Describe the bug
ToolOutputTrimmer can emit a string summary longer than the configured max_output_chars budget. This happens when the existing rich summary is shorter than the original tool output but larger than the configured budget.
Repro steps
With openai-agents 0.22.0:
from types import SimpleNamespace
from agents.extensions import ToolOutputTrimmer
from agents.run_config import ModelInputData
items = [
{"type": "function_call", "name": "search", "call_id": "call_1", "arguments": "{}"},
{"type": "function_call_output", "call_id": "call_1", "output": "x" * 1000},
]
data = SimpleNamespace(
model_data=ModelInputData(input=items, instructions=None),
)
result = ToolOutputTrimmer(max_output_chars=40)(data)
print(len(result.model_data.input[1]["output"]))
The emitted summary is longer than 40 characters.
Expected behavior
Every supported string function-call output replacement should respect max_output_chars. Existing summaries should remain unchanged when they already fit, and outputs should remain untrimmed when the rich summary would not be shorter than the original.
Debug information
- Agents SDK version: 0.22.0
- Python: 3.12.14
- OS: Ubuntu 22.04
- Reproducible: yes
Describe the bug
ToolOutputTrimmer can emit a string summary longer than the configured max_output_chars budget. This happens when the existing rich summary is shorter than the original tool output but larger than the configured budget.
Repro steps
With openai-agents 0.22.0:
The emitted summary is longer than 40 characters.
Expected behavior
Every supported string function-call output replacement should respect max_output_chars. Existing summaries should remain unchanged when they already fit, and outputs should remain untrimmed when the rich summary would not be shorter than the original.
Debug information