Skip to main content
AgentsUse

Harness pattern · Record

Tool-call logs and observability

Log every call with redacted arguments, gate decision, duration, outcome, and result size, then use those logs for maintenance as well as incident review.

The failure it prevents

In production: After a bad run, nobody can answer what the agent did, in what order, or why.

An agent does something wrong at 14:03 and the investigation starts from a chat transcript. Transcripts show what the model said, not what the harness did: which calls ran, which were gated, what the tool returned, how long it took, and what it cost. Without that record, incidents cannot be reproduced and reviews turn into memory against memory.

The second failure is slower. Tool descriptions degrade. A vendor changes a response shape, a parameter gains a new constraint, and the only symptom is a model that got worse. Anthropic reads this directly from evaluation traffic: total tool calls, redundant calls, errors, and invalid-parameter errors per tool show which descriptions to fix. Without counts, the signal is invisible.

How it works

Log at the harness, not in the model's narration. One structured record per call: timestamp, run id, tool, redacted arguments or an argument hash, gate decision, duration, outcome class (ok, tool error, protocol error, cancelled), and result size in tokens. MCP gives servers a logging channel (notifications/message with syslog severity levels) and tells clients to keep configuration so users can enable, disable, and filter it. Treat host-side logging of tool usage as an audit function, not a debug extra.

Redact by default. Arguments and results carry secrets, personal data, and payloads that do not belong in a log store. MCP's logging guidance is direct: never emit secrets or credentials. Hash or truncate arguments, and keep full text only where a retention decision requires it.

Trace runs end to end. Anthropic runs full production tracing on their multi-agent system, watching decision patterns and tool usage while respecting privacy by monitoring patterns rather than reading conversation contents. Apply the same line: aggregate first, drill into individual runs only during an investigation.

Turn counts into maintenance. Per tool: call volume, first-attempt failure rate, invalid-parameter rate, average result tokens, p95 duration. Review monthly. A tool with a rising invalid-parameter rate gets a better description. A tool returning 40,000 tokens per call gets a budget.

When to use it

  • Any agent running unattended, on a schedule, or against real accounts.
  • Approval-gated tools, where the decision record is the audit trail.
  • Multi-agent systems, where responsibility diffuses across workers by design.
  • Cost-sensitive deployments; result-token counts per tool find the spend.

When to skip or soften it

  • Local experiments in a sandbox with throwaway data; a console print is enough.
  • Extremely high-volume read calls where sampling beats completeness; sample deliberately and say so in the config.

Tradeoffs

Logs are a liability as well as an asset: they store what the agent touched, which is often the sensitive part. Retention limits, redaction, and access control are part of the pattern, not follow-up work. Volume is the other cost. One JSON line per call is cheap; full result bodies are not. Log sizes and hashes, and store bodies separately under shorter retention.

One line per tool call (AgentsUse shape)

The minimum record that answers the incident questions and feeds per-tool maintenance metrics. Arguments are hashed; result bodies live elsewhere under shorter retention.

One line per tool call (AgentsUse shape)
{
  "ts": "2026-10-08T14:03:11Z",
  "run_id": "run_8f3",
  "step": 7,
  "tool": "tavily_search",
  "gate": "auto-approved",
  "args_hash": "b3:9f2c",
  "duration_ms": 1840,
  "outcome": "ok",
  "result_tokens": 3120,
  "attempt": 1
}

Shape source: AgentsUse suggested shape; logging duties per MCP specification 2025-06-18. Placeholders only; adapt names and numbers to your stack.

Implementation checklist

  • Every tool call emits one structured record, including gated, rejected, and cancelled calls.
  • Arguments are redacted or hashed; secrets never reach the log (MCP logging rule).
  • Outcome classes separate ok, tool errors (isError), protocol errors, timeouts, and cancellations.
  • Result tokens and duration are recorded per call and aggregated per tool monthly.
  • Retention and access rules for logs are written down next to the logging config.
  • Invalid-parameter and first-attempt failure rates per tool feed the description-fix list.

Sources and freshness

Claims on this page checked against these sources on 2026-10-08. Code and config blocks are shapes to adapt, not benchmarks.