task_context
Retrieve progressive context for a task with depths from task-only to extended plan and transitive dependencies. For RPI implement tasks, automatically includes research and plan outputs.
Instructions
Get progressive context for a task. Depth: 1 (task only), 2 (+ neighborhood), 3 (+ knowledge), 4 (+ extended plan/goals/transitive deps). For RPI implement tasks, automatically includes research+plan outputs from the chain.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | ||
| depth | No | ||
| token_budget | No |
Implementation Reference
- src/tools/bdi/beliefs.js:199-214 (handler)Handler function for task_context: takes task_id, depth (1-4), token_budget; calls /context/progressive API and returns formatted response with as_of timestamp.
async function taskContextHandler(args, apiClient) { const { task_id, depth = 2, token_budget = 0 } = args; const params = new URLSearchParams({ node_id: task_id, depth: String(depth), token_budget: String(token_budget), log_limit: '10', include_research: 'true', }); try { const response = await apiClient.axiosInstance.get(`/context/progressive?${params}`); return formatResponse({ as_of: asOf(), ...response.data }); } catch (err) { return errorResponse('upstream_unavailable', `Failed to load task context: ${err.response?.data?.error || err.message}`); } } - src/tools/bdi/beliefs.js:182-197 (schema)Schema definition for task_context tool: name, description, inputSchema with task_id (required), depth (enum 1-4, default 2), token_budget (default 0).
const taskContextDefinition = { name: 'task_context', description: "Get progressive context for a task. Depth: 1 (task only), 2 (+ neighborhood), " + "3 (+ knowledge), 4 (+ extended plan/goals/transitive deps). For RPI implement " + "tasks, automatically includes research+plan outputs from the chain.", inputSchema: { type: 'object', properties: { task_id: { type: 'string' }, depth: { type: 'integer', enum: [1, 2, 3, 4], default: 2 }, token_budget: { type: 'integer', default: 0 }, }, required: ['task_id'], }, }; - src/tools/bdi/beliefs.js:555-573 (registration)Exports taskContextDefinition in definitions array and taskContextHandler mapped to 'task_context' key in handlers object.
module.exports = { definitions: [ briefingDefinition, taskContextDefinition, goalStateDefinition, recallKnowledgeDefinition, listPlansDefinition, searchDefinition, planAnalysisDefinition, ], handlers: { briefing: briefingHandler, task_context: taskContextHandler, goal_state: goalStateHandler, recall_knowledge: recallKnowledgeHandler, list_plans: listPlansHandler, search: searchHandler, plan_analysis: planAnalysisHandler, }, - src/tools/bdi/index.js:42-46 (registration)Aggregates all BDI tool definitions (including task_context) from beliefs, desires, intentions, utility modules into bdiToolDefinitions.
module.exports = { bdiToolDefinitions: definitions, bdiToolHandler, bdiToolNames: names, }; - src/tools.js:26-28 (registration)MCP server registration: wires bdiToolDefinitions into ListToolsRequestSchema handler so task_context is exposed as an MCP tool.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: bdiToolDefinitions }; });