Skip to content

feat: enhance large tool response handling with character limits - #1189

Merged
thesujai merged 5 commits into
mainfrom
feat/large-tool-call-handling
Oct 28, 2026
Merged

thesujai merged 5 commits into
mainfrom
feat/large-tool-call-handling

Conversation

@thesujai

@thesujai thesujai commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #

Changes

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

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-tools get_tool_info on the deferred-tools server can bypass offload when output stays within min(50,000 characters, 80% of estimated remaining context), using model contextLength and 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 via describeContentSize), 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.

@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aaf81f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@truefoundry/trueforge-core Patch
@truefoundry/trueforge Patch

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

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge-core/src/core/capabilities/builtins/LargeToolResponse.ts Outdated
Comment thread packages/trueforge-core/src/core/capabilities/builtins/LargeToolResponse.ts Outdated
@veria-ai

veria-ai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Comment thread packages/trueforge-core/src/core/capabilities/builtins/LargeToolResponse.ts Outdated
Comment thread packages/trueforge-core/src/core/capabilities/builtins/LargeToolResponse.ts Outdated
Comment thread packages/trueforge-core/src/core/capabilities/builtins/LargeToolResponse.ts Outdated

@chiragjn chiragjn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it approved with comments

@thesujai
thesujai enabled auto-merge (squash) October 28, 2026 09:55
@thesujai
thesujai disabled auto-merge October 28, 2026 09:55
@thesujai
thesujai enabled auto-merge (squash) October 28, 2026 10:13
@thesujai
thesujai merged commit e6a2e9e into main Oct 28, 2026
15 checks passed
@thesujai
thesujai deleted the feat/large-tool-call-handling branch October 28, 2026 10:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aaf81f7. Configure here.

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