Skip to content

Fix: count all tool tokens in budget and add summarization UserMessage priority#5000

Merged
bhavyaus merged 1 commit intorelease/0.43from
dev/bhavyau/fix-tool-token-budget-0.43
Apr 6, 2026
Merged

Fix: count all tool tokens in budget and add summarization UserMessage priority#5000
bhavyaus merged 1 commit intorelease/0.43from
dev/bhavyau/fix-tool-token-budget-0.43

Conversation

@bhavyaus
Copy link
Copy Markdown
Contributor

@bhavyaus bhavyaus commented Apr 6, 2026

Cherry-pick of #4992 into release/0.43.

Problem

Two issues causing summarization failures:

1. Tool token under-counting (context_length_exceeded → "No messages provided")

The 3/30 change (#4834) excluded deferred tools from toolTokens, making the message budget ~31K too generous. The summarization call uses ChatLocation.Other where all tools count fully, causing conversations to overflow the context window.

2. Summarization UserMessage has no priority (empty messages)

The final "Summarize the conversation..." UserMessage had no explicit priority (defaulting to 0). Under tight budgets, prompt-tsx would prune it, resulting in empty messages → "No messages provided".

Changes

  • agentIntent.ts: Count all tools for toolTokens (remove effectiveTools filtering)
  • summarizedConversationHistory.tsx: Add tool-token budget reduction in getSummary(Full), add priority to summarization UserMessage
  • summarization.spec.tsx: Add repro test for empty messages with small budget

…ools

Deferred tools (defer_loading: true) still count against the API context
window. The 3/30 change (#4834) excluded them from toolTokens, causing
the message budget to be ~31K tokens too generous and leading to
context_length_exceeded errors followed by summarization failures
("No messages provided").
@bhavyaus bhavyaus enabled auto-merge April 6, 2026 18:08
@bhavyaus bhavyaus merged commit 303b0dc into release/0.43 Apr 6, 2026
19 checks passed
@bhavyaus bhavyaus deleted the dev/bhavyau/fix-tool-token-budget-0.43 branch April 6, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants