Recorder

Claude Agent SDK

Each agent's query ends with a result message that carries its usage and cost. Record it once per agent.

  1. Copy harness_recorder.py into your project.
  2. Record each agent's result message as below.

Record a query

from harness_recorder import Recorder, usage_from
run = Recorder("claims-settlement", "3.0.0").start_run(claim_id)
with run.agent("settle", prompt_ref="prompts/settlement-calculator@3", model="anthropic/claude-sonnet-5") as step:
    async for message in query(prompt=task, options=options):
        if type(message).__name__ == "ResultMessage":
            step.model_call(**usage_from(message), cost_usd=message.total_cost_usd)
run.finish("completed")

Where the log lands

Wherever your service logs go, or a folder.

How it reaches the harness

You download the logs with your own access.

Read the full guide on GitHub

Add the recorder

20 platform guides in total.