> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracepress.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# When am I frustrated with my agent?

> Find the moments in your own Claude Code sessions that went wrong.

Claude Code keeps every session on disk, so you can ask questions of your own work. This
recipe finds the messages where you were frustrated with the agent, then sums up what caused
it in each session.

```python theme={null}
import tracepress as tp

tp.configure(lm="openrouter:openai/gpt-6-luna")
src = tp.read.claude_code(project="my-repo", limit=50)   # or tp.read.codex()

moments = (src.steps
    .filter(lambda r: r.source == "user")
    .lm_map("message -> frustrated: bool, about",
            instructions="Is the user frustrated with the agent? If so, say what about."))

per_session = (moments.filter(lambda r: r.frustrated)
    .group_by("session")
    .lm_reduce("about -> causes: list[str]",
               instructions="What did the agent keep doing that frustrated the user?"))

per_session.to_pandas()
```

`tp.read.claude_code()` reads `~/.claude/projects` by default. `project` keeps sessions whose
working directory contains it, and `limit` keeps the most recently active ones. The plain-Python
`filter` drops agent and tool steps before any LLM call, so you only pay for your own messages.

To watch for this live instead, register the same `lm_map` on a server: see
[Live pipelines](https://docs.tracepress.ai/cookbooks/live.md#keep-pipelines-running-on-a-server).

## Next steps

> [card] [Load traces](https://docs.tracepress.ai/cookbooks/sources.md)
>
> Codex sessions and the other sources.

> [card] [Optimization](https://docs.tracepress.ai/cookbooks/optimize.md)
>
> Label a few messages and tune the detector.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.