Agent Harness Tutorial · End to end · Zoom level 3
How we take care of it: cut to 8,000 chars
cut to 8,000 chars catches huge results.
How we took care of it.
- Results over 8,000 characters are cut, with the mark "…[truncated from N characters]".
| It reads | the size of each tool result |
| Kind | rule |
| Provided by | harness |
| If it fails | the cut result |
| Where in the code | GatedTools._bound() · H tools/__init__.py |
| Runs at | 5 · The tool itself |
Real exampleGap F-129: the setting itself does nothing yet; the 8,000 is fixed.
More on this: Trimming.
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
def _bound(self, result: ToolResult, span: Span) -> ToolResult:
"""AAC-0105, AOAS Q-TOOL-RESULT — a result enters context bounded.
Measured on `for_context()`, the rendering the context boundary sends.
The first version measured the structured payload and cut the text
block, while the context sent the structured payload — so a large
structured result, the common kind, went through whole (F-023).
"""
rendered = result.for_context()
limit = self._max_result_chars
if len(rendered) <= limit:
return result
span.set_attribute("agent.tool.truncated", True)
tel.counters.tool_truncated.add(1, {"tool": result.name}) # AACP-0004
mark = TRUNCATION_MARK.format(total=len(rendered))
bounded = rendered[: max(0, limit - len(mark))] + mark
return result.model_copy(update={"text": bounded[:limit], "truncated": True})