history_context
Retrieve recent collaboration context to continue previous work by accessing the last few interactions between AI models.
Instructions
获取最近的协作上下文,可用于继续之前的工作
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | 获取最近几次协作,默认 3 |
Implementation Reference
- src/server.ts:246-258 (registration)Tool registration in ListToolsRequestSchema handler, defining name, description, and input schema for 'history_context' tool.{ name: 'history_context', description: '获取最近的协作上下文,可用于继续之前的工作', inputSchema: { type: 'object', properties: { count: { type: 'number', description: '获取最近几次协作,默认 3', }, }, }, },
- src/server.ts:555-581 (handler)The main handler for the 'history_context' tool in the CallToolRequestSchema switch statement. It calls historyManager.getRecent to fetch recent collaboration history and formats it as markdown context for continuing previous work.case 'history_context': { const { count } = args as { count?: number }; const recent = historyManager.getRecent(count || 3); if (recent.length === 0) { return { content: [ { type: 'text', text: '暂无协作历史记录', }, ], }; } const contextText = recent.map(entry => { return `### ${entry.task}\n**ID**: ${entry.id}\n**时间**: ${new Date(entry.timestamp).toLocaleString()}\n\n${entry.summary}`; }).join('\n\n---\n\n'); return { content: [ { type: 'text', text: `## 📚 最近的协作上下文\n\n${contextText}`, }, ], }; }
- src/collaboration/history.ts:219-224 (helper)HistoryManager.getRecent method, which retrieves the most recent complete history entries by calling list() and get() methods. This is the core utility function invoked by the tool handler.*/ getRecent(count = 5): HistoryEntry[] { return this.list(count) .map((s) => this.get(s.id)) .filter((e): e is HistoryEntry => e !== null); }