-
Notifications
You must be signed in to change notification settings - Fork 478
Description
Description
The context pruner's summarizeToolCall function always falls back to the generic "Read docs" summary for read_docs tool calls because it reads input.query which doesn't exist on the ReadDocsParams schema.
Root Cause
In agents/context-pruner.ts (line 253-256 in the exported function and the duplicated version inside handleSteps):
case 'read_docs': {
const query = input.query as string | undefined // ← wrong field name
return query ? `Read docs: "${query}"` : 'Read docs'
}But ReadDocsParams (defined in agents/types/tools.ts:207-214) has these fields:
export interface ReadDocsParams {
libraryTitle: string
topic: string
max_tokens?: number
}There is no query field. input.query is always undefined, so every read_docs call is summarized as the generic 'Read docs' instead of e.g. 'Read docs: "Next.js - routing"'.
Impact
After context pruning, the model loses information about which libraries/topics were already fetched. This can cause redundant re-fetches of documentation that was already retrieved, wasting tokens and time.
Suggested Fix
case 'read_docs': {
const libraryTitle = input.libraryTitle as string | undefined
const topic = input.topic as string | undefined
if (libraryTitle && topic) {
return `Read docs: "${libraryTitle} - ${topic}"`
}
return libraryTitle ? `Read docs: "${libraryTitle}"` : 'Read docs'
}Note: this fix needs to be applied in both copies — the exported summarizeToolCall function at the top of the file and the duplicated version inside handleSteps (which is serialized to a string for the agent runtime).