Reduce ToolReturn.attachments under ToolOutputLimits
Closed
KU
4d ago+274+274+012345678901234567890123456789-34-34-01234567890123456789
Summary
- Apply
ToolOutputLimitsbands to each text item inToolReturn.attachments(nested-tool content such as Code Mode's), independently ofreturn_value/content. - Keep each attachment's
tool_call_id,tool_name, andcapability_id; put the truncation or spill note on that attachment. File attachments pass through. Spilled attachments recordoverflow_attachment_handlesin metadata. - Docs and skill text updated to match.
Closes #15002.
Follow-up to #14479 (this PR is stacked on tool-return-content-carrier).
Test plan
-
uv run --no-sync pytest -p no:cacheprovider tests/harness/tool_output_limits - New
TestAttachmentReductioncases (truncate, spill, only-attachments, per-item, TextContent, file passthrough, combined) - Docs parity for tool-output-limits
- Ruff + basedpyright on changed paths
Summary by cubic
Reduces oversized text in ToolReturn.attachments so nested-tool content, such as Code Mode's, no longer reaches the model unreduced. Text attachments are now measured and reduced independently with the same ToolOutputLimits bands used for return_value and content, while preserving each attachment's tool_call_id, tool_name, and capability_id. Truncation or spill notes are placed on the attachment itself; file attachments pass through unchanged. Spilled attachments record overflow_attachment_handles in ToolReturn.metadata, keyed per attachment's tool_call_id. Docs and skill references updated to match. Closes #15002.