Skip to content
Back to full roadmap
topiccore

Tool Result Formatting

Tool output = prompt to the model. Too large blows context; structure with XML/JSON.

2 hours1 prereqs

Patterns:

  1. Compact JSON{"temp": 22, "condition": "sunny"} — small, parser-friendly.
  2. Markdown table — human + model readable for multiple rows.
  3. XML sections — for complex nested data: <weather><current>...</current><forecast>...</forecast></weather>.
  4. Summary + raw — large data: 100-token summary first, then optional raw <raw>...</raw> block.

Pro: prefix the result with a context sentence like Result for query 'X': — the model instantly knows what it's a result of.

Anti-pattern: raw HTML, raw SQL output, 10K-line log dumps — kill the context.

Prerequisites