Trace runs, not conversations
Someone tells you the agent answered badly. To fix it, you need the run: what it was asked, which tools it called, what each one returned, and what it answered. Now say the question came from a direct message between two colleagues. The run that would explain the bad answer is also a private conversation, and the people who debug the agent were never part of it.
On Agent Core, every run is traced and every answer is graded. Each run also decides whether its text may leave the service at all.
What the article argues
Anthropic’s How we built our multi-agent research system has a short section on running agents in production. Agents make different decisions from one run to the next, so a report that the agent wasn’t finding obvious information can’t be explained without seeing the run. Full production tracing is what let them diagnose failures and fix them systematically. They also watch decision patterns and how agents interact, “without monitoring the contents of individual conversations”, to protect users’ privacy.
Those two goals pull against each other.
One trace per run
Every run already produced an OpenTelemetry trace, but only its size-limited, redacted log lines left the service. I had the agent loop report every model request: its purpose, timing, usage, and the messages the provider hadn’t seen yet. A continuation reports only the messages added since the previous request, so a long run doesn’t repeat its whole history in every step. Then I exported that trace to a self-hosted Langfuse through a second span processor, next to the one that writes logs. It only exports spans that carry Langfuse attributes, so authentication and storage spans stay out.
The root span is the run. Each model request becomes a generation under it, each product read a tool observation, and the posted reply a span that carries its status and kind but never its text. The session ID names the conversation, such as comms:thread:<id>, so every run in one thread lands in one Langfuse session. Langfuse reads the user and the session on each observation, not just the root, so I repeated both on every child. Before that, Langfuse put the cost of every run under an unknown user, because the generations that carry the cost had no user on them.
Here is the trace of one run from the service’s integration test. The test uses a fake product: the question is “Who owns the release?”, the model calls one read tool, then answers. The root span’s attributes (trimmed):
{
"langfuse.trace.name": "agent_core.run",
"user.id": "user-1",
"session.id": "fake:record:record-1",
"langfuse.trace.tags": ["product:fake", "anchor:record", "audience:public",
"route:economy", "env:development", "outcome:completed"],
"langfuse.trace.metadata.run_id": "<run id>",
"langfuse.trace.metadata.audience": "public",
"agent_core.anchor.kind": "record",
"agent_core.audience": "public",
"agent_core.run.first_status_ms": <number>,
"agent_core.run.first_answer_ms": <number>,
"langfuse.trace.input": "{\"question\":\"Who owns the release?\",\"anchor\":{\"kind\":\"record\",\"object_id\":\"record-1\"}}",
"langfuse.trace.output": "The deterministic run completed."
}
In that test, two generations sit under the agent_core.model span. The first one’s output is the tool call, {"tool_calls": [{"name": "fake.load_record"}]}, and the second carries its usage. The agent_core.tool observation holds what the read returned, {"id": "record-1"}, with stop_reason: complete in its metadata. When the judge grades the run, an agent_core.judge evaluator sits under the root with its own generation, so its usage never mixes with the answer’s.
A run from the evaluation set has the same shape. It carries the evaluation environment and a client request ID of eval:<case>:<repeat>, so it can be filtered out of real traffic. The daily report reads these traces from the production environment only, and a read either returns everything or fails, so a partial read can’t turn into wrong numbers.
Content only where it may leave
From the start, the exporter decided per run whether content leaves the service. Content means the question, the messages of every model request, the tools’ arguments and results, and the answer. Everything else is exported either way: IDs, tags, timing, usage, cost and scores. LANGFUSE_CONTENT_CAPTURE has three values: all, public (only public channels and workspace-wide sessions), and none. Every content attribute goes through the run’s decision.
The setting changed twice in production that first week, and the order matters.
- For the first release to people at Todoist, production captured content in every conversation, readable by a small named group and purged after 90 days.
- People in a DM or a private channel couldn’t know their messages were in a trace, including people who never tagged the agent. I made the first reply in a private conversation end with a fixed notice, repeated when the members change. I reverted it ten minutes later, before it was deployed. The agent was an experiment for people at Todoist, the notice was behavior we’d have to remember to remove, and an announcement to everyone would cover it.
- That evening, we decided private conversations should not leave the service at all, and production switched to
public. A DM’s run still gets its score, latency, cost and failures, but no question, sources or answer. The audience is checked again at every run, so a channel that turns private stops exporting content.
Then the agent started running outside our own workspace. public was about audience, not ownership, so a customer’s public channel would have been exported in full. I added LANGFUSE_CONTENT_CAPTURE_WORKSPACES, a list of <product>:<workspace_id> entries, and production listed only our own. I moved the decision into one function, contentCapture, that checks the workspace first, then the audience. Some of its unit test cases, laid out as a table:
capture audience workspace list decision
all private none captured
public private none audience_not_public
public public none captured
none public none off
public private lists this workspace audience_not_public
all public lists another workspace workspace_not_listed
all public set, chat has no workspace workspace_not_listed
Each run span records the result, so a wrong list shows up in Datadog as a count per reason.
Here is the same test run, asked in a private group chat with capture set to public. The root’s tags now include conversation:group and audience:private. The test serializes every span’s attributes and checks what’s missing: “Who owns the release?” doesn’t appear, neither does “The deterministic run completed.”, and no observation has an input or an output. The first generation still has its usage_details; only content is gated, so the tool observation and both generations are still exported. Someone reading this trace sees one read, two model requests and the outcome. They can’t see what it was asked.
Scores and votes without the text
A trace is only half of it. To know which runs to look at, each one needs a grade. I added a score sink with a deterministic ID per score, <traceId>:<name>, so a retry replaces a score instead of adding a second one. The judge writes eight scores on the trace: the composite and one per dimension. The asker’s thumbs up or down, which Comms delivers, becomes a user_feedback score on the same trace: 1 for up, 0 for down, and a removed vote keeps a 0 marked removed: true.
The scores are numbers, but the judge also gives a short reason per dimension, and a reason can name a fact from the conversation. So reasons follow the run’s capture decision: a run whose content stays in the service exports its scores and answer kind with no comment. When reasons are exported, the judge prompt forbids quoting, and code checks anyway. A reason that repeats eight consecutive words of the question, a source or the history is replaced. From the judge’s unit test, with the question “Who owns the release and when it ships next week?” and this reason for helpful:
Answers who owns the release and when it ships next week fully
The composite’s comment on the trace becomes:
helpful: Reason withheld: it quoted the conversation.; source_support: fine; invented_claims: fine; current_decision: fine; audience_safe_sources: fine; cited_sources: fine; member_tone: fine
The other six reasons are the test fixture’s “fine”. The check stops verbatim passages, not every short fragment, so it backs up the capture decision, it doesn’t replace it. The same rule applies to the vote: for a reply in a workspace that isn’t listed, the vote is recorded and any reason written with it is not sent.
Then there’s the second exit. The span log writes every span attribute to the service log, and Datadog ingests that log. I had put the judge’s scores on its span as plain numbers, so a dashboard could average them next to failures and latency. But the verdict, with its seven reasons, was also a span attribute, so it reached Datadog for every run, private conversations included. Before the fix, a judge span’s log record ended with:
"langfuse.observation.metadata.verdict": "{\"dimensions\":{\"helpful\":{\"score\":2,\"reason\":\"...\"}}}"
After the change, the record kept agent_core.judge.composite, the per-dimension scores and answer_kind, and had no verdict. The span log then dropped every langfuse.* attribute except an allowlist of codes and IDs the dashboard reads: the anchor kind and workspace, the audience, the model parameters, an outcome and its failure codes. Langfuse still got everything. Votes followed the same rule: the feedback span records agent_core.feedback.vote (up, down or removed) and a delivery status, never the voter or the post.
What I’d tell someone doing the same
- Decide once per run, in one place, and record the decision. Every content attribute and the judge’s reasons read that one result, and the vote’s reason follows the same workspace rule. Writing
captured,off,workspace_not_listedoraudience_not_publicon the run span turns a misconfiguration into a number you can watch. - Allowlist what goes to your log, not blocklist. We had two exits, Langfuse and the log, and protected only the first. With an allowlist, new trace metadata stays out of the log until someone adds it on purpose.
- Check your own signal through the real logger. The capture decision was first named
agent_core.content_capture, and the log redacts any field whose name containscontent, so I renamed it toagent_core.captureand covered it with the logger test in Measure failures where the model sees them.
The trade-off: in a private conversation, we know a run scored low, how many reads it made, how long it took and whether its reply was posted. We don’t know what it read or answered.