cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Checks › 5 · The tool itself › cut to 8,000 chars

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.

Open: 11before loopopen ›Open: 22before modelopen ›Open: 33after modelopen ›Open: 44before toolopen ›Open: 55the toolopen ›Open: 66after toolopen ›Open: 77after loopopen ›Open: 88before replyopen ›It readsthe size of each tool resultcut to 8,000 charsrule · harnesspassCarries onfailIf it failsthe cut resultWHERE IN THE CODE: GatedTools._bound() · H tools/__init__.py
The strip at the top shows every check point where this check runs, in dark.

How we took care of it.

  1. Results over 8,000 characters are cut, with the mark "…[truncated from N characters]".
It readsthe size of each tool result
Kindrule
Provided byharness
If it failsthe cut result
Where in the codeGatedTools._bound() · H tools/__init__.py
Runs at5 · 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})