agent runtime lab en · 2026 · Technical Research Note
06. How Tool Results Should Return to the Model
The model does not observe local execution; the runtime must carry evidence into the next turn
Comparing complete delivery, truncation, structured summaries, and external references for model evidence and context control.
Research edition · 8 chapters · 4 minute read · Updated 2026-07-27
When a model emits pwd, it does not know which path the command will return. Execution occurs outside the model and does not update model state automatically.
A second model request is required:
task → proposed call → runtime execution → result delivery → next decision
Without the call record, the model may not know which action produced a result. Without the result, it can only guess. Showing raw output directly to the user prevents the model from combining evidence or formatting the required answer.
A result is more than appended text
| Field | Question answered |
|---|---|
| Call identifier | Which request produced this result? |
| Status | Completed, failed, denied, or unknown? |
| Content | What evidence is available? |
| Error | Why is there no result? |
| Truncation marker | Is the content complete? |
| External reference | Where is the complete result stored? |
The durable trace can retain the full structure while the model-facing representation is compressed. Reusing one already-truncated string for both destroys the original debugging evidence.
Four delivery strategies
| Strategy | Suitable content | Cost |
|---|---|---|
| Complete | Small structured results | Consumes context |
| Head and tail | Long logs and stack traces | Can omit middle evidence |
| Structured summary | Documents and search results | Can omit or alter facts |
| External reference | Datasets and build artifacts | Requires later range reads |
A 100 KB log should not enter context by default. Store the original and return line count, error lines, head and tail samples, and a content reference. The model can request a range when needed.
Truncation must be explicit
A result reports original bytes, returned bytes, truncation point, retained region, and a method for retrieving the rest. “No error was found” is different from “the unreturned region may contain an error.”
Parallel results remain independent
Kimi’s second request contained two role=tool messages referring to Bash_0 and Bash_1. Identity, not completion time, joined each result to its call.
If one parallel call succeeds and another times out, the batch cannot collapse into one failure value. The model needs each status to retry only the failed item.
Summaries point back to evidence
Every summarized fact should refer to a log range, file-fragment identifier, or result-object path. When an answer is wrong, the trace can distinguish a tool error from a summarizer error and a later reasoning error.
The summarizer itself follows a result contract containing facts, uncertainties, omitted ranges, and the original result reference. A fluent paragraph alone hides missing information.
Strategy depends on tool semantics
Directory listings fit structured arrays. Command logs fit head-and-tail retention plus extracted error lines. Search results fit itemized summaries with sources. Binary artifacts return metadata and a reference.
One character limit for every tool discards different critical evidence. Regression tests include encoding failures, empty output, repeated fields, and one extremely long line.
Measuring the tradeoff
Run the same tool at 1 KB, 100 KB, and 1 MB under all four strategies:
| Metric | Meaning |
|---|---|
| Next-turn input Tokens | Context growth |
| Fact accuracy | Whether specified evidence is found |
| Additional tool calls | Whether the model must fetch ranges |
| Time to first Token | Latency from larger input |
| Traceability | Ability to return to the original |
The objective is neither minimum output nor maximum completeness. It is a verifiable boundary among evidence, context cost, and recovery.
Budget for the next decision
| Plane | Content | Default context |
|---|---|---|
| Control | Status, error class, truncation, duration | Included |
| Decision | Fields needed for the next action | Included |
| Evidence | Full body, logs, binary objects | Referenced |
MCP supports text, structured content, resource links, and outputSchema validation. MCP Tools specification
Truncation tests place the decisive fact at the beginning, middle, and end, then compare head, tail, and relevance selection. Each result records original bytes, retained ranges, encoding, source reference, and reason.
Summary fidelity probes check error codes, files, object counts, and receipts. Identifiers remain verbatim. The measurement unit is the full Agent loop: a short summary that causes three repeated calls can cost more than one complete result.
Statement: If no specific statement in the content, the copyright belongs to sshipanoo . Reprint please indicate the link of this article.
(The content is authorized with CC BY-NC-SA 4.0 protocol)
Title:06. How Tool Results Should Return to the Model
Link:https://www.sshipanoo.com/en/blog/ai/agent-runtime-lab/how-tool-results-return-to-model/
