Repository navigation
feat: enhance large tool response handling with character limits - #1189
Conversation
🦋 Changeset detectedLatest commit: aaf81f7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
…d character limit adjustments
chiragjn
left a comment
There was a problem hiding this comment.
Keeping it approved with comments
…ment for elevated tools
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit aaf81f7. Configure here.
| return false; | ||
| } | ||
| return ELEVATED_TOOLS.has(info.originalToolName) && entry.originalContent.length <= limit; | ||
| } |
There was a problem hiding this comment.
Elevated tools ignore combined budget
Medium Severity
Each deferred get_tool_info result skips offload if it alone is under min(50000, 80% of remaining context). Sibling elevated results never share that budget, so several parallel get_tool_info calls can keep far more than remaining context and overflow the next model request.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit aaf81f7. Configure here.


Summary
Closes #
Changes
How was this tested?
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,python/trueforge_sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Medium Risk
Changes core context-window tool response processing and what the model sees when outputs are truncated; mis-tuned limits could allow context blow-ups or over-block
get_tool_info.Overview
Large tool response handling is tightened and the messages shown to the model are clearer when outputs are blocked or offloaded to the sandbox.
Blocking now uses a strict
>token threshold (and an early exit when the batch total is at or below the individual limit) so responses exactly at the advertised character cap (tokens × 4) are not offloaded. Deferred-toolsget_tool_infoon the deferred-tools server can bypass offload when output stays within min(50,000 characters, 80% of estimated remaining context), using modelcontextLengthand live usage passed in from the agent spec.Blocked MCP, sandbox, and file-dump paths share a
Content too big (N characters; reason)preamble (plain digit sizes viadescribeContentSize), with RFC 2119 MUST/MAY/SHOULD recovery steps including explicit per-response character limits. Sub-agent large-output guidance uses the same tone.Reviewed by Cursor Bugbot for commit aaf81f7. Bugbot is set up for automated code reviews on this repo. Configure here.