Richer agent transcripts + lifecycle data for observability (Langfuse / stop hooks)

Hey, thanks for such a well thought-out request. The Ask 1 to 5 breakdown with an example of the desired JSONL schema is exactly the level of detail we need. I’ve forwarded it as a feature request.

I also want to clarify the status on a few items so you don’t build a pipeline on the wrong expectations:

  • stop payload: it fires in local CLI plus IDE and includes conversation_id, transcript_path, model or model_id or model_params. Token usage input_tokens, output_tokens, cache_* is not included in the stop payload right now. That’s one of the key points in your request and it’s tracked.
  • Token usage, thinking, and assistant message are available today via headless --print with --output-format stream-json. The final result event includes token usage and the request ID, and along the way you also get thinking deltas and the full assistant message. For cost dashboards and trace reconstruction, this is a workable interim option without transcript enrichment.
  • afterAgentResponse and afterAgentThought: these do not fire in CLI right now, neither headless nor interactive. This is a known gap, see Hooks afterAgentResponse / afterAgentThought not firing in headless CLI. They work in the IDE.
  • Env for hooks Ask 4: the sessionStart hook response can set env for later hook calls in the session, but there are important caveats. Subagents do not inherit that env, see SubAgents do not inherit environment variables, and variables are lost when you close and reopen a chat or restart Cursor. sessionStart is not replayed on resume, see Env exported in sessionStart hook does not persist across Cursor restarts. So as a channel for persistent secrets it’s not reliable right now. Sidecar files are the more honest option for now.

On the main asks, Ask 1 transcript schema enrichment, per-row timestamps, usage, tool_result with tool_use_id, stable IDs, per-row model, and Ask 2 flush or ready signal before stop, there’s no implementation timeline yet. The request is logged in that form.

Also, a sample current vs desired JSONL from your local agent-transcripts/ would be helpful. If you can share it here, it’ll help us pin down the minimum viable schema more precisely.