plan_intent
Generate execution plans with policy checkpoints to coordinate and manage intent workflows through memory gateway capabilities.
Instructions
Generate an intent execution plan with policy checkpoints
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| intentId | Yes | ||
| context | No | ||
| mcpProfile | No | ||
| bundleId | No | ||
| partnerProfile | No | ||
| delegationMode | No | ||
| approved | No | ||
| repoPath | No |
Implementation Reference
- scripts/intent-router.js:150-255 (handler)The planIntent function is the core logic for the 'plan_intent' MCP tool. It loads policy bundles, validates intents, ranks actions based on strategy, checks code graph impact, and evaluates delegation.
function planIntent(options = {}) { const bundle = loadPolicyBundle(options.bundleId); const profile = assertKnownMcpProfile(options.mcpProfile || getActiveMcpProfile()); const intentId = String(options.intentId || '').trim(); const context = String(options.context || '').trim(); const approved = options.approved === true; const tokenBudget = resolveTokenBudget(options.tokenBudget); const delegationMode = normalizeDelegationMode(options.delegationMode); if (!intentId) { throw new Error('intentId is required'); } const intent = bundle.intents.find((item) => item.id === intentId); if (!intent) { throw new Error(`Unknown intent: ${intentId}`); } const requiredRisks = getRequiredApprovalRisks(bundle, profile); const requiresApproval = requiredRisks.includes(intent.risk); const checkpointRequired = requiresApproval && !approved; const partnerStrategy = buildPartnerStrategy({ partnerProfile: options.partnerProfile, tokenBudget, }); const rankedActions = rankActions(intent.actions, { modelPath: options.modelPath, partnerStrategy, }); const plannedActions = partnerStrategy.profile === 'balanced' ? intent.actions : rankedActions.ranked; const phases = decomposeActions(plannedActions); const codegraphImpact = analyzeCodeGraphImpact({ intentId, context, repoPath: options.repoPath, }); const partnerChecks = mergeUnique([ ...partnerStrategy.recommendedChecks, ...codegraphImpact.verificationHints, ]); const enrichedPartnerStrategy = { ...partnerStrategy, recommendedChecks: partnerChecks, }; const basePlan = { bundleId: bundle.bundleId, mcpProfile: profile, partnerProfile: enrichedPartnerStrategy.profile, generatedAt: new Date().toISOString(), status: checkpointRequired ? 'checkpoint_required' : 'ready', intent: { id: intent.id, description: intent.description, risk: intent.risk, }, context, requiresApproval, approved, checkpoint: checkpointRequired ? { type: 'human_approval', reason: `Intent '${intent.id}' has risk '${intent.risk}' under profile '${profile}'.`, requiredForRiskLevels: requiredRisks, } : null, actions: plannedActions, phases, tokenBudget: enrichedPartnerStrategy.tokenBudget || tokenBudget, partnerStrategy: enrichedPartnerStrategy, actionScores: rankedActions.scores, codegraphImpact, killSwitches: loadGatesConfig().gates .filter((g) => { const isHighRisk = ['high', 'critical'].includes(intent.risk); if (isHighRisk && (g.severity === 'high' || g.severity === 'critical')) return true; const actionNames = plannedActions.map((a) => a.name); return g.trigger && actionNames.some((name) => g.trigger.toLowerCase().includes(name.toLowerCase())); }) .map((g) => ({ id: g.id, layer: g.layer || 'Execution', action: g.action, severity: g.severity, })), }; const delegation = evaluateDelegation({ delegationMode, plan: basePlan, mcpProfile: profile, context, repoPath: options.repoPath, }); return { ...basePlan, executionMode: delegation.executionMode, delegationEligible: delegation.delegationEligible, delegationScore: delegation.delegationScore, delegationReason: delegation.delegationReason, delegateProfile: delegation.delegateProfile, handoffContract: delegation.handoffContract, }; } - adapters/mcp/server-stdio.js:343-353 (handler)The MCP handler registration for 'plan_intent' calls the planIntent function imported from intent-router.js.
case 'plan_intent': return toTextResult(planIntent({ intentId: args.intentId, context: args.context || '', mcpProfile: args.mcpProfile, bundleId: args.bundleId, partnerProfile: args.partnerProfile, delegationMode: args.delegationMode, approved: args.approved === true, repoPath: args.repoPath, }));