Skip to content

Add MaxResultSizeHint to ToolAnnotations for agent-level result truncation - #159

Draft
myzie wants to merge 1 commit into
mainfrom
worktree-feat+large-result-truncation
Draft

Add MaxResultSizeHint to ToolAnnotations for agent-level result truncation#159
myzie wants to merge 1 commit into
mainfrom
worktree-feat+large-result-truncation

Conversation

@myzie

@myzie myzie commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds MaxResultSizeHint int to ToolAnnotations; when > 0, the agent truncates oversized text content blocks after tool execution
  • Truncated results are written in full to a temp file (OS-managed cleanup); a footer appended to the result tells the model where to find the full output
  • Exports TruncateResult(s string, max int) (result, tmpPath string, err error) for toolkit authors to use directly
  • Default hints: ReadFile and Fetch → 100,000 chars; Bash → 50,000 chars
  • Truncation is skipped for error results, suspend results, background results, and non-text content blocks

Test plan

  • TestTruncateResult/short_string_is_unchanged — no-op below limit
  • TestTruncateResult/exact_limit_is_unchanged — boundary case
  • TestTruncateResult/over_limit_is_truncated_with_footer — footer contains char count and temp file path
  • TestTruncateResult/unicode_is_truncated_by_rune_count — multi-byte chars counted correctly
  • TestToolAnnotationsMaxResultSizeHint — JSON round-trip preserves the field
  • TestToolAnnotationsZeroHintOmitted — zero value omitted from JSON

🤖 Generated with Claude Code

…ation

Adds MaxResultSizeHint int to ToolAnnotations. When > 0, the agent
truncates oversized text results, writes the full output to a temp file,
and appends a footer so the model can access the tail via ReadFile.
Exports TruncateResult for toolkit authors. Defaults: ReadFile/Fetch
100k chars, Bash 50k chars.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83847302-5715-4723-8439-1e5c7cf4cbc3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-feat+large-result-truncation

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant