From c8ed37e126a5db64ca2eb049d7fa6307543a01ff Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 15 Oct 2026 12:25:14 +0800 Subject: [PATCH] sessions: each Codex response exported to Langfuse carries only its own reply and tool calls, with the turn's prompt, and a finished turn exports once (#2284, JuckZ) JuckZ's Codex Desktop trace in Langfuse showed one reply repeated on every later response of its turn, no prompt or tool linkage, and a completed turn exported a second time as failed. - token_usage_record copied t.output (the turn's last AgentMessage, a role-less text array) into every later response, including tool-call-only ones. Each generation now takes its bodies from the rollout's response_items: input is the base instructions (session_meta) as a system message, the turn's developer/user messages, and the tool results fed back since the previous response; output is only that response's assistant text and tool calls, in OpenAI chat shape with call IDs. Turn IDs fall back to the desktop's internal_chat_message_metadata_passthrough.turn_id, then the current turn (the CLI records none). - task_complete/turn_aborted deleted the turn but left it current, so the following thread_settings_applied recreated it and the next task_started exported it again as an inferred, failed root under the same ID. - Extension items (web search, image generation) get a span named by kind with query/action/prompt in and results/saved_path/failure out; FileChange gets its diff, ImageView its path. Never the image generation's base64 result. Not copied from the reference: it rebuilt the whole turn history for every response. That is quadratic, and the user's real rollouts carry 2-3MB screenshots in tool outputs and 100-400KB data-URL images in prompts, which it would repeat on each response. Here inline images in a prompt or fed-back result are named ("[image image/png, N bytes not exported]"); the tool's own span keeps the output as recorded. Siblings: Claude, Pi/omp, Gemini and OpenCode already give each response its own message's content; the reused output and the recreated root were Codex-only. Fixture: internal/sessions/testdata/traces/codex-desktop-sanitized.jsonl is JuckZ's file byte for byte (cmp against d96139c2), described in the README. Run (worktree on origin/main 95e7c6bcc, sandbox HOME): - go test ./internal/sessions -run 'Codex|Trace'; -race -count=20 -run Codex - end to end through sessions.TraceReader.Poll + otlp.sessionRecord on the fixture: 2 roots, 28 generations, system+developer+user in, own reply out - gofmt -l; go vet ./... (darwin), GOOS=windows, GOOS=linux -tags nogui - go test -count=1 ./internal/sessions ./internal/otlp: ok Full suite: SUITE_LINE Broken by hand, each red: the original traces.go (all three new tests); output from t.output; out not reset between responses (repeated tool call id, 8 of 5 responses with text); data URL kept; Extension unhandled (0 of 4 web ops); current not cleared on completion (3 roots over 2 IDs); base instructions dropped; native bodies dropped. Not tried: a real Langfuse server, a live Codex Desktop or Windows run, context compaction (the transcript is not reset on it), earlier turns' context in a response's input, local_shell_call/web_search_call response items. Masking of tool arguments and MCP result order from the reference are left out of this commit. Co-authored-by: JuckZ <35656100+JuckZ@users.noreply.github.com> --- internal/sessions/testdata/traces/README.md | 13 + .../traces/codex-desktop-sanitized.jsonl | 287 ++++++++++++++++++ internal/sessions/traces.go | 68 ++++- internal/sessions/traces_codex.go | 177 +++++++++++ internal/sessions/traces_codex_test.go | 204 +++++++++++++ 5 files changed, 741 insertions(+), 8 deletions(-) create mode 100644 internal/sessions/testdata/traces/codex-desktop-sanitized.jsonl create mode 100644 internal/sessions/traces_codex.go create mode 100644 internal/sessions/traces_codex_test.go diff --git a/internal/sessions/testdata/traces/README.md b/internal/sessions/testdata/traces/README.md index 3de9bffd7..6cd4b454c 100644 --- a/internal/sessions/testdata/traces/README.md +++ b/internal/sessions/testdata/traces/README.md @@ -17,3 +17,16 @@ removed. Remaining string values were checked against an explicit allowlist. These are sanitized real transcripts, not synthetic event sequences. Pi and Codex have been tested end to end. Claude Code/Cowork, Oh My Pi, OpenCode and Gemini CLI have format tests but are **not tested end to end** by the PR author. + +## codex-desktop-sanitized.jsonl + +Supplied by JuckZ with #2284, copied byte for byte. In their words: + +This fixture preserves event ordering, message/content types, timing, token +usage, and native/response-item echoes from two Windows Codex desktop turns +recorded on 2026-10-14. Session/message/call IDs are consistently renamed; +instructions, user text, replies, paths, arguments, diffs, URLs, and tool results +are replaced with fixture values. No credentials or private conversation text +are included. The 28 usage records contain eight distinct recorded assistant +messages, including model responses that emit only a tool call and multi-part +user inputs whose native UI echo contains fewer parts. diff --git a/internal/sessions/testdata/traces/codex-desktop-sanitized.jsonl b/internal/sessions/testdata/traces/codex-desktop-sanitized.jsonl new file mode 100644 index 000000000..a9d0dab75 --- /dev/null +++ b/internal/sessions/testdata/traces/codex-desktop-sanitized.jsonl @@ -0,0 +1,287 @@ +{"type":"session_meta","timestamp":"2026-10-14T13:01:00.402Z","payload":{"id":"codex-conversation-fixture","model_provider":"fixture-provider","base_instructions":{"text":"Fixture system instructions.","provenance":"[REDACTED]"}}} +{"timestamp":"2026-10-14T14:06:34.978Z","type":"event_msg","payload":{"type":"task_started","started_at":1791986794,"turn_id":"turn-1"}} +{"timestamp":"2026-10-14T14:06:35.014Z","type":"response_item","payload":{"type":"message","id":"id-0001","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"role":"developer","content":[{"type":"input_text","text":"Fixture developer message 1."}]}} +{"timestamp":"2026-10-14T14:06:35.030Z","type":"turn_context","payload":{"turn_id":"turn-1","model":"fixture-model"}} +{"timestamp":"2026-10-14T14:06:35.052Z","type":"response_item","payload":{"type":"message","id":"id-0002","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"role":"user","content":[{"type":"input_text","text":"Fixture user message 1."}]}} +{"timestamp":"2026-10-14T14:06:35.059Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986795059,"completed_at_ms":1791986795059,"turn_id":"turn-1","item":{"type":"UserMessage","id":"id-0003","content":[{"type":"text","text":"Fixture user message 1."}]}}} +{"timestamp":"2026-10-14T14:06:42.657Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986800932,"completed_at_ms":1791986802657,"turn_id":"turn-1","item":{"type":"AgentMessage","id":"id-0004","content":[{"type":"Text","text":"Fixture assistant message 1."}]}}} +{"timestamp":"2026-10-14T14:06:42.666Z","type":"response_item","payload":{"type":"message","id":"id-0004","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 1."}]}} +{"timestamp":"2026-10-14T14:06:53.963Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0005","call_id":"id-0006","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:06:54.169Z","type":"token_usage_record","payload":{"usage":{"input_tokens":238029,"cached_input_tokens":227456,"cache_write_input_tokens":0,"output_tokens":498,"reasoning_output_tokens":0,"total_tokens":238527},"turn_id":"turn-1","response_id":"id-0007"}} +{"timestamp":"2026-10-14T14:06:54.731Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986814156,"completed_at_ms":1791986814731,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0008","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0008"}}} +{"timestamp":"2026-10-14T14:06:54.784Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986814156,"completed_at_ms":1791986814784,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"failed","exit_code":1,"id":"id-0009","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0009"}}} +{"timestamp":"2026-10-14T14:06:54.796Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986814164,"completed_at_ms":1791986814796,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0010","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0010"}}} +{"timestamp":"2026-10-14T14:06:54.807Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0011","call_id":"id-0006","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0006"}} +{"timestamp":"2026-10-14T14:06:54.815Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:07:22.529Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986819051,"completed_at_ms":1791986842529,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0012"}}} +{"timestamp":"2026-10-14T14:07:22.555Z","type":"response_item","payload":{"type":"reasoning","id":"id-0012","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:07:47.378Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986842563,"completed_at_ms":1791986867378,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0013"}}} +{"timestamp":"2026-10-14T14:07:47.386Z","type":"response_item","payload":{"type":"reasoning","id":"id-0013","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:07:57.091Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0014","call_id":"id-0015","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:07:57.242Z","type":"token_usage_record","payload":{"usage":{"input_tokens":247805,"cached_input_tokens":237824,"cache_write_input_tokens":0,"output_tokens":1460,"reasoning_output_tokens":1034,"total_tokens":249265},"turn_id":"turn-1","response_id":"id-0016"}} +{"timestamp":"2026-10-14T14:07:57.937Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986877287,"completed_at_ms":1791986877937,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0017","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0017"}}} +{"timestamp":"2026-10-14T14:07:57.960Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986877272,"completed_at_ms":1791986877960,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0018","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0018"}}} +{"timestamp":"2026-10-14T14:07:57.979Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986877972,"completed_at_ms":1791986877979,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"start_session","server":"cua-driver","status":"completed","id":"id-0019","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0019"}]}}}} +{"timestamp":"2026-10-14T14:07:58.212Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986877992,"completed_at_ms":1791986878212,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"list_windows","server":"cua-driver","status":"completed","id":"id-0020","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0020"}]}}}} +{"timestamp":"2026-10-14T14:07:58.224Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0021","call_id":"id-0015","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0015"}} +{"timestamp":"2026-10-14T14:07:58.232Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:08:26.821Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986882039,"completed_at_ms":1791986906821,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0022"}}} +{"timestamp":"2026-10-14T14:08:26.831Z","type":"response_item","payload":{"type":"reasoning","id":"id-0022","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:08:33.372Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0023","call_id":"id-0024","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:08:33.479Z","type":"token_usage_record","payload":{"usage":{"input_tokens":254171,"cached_input_tokens":247680,"cache_write_input_tokens":0,"output_tokens":819,"reasoning_output_tokens":516,"total_tokens":254990},"turn_id":"turn-1","response_id":"id-0025"}} +{"timestamp":"2026-10-14T14:08:33.537Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986913402,"completed_at_ms":1791986913536,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"get_window_state","server":"cua-driver","status":"completed","id":"id-0026","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0026"}]}}}} +{"timestamp":"2026-10-14T14:08:34.848Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986913732,"completed_at_ms":1791986914848,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0027","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0027"}}} +{"timestamp":"2026-10-14T14:08:34.862Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0028","call_id":"id-0024","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0024"}} +{"timestamp":"2026-10-14T14:08:34.872Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:08:53.588Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986919802,"completed_at_ms":1791986933588,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0029"}}} +{"timestamp":"2026-10-14T14:08:53.599Z","type":"response_item","payload":{"type":"reasoning","id":"id-0029","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:09:00.811Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0030","call_id":"id-0031","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:09:00.841Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986940830,"completed_at_ms":1791986940841,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"click","server":"cua-driver","status":"completed","id":"id-0032","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0032"}]}}}} +{"timestamp":"2026-10-14T14:09:00.956Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986940855,"completed_at_ms":1791986940955,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"get_window_state","server":"cua-driver","status":"completed","id":"id-0033","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0033"}]}}}} +{"timestamp":"2026-10-14T14:09:01.011Z","type":"token_usage_record","payload":{"usage":{"input_tokens":259478,"cached_input_tokens":253952,"cache_write_input_tokens":0,"output_tokens":602,"reasoning_output_tokens":263,"total_tokens":260080},"turn_id":"turn-1","response_id":"id-0034"}} +{"timestamp":"2026-10-14T14:09:01.702Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986941136,"completed_at_ms":1791986941702,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0035","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0035"}}} +{"timestamp":"2026-10-14T14:09:01.713Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0036","call_id":"id-0031","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0031"}} +{"timestamp":"2026-10-14T14:09:01.721Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:09:18.294Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0037","call_id":"id-0038","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:09:18.462Z","type":"token_usage_record","payload":{"usage":{"input_tokens":260529,"cached_input_tokens":259328,"cache_write_input_tokens":0,"output_tokens":421,"reasoning_output_tokens":0,"total_tokens":260950},"turn_id":"turn-1","response_id":"id-0039"}} +{"timestamp":"2026-10-14T14:09:19.190Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986958312,"completed_at_ms":1791986959190,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"click","server":"cua-driver","status":"completed","id":"id-0040","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0040"}]}}}} +{"timestamp":"2026-10-14T14:09:19.333Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986959203,"completed_at_ms":1791986959332,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"get_window_state","server":"cua-driver","status":"completed","id":"id-0041","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0041"}]}}}} +{"timestamp":"2026-10-14T14:09:20.091Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986959511,"completed_at_ms":1791986960091,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0042","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0042"}}} +{"timestamp":"2026-10-14T14:09:20.103Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0043","call_id":"id-0038","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0038"}} +{"timestamp":"2026-10-14T14:09:20.111Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:09:48.665Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986965254,"completed_at_ms":1791986988665,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0044"}}} +{"timestamp":"2026-10-14T14:09:48.684Z","type":"response_item","payload":{"type":"reasoning","id":"id-0044","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:10:14.672Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791986988822,"completed_at_ms":1791987014672,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0045"}}} +{"timestamp":"2026-10-14T14:10:14.684Z","type":"response_item","payload":{"type":"reasoning","id":"id-0045","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:10:40.580Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987014827,"completed_at_ms":1791987040580,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0046"}}} +{"timestamp":"2026-10-14T14:10:40.588Z","type":"response_item","payload":{"type":"reasoning","id":"id-0046","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:10:42.333Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987040596,"completed_at_ms":1791987042333,"turn_id":"turn-1","item":{"type":"AgentMessage","id":"id-0047","content":[{"type":"Text","text":"Fixture assistant message 2."}]}}} +{"timestamp":"2026-10-14T14:10:42.341Z","type":"response_item","payload":{"type":"message","id":"id-0047","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 2."}]}} +{"timestamp":"2026-10-14T14:10:56.968Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0048","call_id":"id-0049","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:10:57.128Z","type":"token_usage_record","payload":{"usage":{"input_tokens":261581,"cached_input_tokens":260352,"cache_write_input_tokens":0,"output_tokens":2138,"reasoning_output_tokens":1552,"total_tokens":263719},"turn_id":"turn-1","response_id":"id-0050"}} +{"timestamp":"2026-10-14T14:10:57.708Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987057153,"completed_at_ms":1791987057708,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0051","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0051"}}} +{"timestamp":"2026-10-14T14:10:59.905Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987057892,"completed_at_ms":1791987059905,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0052","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0052"}}} +{"timestamp":"2026-10-14T14:11:01.383Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987060090,"completed_at_ms":1791987061383,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0053","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0053"}}} +{"timestamp":"2026-10-14T14:11:01.412Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0054","call_id":"id-0049","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0049"}} +{"timestamp":"2026-10-14T14:11:01.423Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:11:21.057Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:11:46.746Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987085595,"completed_at_ms":1791987106746,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0055"}}} +{"timestamp":"2026-10-14T14:11:46.755Z","type":"response_item","payload":{"type":"reasoning","id":"id-0055","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:12:11.373Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987106762,"completed_at_ms":1791987131373,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0056"}}} +{"timestamp":"2026-10-14T14:12:11.383Z","type":"response_item","payload":{"type":"reasoning","id":"id-0056","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:12:23.322Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0057","call_id":"id-0058","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:12:23.419Z","type":"token_usage_record","payload":{"usage":{"input_tokens":267310,"cached_input_tokens":267136,"cache_write_input_tokens":0,"output_tokens":1598,"reasoning_output_tokens":1034,"total_tokens":268908},"turn_id":"turn-1","response_id":"id-0059"}} +{"timestamp":"2026-10-14T14:12:25.939Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987143532,"completed_at_ms":1791987145939,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0060","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0060"}}} +{"timestamp":"2026-10-14T14:12:25.990Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987143513,"completed_at_ms":1791987145990,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0061","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0061"}}} +{"timestamp":"2026-10-14T14:12:26.002Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0062","call_id":"id-0058","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0058"}} +{"timestamp":"2026-10-14T14:12:26.009Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:12:57.736Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987153090,"completed_at_ms":1791987177736,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0063"}}} +{"timestamp":"2026-10-14T14:12:57.749Z","type":"response_item","payload":{"type":"reasoning","id":"id-0063","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:13:26.749Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987177756,"completed_at_ms":1791987206749,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0064"}}} +{"timestamp":"2026-10-14T14:13:26.758Z","type":"response_item","payload":{"type":"reasoning","id":"id-0064","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:13:52.172Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987207152,"completed_at_ms":1791987232172,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0065"}}} +{"timestamp":"2026-10-14T14:13:52.183Z","type":"response_item","payload":{"type":"reasoning","id":"id-0065","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:14:04.459Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0066","call_id":"id-0067","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:14:04.626Z","type":"token_usage_record","payload":{"usage":{"input_tokens":273856,"cached_input_tokens":267136,"cache_write_input_tokens":0,"output_tokens":2044,"reasoning_output_tokens":1493,"total_tokens":275900},"turn_id":"turn-1","response_id":"id-0068"}} +{"timestamp":"2026-10-14T14:14:05.267Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987244657,"completed_at_ms":1791987245267,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0069","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0069"}}} +{"timestamp":"2026-10-14T14:14:08.253Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987244657,"completed_at_ms":1791987248253,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0070","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0070"}}} +{"timestamp":"2026-10-14T14:14:08.277Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0071","call_id":"id-0067","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0067"}} +{"timestamp":"2026-10-14T14:14:08.287Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:14:29.387Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987254058,"completed_at_ms":1791987269387,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0072"}}} +{"timestamp":"2026-10-14T14:14:29.400Z","type":"response_item","payload":{"type":"reasoning","id":"id-0072","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:14:32.775Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0073","call_id":"id-0074","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:14:32.982Z","type":"token_usage_record","payload":{"usage":{"input_tokens":279090,"cached_input_tokens":273664,"cache_write_input_tokens":0,"output_tokens":451,"reasoning_output_tokens":290,"total_tokens":279541},"turn_id":"turn-1","response_id":"id-0075"}} +{"timestamp":"2026-10-14T14:14:33.694Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987272954,"completed_at_ms":1791987273694,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0076","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0076"}}} +{"timestamp":"2026-10-14T14:14:33.706Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0077","call_id":"id-0074","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0074"}} +{"timestamp":"2026-10-14T14:14:33.714Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:15:01.126Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987278654,"completed_at_ms":1791987301126,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0078"}}} +{"timestamp":"2026-10-14T14:15:01.141Z","type":"response_item","payload":{"type":"reasoning","id":"id-0078","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:15:29.046Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987301148,"completed_at_ms":1791987329046,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0079"}}} +{"timestamp":"2026-10-14T14:15:29.060Z","type":"response_item","payload":{"type":"reasoning","id":"id-0079","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:15:51.101Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987329067,"completed_at_ms":1791987351101,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0080"}}} +{"timestamp":"2026-10-14T14:15:51.113Z","type":"response_item","payload":{"type":"reasoning","id":"id-0080","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:16:19.600Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987351122,"completed_at_ms":1791987379600,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0081"}}} +{"timestamp":"2026-10-14T14:16:19.610Z","type":"response_item","payload":{"type":"reasoning","id":"id-0081","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:16:43.833Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987379682,"completed_at_ms":1791987403833,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0082"}}} +{"timestamp":"2026-10-14T14:16:43.841Z","type":"response_item","payload":{"type":"reasoning","id":"id-0082","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:17:00.218Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987403855,"completed_at_ms":1791987420218,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0083"}}} +{"timestamp":"2026-10-14T14:17:00.232Z","type":"response_item","payload":{"type":"reasoning","id":"id-0083","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:17:02.690Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987420240,"completed_at_ms":1791987422690,"turn_id":"turn-1","item":{"type":"AgentMessage","id":"id-0084","content":[{"type":"Text","text":"Fixture assistant message 3."}]}}} +{"timestamp":"2026-10-14T14:17:02.701Z","type":"response_item","payload":{"type":"message","id":"id-0084","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 3."}]}} +{"timestamp":"2026-10-14T14:17:11.465Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0085","call_id":"id-0086","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:17:11.651Z","type":"token_usage_record","payload":{"usage":{"input_tokens":284585,"cached_input_tokens":278912,"cache_write_input_tokens":0,"output_tokens":3508,"reasoning_output_tokens":2997,"total_tokens":288093},"turn_id":"turn-1","response_id":"id-0087"}} +{"timestamp":"2026-10-14T14:17:12.242Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987431646,"completed_at_ms":1791987432242,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0088","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0088"}}} +{"timestamp":"2026-10-14T14:17:13.434Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987431485,"completed_at_ms":1791987433433,"turn_id":"turn-1","item":{"type":"Extension","id":"id-0089","kind":"web","query":"Fixture search.","action":{"type":"open","url":"https://example.test"},"results":[{"type":"text","text":"Fixture extension result."}]}}} +{"timestamp":"2026-10-14T14:17:13.466Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0090","call_id":"id-0086","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0086"}} +{"timestamp":"2026-10-14T14:17:13.478Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:17:41.747Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987439189,"completed_at_ms":1791987461747,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0091"}}} +{"timestamp":"2026-10-14T14:17:41.757Z","type":"response_item","payload":{"type":"reasoning","id":"id-0091","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:18:08.320Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987461765,"completed_at_ms":1791987488320,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0092"}}} +{"timestamp":"2026-10-14T14:18:08.333Z","type":"response_item","payload":{"type":"reasoning","id":"id-0092","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:18:18.838Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0093","call_id":"id-0094","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:18:18.970Z","type":"token_usage_record","payload":{"usage":{"input_tokens":292494,"cached_input_tokens":284416,"cache_write_input_tokens":0,"output_tokens":1537,"reasoning_output_tokens":1034,"total_tokens":294031},"turn_id":"turn-1","response_id":"id-0095"}} +{"timestamp":"2026-10-14T14:18:22.039Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987499056,"completed_at_ms":1791987502039,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0096","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0096"}}} +{"timestamp":"2026-10-14T14:18:22.052Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0097","call_id":"id-0094","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0094"}} +{"timestamp":"2026-10-14T14:18:22.063Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:18:51.810Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987506438,"completed_at_ms":1791987531810,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0098"}}} +{"timestamp":"2026-10-14T14:18:51.820Z","type":"response_item","payload":{"type":"reasoning","id":"id-0098","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:19:20.700Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987531827,"completed_at_ms":1791987560700,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0099"}}} +{"timestamp":"2026-10-14T14:19:20.711Z","type":"response_item","payload":{"type":"reasoning","id":"id-0099","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:19:43.950Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987560720,"completed_at_ms":1791987583950,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0100"}}} +{"timestamp":"2026-10-14T14:19:43.959Z","type":"response_item","payload":{"type":"reasoning","id":"id-0100","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:20:09.266Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987584007,"completed_at_ms":1791987609266,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0101"}}} +{"timestamp":"2026-10-14T14:20:09.275Z","type":"response_item","payload":{"type":"reasoning","id":"id-0101","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:20:14.225Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0102","call_id":"id-0103","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:20:14.339Z","type":"token_usage_record","payload":{"usage":{"input_tokens":296548,"cached_input_tokens":292352,"cache_write_input_tokens":0,"output_tokens":2335,"reasoning_output_tokens":2070,"total_tokens":298883},"turn_id":"turn-1","response_id":"id-0104"}} +{"timestamp":"2026-10-14T14:20:14.960Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987614404,"completed_at_ms":1791987614960,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0105","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0105"}}} +{"timestamp":"2026-10-14T14:20:17.462Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987615139,"completed_at_ms":1791987617462,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0106","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0106"}}} +{"timestamp":"2026-10-14T14:20:17.483Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0107","call_id":"id-0103","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0103"}} +{"timestamp":"2026-10-14T14:20:17.496Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:20:46.913Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987623522,"completed_at_ms":1791987646913,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0108"}}} +{"timestamp":"2026-10-14T14:20:46.924Z","type":"response_item","payload":{"type":"reasoning","id":"id-0108","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:21:14.085Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987646932,"completed_at_ms":1791987674085,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0109"}}} +{"timestamp":"2026-10-14T14:21:14.095Z","type":"response_item","payload":{"type":"reasoning","id":"id-0109","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:21:42.310Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987674105,"completed_at_ms":1791987702310,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0110"}}} +{"timestamp":"2026-10-14T14:21:42.321Z","type":"response_item","payload":{"type":"reasoning","id":"id-0110","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:21:44.409Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987702329,"completed_at_ms":1791987704409,"turn_id":"turn-1","item":{"type":"AgentMessage","id":"id-0111","content":[{"type":"Text","text":"Fixture assistant message 4."}]}}} +{"timestamp":"2026-10-14T14:21:44.432Z","type":"response_item","payload":{"type":"message","id":"id-0111","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 4."}]}} +{"timestamp":"2026-10-14T14:21:55.900Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0112","call_id":"id-0113","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:21:56.023Z","type":"token_usage_record","payload":{"usage":{"input_tokens":301221,"cached_input_tokens":296320,"cache_write_input_tokens":0,"output_tokens":2173,"reasoning_output_tokens":1544,"total_tokens":303394},"turn_id":"turn-1","response_id":"id-0114"}} +{"timestamp":"2026-10-14T14:21:57.516Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987716094,"completed_at_ms":1791987717516,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"failed","exit_code":1,"id":"id-0115","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0115"}}} +{"timestamp":"2026-10-14T14:21:57.526Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0116","call_id":"id-0113","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0113"}} +{"timestamp":"2026-10-14T14:21:57.534Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:22:24.798Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987721480,"completed_at_ms":1791987744798,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0117"}}} +{"timestamp":"2026-10-14T14:22:24.810Z","type":"response_item","payload":{"type":"reasoning","id":"id-0117","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:22:54.795Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987744820,"completed_at_ms":1791987774795,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0118"}}} +{"timestamp":"2026-10-14T14:22:54.804Z","type":"response_item","payload":{"type":"reasoning","id":"id-0118","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:23:18.824Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987774810,"completed_at_ms":1791987798823,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0119"}}} +{"timestamp":"2026-10-14T14:23:18.832Z","type":"response_item","payload":{"type":"reasoning","id":"id-0119","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:23:23.385Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0120","call_id":"id-0121","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:23:23.484Z","type":"token_usage_record","payload":{"usage":{"input_tokens":303762,"cached_input_tokens":301056,"cache_write_input_tokens":0,"output_tokens":1795,"reasoning_output_tokens":1552,"total_tokens":305557},"turn_id":"turn-1","response_id":"id-0122"}} +{"timestamp":"2026-10-14T14:23:24.175Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987803568,"completed_at_ms":1791987804175,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0123","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0123"}}} +{"timestamp":"2026-10-14T14:23:25.048Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987804359,"completed_at_ms":1791987805048,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0124","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0124"}}} +{"timestamp":"2026-10-14T14:23:25.062Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0125","call_id":"id-0121","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0121"}} +{"timestamp":"2026-10-14T14:23:25.073Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:23:54.912Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987811289,"completed_at_ms":1791987834912,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0126"}}} +{"timestamp":"2026-10-14T14:23:54.922Z","type":"response_item","payload":{"type":"reasoning","id":"id-0126","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:24:24.281Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987835059,"completed_at_ms":1791987864281,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0127"}}} +{"timestamp":"2026-10-14T14:24:24.290Z","type":"response_item","payload":{"type":"reasoning","id":"id-0127","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:24:28.368Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0128","call_id":"id-0129","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:24:28.533Z","type":"token_usage_record","payload":{"usage":{"input_tokens":308490,"cached_input_tokens":303616,"cache_write_input_tokens":0,"output_tokens":1250,"reasoning_output_tokens":1034,"total_tokens":309740},"turn_id":"turn-1","response_id":"id-0130"}} +{"timestamp":"2026-10-14T14:24:30.259Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987868561,"completed_at_ms":1791987870258,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0131","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0131"}}} +{"timestamp":"2026-10-14T14:24:30.271Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0132","call_id":"id-0129","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0129"}} +{"timestamp":"2026-10-14T14:24:30.279Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:25:01.016Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987874791,"completed_at_ms":1791987901016,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0133"}}} +{"timestamp":"2026-10-14T14:25:01.041Z","type":"response_item","payload":{"type":"reasoning","id":"id-0133","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:25:05.013Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0134","call_id":"id-0135","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:25:05.202Z","type":"token_usage_record","payload":{"usage":{"input_tokens":311270,"cached_input_tokens":308352,"cache_write_input_tokens":0,"output_tokens":735,"reasoning_output_tokens":516,"total_tokens":312005},"turn_id":"turn-1","response_id":"id-0136"}} +{"timestamp":"2026-10-14T14:25:06.228Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987905195,"completed_at_ms":1791987906228,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"failed","exit_code":1,"id":"id-0137","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0137"}}} +{"timestamp":"2026-10-14T14:25:06.254Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987906254,"completed_at_ms":1791987906254,"turn_id":"turn-1","item":{"type":"ImageView","id":"id-0138","path":"/workspace/fixture.png"}}} +{"timestamp":"2026-10-14T14:25:06.364Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0139","call_id":"id-0135","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0135"}} +{"timestamp":"2026-10-14T14:25:06.372Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:25:37.403Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987910679,"completed_at_ms":1791987937403,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0140"}}} +{"timestamp":"2026-10-14T14:25:37.415Z","type":"response_item","payload":{"type":"reasoning","id":"id-0140","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:26:01.399Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987937423,"completed_at_ms":1791987961399,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0141"}}} +{"timestamp":"2026-10-14T14:26:01.409Z","type":"response_item","payload":{"type":"reasoning","id":"id-0141","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:26:27.776Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987962031,"completed_at_ms":1791987987776,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0142"}}} +{"timestamp":"2026-10-14T14:26:27.785Z","type":"response_item","payload":{"type":"reasoning","id":"id-0142","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:26:49.486Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791987987796,"completed_at_ms":1791988009486,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0143"}}} +{"timestamp":"2026-10-14T14:26:49.498Z","type":"response_item","payload":{"type":"reasoning","id":"id-0143","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:27:13.173Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988009596,"completed_at_ms":1791988033173,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0144"}}} +{"timestamp":"2026-10-14T14:27:13.183Z","type":"response_item","payload":{"type":"reasoning","id":"id-0144","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:27:40.814Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0145","call_id":"id-0146","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:27:40.835Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988060834,"completed_at_ms":1791988060835,"turn_id":"turn-1","item":{"type":"FileChange","status":"completed","id":"id-0147","changes":{"fixture.txt":{"type":"update","content":"Fixture file diff."}},"stdout":"Fixture file changed.","stderr":""}}} +{"timestamp":"2026-10-14T14:27:40.956Z","type":"token_usage_record","payload":{"usage":{"input_tokens":313870,"cached_input_tokens":311168,"cache_write_input_tokens":0,"output_tokens":3843,"reasoning_output_tokens":2588,"total_tokens":317713},"turn_id":"turn-1","response_id":"id-0148"}} +{"timestamp":"2026-10-14T14:27:43.305Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988061022,"completed_at_ms":1791988063304,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0149","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0149"}}} +{"timestamp":"2026-10-14T14:27:43.317Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0150","call_id":"id-0146","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0146"}} +{"timestamp":"2026-10-14T14:27:43.326Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:28:09.944Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988067933,"completed_at_ms":1791988089944,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0151"}}} +{"timestamp":"2026-10-14T14:28:09.962Z","type":"response_item","payload":{"type":"reasoning","id":"id-0151","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:28:29.949Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988090019,"completed_at_ms":1791988109949,"turn_id":"turn-1","item":{"type":"Reasoning","id":"id-0152"}}} +{"timestamp":"2026-10-14T14:28:29.958Z","type":"response_item","payload":{"type":"reasoning","id":"id-0152","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"}}} +{"timestamp":"2026-10-14T14:28:31.154Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0153","call_id":"id-0154","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:28:31.284Z","type":"token_usage_record","payload":{"usage":{"input_tokens":318011,"cached_input_tokens":313472,"cache_write_input_tokens":0,"output_tokens":1105,"reasoning_output_tokens":1034,"total_tokens":319116},"turn_id":"turn-1","response_id":"id-0155"}} +{"timestamp":"2026-10-14T14:28:32.107Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988111343,"completed_at_ms":1791988112107,"turn_id":"turn-1","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0156","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0156"}}} +{"timestamp":"2026-10-14T14:28:32.131Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988112124,"completed_at_ms":1791988112131,"turn_id":"turn-1","item":{"type":"McpToolCall","tool":"end_session","server":"cua-driver","status":"completed","id":"id-0157","arguments":{"path":"fixture.txt"},"result":{"content":[{"type":"text","text":"Fixture MCP result id-0157"}]}}}} +{"timestamp":"2026-10-14T14:28:32.146Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0158","call_id":"id-0154","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"output":"Fixture tool result id-0154"}} +{"timestamp":"2026-10-14T14:28:32.157Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:28:43.695Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988118148,"completed_at_ms":1791988123695,"turn_id":"turn-1","item":{"type":"AgentMessage","id":"id-0159","content":[{"type":"Text","text":"Fixture assistant message 5."}]}}} +{"timestamp":"2026-10-14T14:28:43.711Z","type":"response_item","payload":{"type":"message","id":"id-0159","internal_chat_message_metadata_passthrough":{"turn_id":"turn-1"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 5."}]}} +{"timestamp":"2026-10-14T14:28:43.925Z","type":"token_usage_record","payload":{"usage":{"input_tokens":319235,"cached_input_tokens":317952,"cache_write_input_tokens":0,"output_tokens":235,"reasoning_output_tokens":0,"total_tokens":319470},"turn_id":"turn-1","response_id":"id-0160"}} +{"timestamp":"2026-10-14T14:28:43.938Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:28:43.987Z","type":"event_msg","payload":{"type":"task_complete","started_at":1791986794,"completed_at":1791988123,"duration_ms":1329009,"turn_id":"turn-1","last_agent_message":"Fixture assistant message 5."}} +{"timestamp":"2026-10-14T14:30:37.407Z","type":"event_msg","payload":{"type":"thread_settings_applied"}} +{"timestamp":"2026-10-14T14:30:37.423Z","type":"event_msg","payload":{"type":"task_started","started_at":1791988237,"turn_id":"turn-2"}} +{"timestamp":"2026-10-14T14:30:37.455Z","type":"response_item","payload":{"type":"message","id":"id-0161","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"role":"developer","content":[{"type":"input_text","text":"Fixture developer message 2."}]}} +{"timestamp":"2026-10-14T14:30:37.472Z","type":"turn_context","payload":{"turn_id":"turn-2","model":"fixture-model"}} +{"timestamp":"2026-10-14T14:30:37.583Z","type":"response_item","payload":{"type":"message","id":"id-0162","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"role":"user","content":[{"type":"input_text","text":"Fixture user message 2."},{"type":"input_text","text":"Fixture user message 3."},{"type":"input_text","text":"Fixture user message 4."}]}} +{"timestamp":"2026-10-14T14:30:37.592Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988237592,"completed_at_ms":1791988237592,"turn_id":"turn-2","item":{"type":"UserMessage","id":"id-0163","content":[{"type":"text","text":"Fixture user message 2."}]}}} +{"timestamp":"2026-10-14T14:31:06.261Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988245094,"completed_at_ms":1791988266261,"turn_id":"turn-2","item":{"type":"Reasoning","id":"id-0164"}}} +{"timestamp":"2026-10-14T14:31:06.270Z","type":"response_item","payload":{"type":"reasoning","id":"id-0164","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"}}} +{"timestamp":"2026-10-14T14:31:08.768Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988266278,"completed_at_ms":1791988268768,"turn_id":"turn-2","item":{"type":"AgentMessage","id":"id-0165","content":[{"type":"Text","text":"Fixture assistant message 6."}]}}} +{"timestamp":"2026-10-14T14:31:08.776Z","type":"response_item","payload":{"type":"message","id":"id-0165","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 6."}]}} +{"timestamp":"2026-10-14T14:31:28.438Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0166","call_id":"id-0167","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:31:28.686Z","type":"token_usage_record","payload":{"usage":{"input_tokens":329530,"cached_input_tokens":319104,"cache_write_input_tokens":0,"output_tokens":1495,"reasoning_output_tokens":516,"total_tokens":331025},"turn_id":"turn-2","response_id":"id-0168"}} +{"timestamp":"2026-10-14T14:31:29.294Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988288625,"completed_at_ms":1791988289294,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0169","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0169"}}} +{"timestamp":"2026-10-14T14:31:29.369Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988288651,"completed_at_ms":1791988289369,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0170","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0170"}}} +{"timestamp":"2026-10-14T14:31:29.976Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988288639,"completed_at_ms":1791988289976,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0171","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0171"}}} +{"timestamp":"2026-10-14T14:31:30.761Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988288494,"completed_at_ms":1791988290761,"turn_id":"turn-2","item":{"type":"Extension","id":"id-0172","kind":"web","query":"Fixture search.","action":{"type":"open","url":"https://example.test"},"results":[{"type":"text","text":"Fixture extension result."}]}}} +{"timestamp":"2026-10-14T14:31:30.777Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0173","call_id":"id-0167","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"output":"Fixture tool result id-0167"}} +{"timestamp":"2026-10-14T14:31:30.787Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:35:04.747Z","type":"token_usage_record","payload":{"usage":{"input_tokens":345491,"cached_input_tokens":329088,"cache_write_input_tokens":0,"output_tokens":6944,"reasoning_output_tokens":0,"total_tokens":352435},"turn_id":"turn-2","response_id":"id-0174"}} +{"timestamp":"2026-10-14T14:35:04.769Z","type":"turn_context","payload":{"turn_id":"turn-2","model":"fixture-model"}} +{"timestamp":"2026-10-14T14:35:04.769Z","type":"event_msg","payload":{"type":"thread_settings_applied"}} +{"timestamp":"2026-10-14T14:35:04.784Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:35:04.795Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988290801,"completed_at_ms":1791988504795,"turn_id":"turn-2","item":{"type":"ContextCompaction","id":"id-0175"}}} +{"timestamp":"2026-10-14T14:35:18.969Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0176","call_id":"id-0177","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:35:19.118Z","type":"token_usage_record","payload":{"usage":{"input_tokens":44353,"cached_input_tokens":24320,"cache_write_input_tokens":0,"output_tokens":417,"reasoning_output_tokens":0,"total_tokens":44770},"turn_id":"turn-2","response_id":"id-0178"}} +{"timestamp":"2026-10-14T14:35:21.871Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988519161,"completed_at_ms":1791988521871,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0179","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0179"}}} +{"timestamp":"2026-10-14T14:35:24.434Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988521883,"completed_at_ms":1791988524434,"turn_id":"turn-2","item":{"type":"Extension","id":"id-0180","kind":"web","query":"Fixture search.","action":{"type":"open","url":"https://example.test"},"results":[{"type":"text","text":"Fixture extension result."}]}}} +{"timestamp":"2026-10-14T14:35:24.447Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0181","call_id":"id-0177","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"output":"Fixture tool result id-0177"}} +{"timestamp":"2026-10-14T14:35:24.454Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:35:34.679Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988528050,"completed_at_ms":1791988534679,"turn_id":"turn-2","item":{"type":"Reasoning","id":"id-0182"}}} +{"timestamp":"2026-10-14T14:35:34.688Z","type":"response_item","payload":{"type":"reasoning","id":"id-0182","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"}}} +{"timestamp":"2026-10-14T14:35:48.220Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0183","call_id":"id-0184","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:35:48.570Z","type":"token_usage_record","payload":{"usage":{"input_tokens":51385,"cached_input_tokens":44160,"cache_write_input_tokens":0,"output_tokens":777,"reasoning_output_tokens":181,"total_tokens":52162},"turn_id":"turn-2","response_id":"id-0185"}} +{"timestamp":"2026-10-14T14:35:49.008Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988548421,"completed_at_ms":1791988549008,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"failed","exit_code":1,"id":"id-0186","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0186"}}} +{"timestamp":"2026-10-14T14:35:50.376Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988548405,"completed_at_ms":1791988550376,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0187","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0187"}}} +{"timestamp":"2026-10-14T14:35:50.403Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0188","call_id":"id-0184","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"output":"Fixture tool result id-0184"}} +{"timestamp":"2026-10-14T14:35:50.411Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:36:00.158Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988554162,"completed_at_ms":1791988560158,"turn_id":"turn-2","item":{"type":"Reasoning","id":"id-0189"}}} +{"timestamp":"2026-10-14T14:36:00.167Z","type":"response_item","payload":{"type":"reasoning","id":"id-0189","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"}}} +{"timestamp":"2026-10-14T14:36:08.382Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0190","call_id":"id-0191","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:36:08.511Z","type":"token_usage_record","payload":{"usage":{"input_tokens":52964,"cached_input_tokens":51200,"cache_write_input_tokens":0,"output_tokens":522,"reasoning_output_tokens":140,"total_tokens":53486},"turn_id":"turn-2","response_id":"id-0192"}} +{"timestamp":"2026-10-14T14:36:11.282Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988568563,"completed_at_ms":1791988571282,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0193","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0193"}}} +{"timestamp":"2026-10-14T14:36:11.294Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0194","call_id":"id-0191","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"output":"Fixture tool result id-0191"}} +{"timestamp":"2026-10-14T14:36:11.302Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:36:28.827Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988575679,"completed_at_ms":1791988588827,"turn_id":"turn-2","item":{"type":"Reasoning","id":"id-0195"}}} +{"timestamp":"2026-10-14T14:36:28.837Z","type":"response_item","payload":{"type":"reasoning","id":"id-0195","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"}}} +{"timestamp":"2026-10-14T14:36:31.511Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988588844,"completed_at_ms":1791988591511,"turn_id":"turn-2","item":{"type":"AgentMessage","id":"id-0196","content":[{"type":"Text","text":"Fixture assistant message 7."}]}}} +{"timestamp":"2026-10-14T14:36:31.520Z","type":"response_item","payload":{"type":"message","id":"id-0196","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 7."}]}} +{"timestamp":"2026-10-14T14:36:35.970Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0197","call_id":"id-0198","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:36:36.054Z","type":"token_usage_record","payload":{"usage":{"input_tokens":55131,"cached_input_tokens":52736,"cache_write_input_tokens":0,"output_tokens":661,"reasoning_output_tokens":361,"total_tokens":55792},"turn_id":"turn-2","response_id":"id-0199"}} +{"timestamp":"2026-10-14T14:36:36.701Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988596153,"completed_at_ms":1791988596701,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0200","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0200"}}} +{"timestamp":"2026-10-14T14:36:40.185Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988596004,"completed_at_ms":1791988600185,"turn_id":"turn-2","item":{"type":"Extension","id":"id-0201","kind":"web","query":"Fixture search.","action":{"type":"open","url":"https://example.test"},"results":[{"type":"text","text":"Fixture extension result."}]}}} +{"timestamp":"2026-10-14T14:36:40.198Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0202","call_id":"id-0198","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"output":"Fixture tool result id-0198"}} +{"timestamp":"2026-10-14T14:36:40.206Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:37:06.364Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988603932,"completed_at_ms":1791988626364,"turn_id":"turn-2","item":{"type":"Reasoning","id":"id-0203"}}} +{"timestamp":"2026-10-14T14:37:06.373Z","type":"response_item","payload":{"type":"reasoning","id":"id-0203","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"}}} +{"timestamp":"2026-10-14T14:37:13.807Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0204","call_id":"id-0205","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:37:13.944Z","type":"token_usage_record","payload":{"usage":{"input_tokens":62064,"cached_input_tokens":54912,"cache_write_input_tokens":0,"output_tokens":855,"reasoning_output_tokens":516,"total_tokens":62919},"turn_id":"turn-2","response_id":"id-0206"}} +{"timestamp":"2026-10-14T14:37:16.146Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988633993,"completed_at_ms":1791988636146,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0207","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0207"}}} +{"timestamp":"2026-10-14T14:37:16.162Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0208","call_id":"id-0205","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"output":"Fixture tool result id-0205"}} +{"timestamp":"2026-10-14T14:37:16.170Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:37:24.174Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988640511,"completed_at_ms":1791988644174,"turn_id":"turn-2","item":{"type":"Reasoning","id":"id-0209"}}} +{"timestamp":"2026-10-14T14:37:24.183Z","type":"response_item","payload":{"type":"reasoning","id":"id-0209","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"}}} +{"timestamp":"2026-10-14T14:37:27.336Z","type":"response_item","payload":{"type":"custom_tool_call","id":"id-0210","call_id":"id-0211","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"name":"exec","input":"Write-Output 'fixture'"}} +{"timestamp":"2026-10-14T14:37:27.850Z","type":"token_usage_record","payload":{"usage":{"input_tokens":64434,"cached_input_tokens":61824,"cache_write_input_tokens":0,"output_tokens":235,"reasoning_output_tokens":79,"total_tokens":64669},"turn_id":"turn-2","response_id":"id-0212"}} +{"timestamp":"2026-10-14T14:37:28.058Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988647528,"completed_at_ms":1791988648058,"turn_id":"turn-2","item":{"type":"CommandExecution","status":"completed","exit_code":0,"id":"id-0213","command":["powershell","Write-Output fixture"],"aggregated_output":"Fixture command result id-0213"}}} +{"timestamp":"2026-10-14T14:37:28.071Z","type":"response_item","payload":{"type":"custom_tool_call_output","id":"id-0214","call_id":"id-0211","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"output":"Fixture tool result id-0211"}} +{"timestamp":"2026-10-14T14:37:28.079Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:37:53.403Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988651940,"completed_at_ms":1791988673403,"turn_id":"turn-2","item":{"type":"Reasoning","id":"id-0215"}}} +{"timestamp":"2026-10-14T14:37:53.412Z","type":"response_item","payload":{"type":"reasoning","id":"id-0215","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"}}} +{"timestamp":"2026-10-14T14:38:06.204Z","type":"event_msg","payload":{"type":"item_completed","started_at_ms":1791988673420,"completed_at_ms":1791988686204,"turn_id":"turn-2","item":{"type":"AgentMessage","id":"id-0216","content":[{"type":"Text","text":"Fixture assistant message 8."}]}}} +{"timestamp":"2026-10-14T14:38:06.215Z","type":"response_item","payload":{"type":"message","id":"id-0216","internal_chat_message_metadata_passthrough":{"turn_id":"turn-2"},"role":"assistant","content":[{"type":"output_text","text":"Fixture assistant message 8."}]}} +{"timestamp":"2026-10-14T14:38:06.250Z","type":"token_usage_record","payload":{"usage":{"input_tokens":68251,"cached_input_tokens":64256,"cache_write_input_tokens":0,"output_tokens":977,"reasoning_output_tokens":516,"total_tokens":69228},"turn_id":"turn-2","response_id":"id-0217"}} +{"timestamp":"2026-10-14T14:38:06.261Z","type":"event_msg","payload":{"type":"token_count"}} +{"timestamp":"2026-10-14T14:38:06.284Z","type":"event_msg","payload":{"type":"task_complete","started_at":1791988237,"completed_at":1791988686,"duration_ms":448860,"turn_id":"turn-2","last_agent_message":"Fixture assistant message 8."}} diff --git a/internal/sessions/traces.go b/internal/sessions/traces.go index 92fdae921..64777fa9a 100644 --- a/internal/sessions/traces.go +++ b/internal/sessions/traces.go @@ -33,6 +33,7 @@ type traceTurn struct { input, output, model string failed, completed bool finishAfter time.Time + codex codexTranscript } // Allow a timing extension to append its final event across reader polls. @@ -51,6 +52,7 @@ type traceCursor struct { tools map[string]TraceSpan parents map[string]string claudeMessage *claudeTraceMessage + codexBase string // Codex base instructions, kept only with bodies } // TraceReader follows supported local agent stores modified since activation. @@ -311,9 +313,18 @@ func (c *traceCursor) interruptCodexTurn(next string, at time.Time) []TraceSpan } } delete(c.turns, t.id) + c.endCodexTurn(t.id) return spans } +// A finished turn stops being current, so a later event without a turn ID +// can't open it again and export it a second time as interrupted. +func (c *traceCursor) endCodexTurn(id string) { + if c.current == id { + c.current = "" + } +} + func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { var o struct { Type string @@ -324,9 +335,14 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { return nil } var p struct { - Type, ID, Model string - Name string - CallID string `json:"call_id"` + Type, ID, Model, Role string + Name string + Content json.RawMessage + Metadata struct { + TurnID string `json:"turn_id"` + } `json:"internal_chat_message_metadata_passthrough"` + BaseInstructions json.RawMessage `json:"base_instructions"` + CallID string `json:"call_id"` Input, Arguments, Output json.RawMessage TurnID string `json:"turn_id"` ResponseID string `json:"response_id"` @@ -346,11 +362,16 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { } Item struct { Type, ID, Tool, Server, Status string + Kind, Path, SavedPath string Command json.RawMessage Arguments json.RawMessage Content json.RawMessage Output json.RawMessage Result json.RawMessage + Changes, Query, Action json.RawMessage + Results, Failure json.RawMessage + RevisedPrompt string `json:"revisedPrompt"` + Stdout, Stderr string AggregatedOutput string `json:"aggregated_output"` ExitCode *int `json:"exit_code"` } @@ -364,6 +385,14 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { if o.Type == "session_meta" { c.session = p.ID c.provider = p.ModelProvider + c.codexBase = "" + if bodies { + var base struct{ Text string } + if json.Unmarshal(p.BaseInstructions, &base) != nil { + json.Unmarshal(p.BaseInstructions, &base.Text) + } + c.codexBase = base.Text + } return nil } if o.Type == "turn_context" { @@ -377,6 +406,9 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { return interrupted } id := p.TurnID + if id == "" { + id = p.Metadata.TurnID + } if id == "" { id = c.current } @@ -387,6 +419,10 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { switch { case o.Type == "response_item": switch p.Type { + case "message": + if bodies && (p.Role == "user" || p.Role == "developer" || p.Role == "system" || p.Role == "assistant") { + t.codex.message(p.Role, p.Content) + } case "custom_tool_call", "function_call": if p.CallID == "" || len(c.tools) >= 256 { return nil @@ -398,9 +434,17 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { if s.Input == "" { s.Input = string(p.Input) } + arguments := p.Arguments + if len(arguments) == 0 { + arguments = p.Input + } + t.codex.call(p.CallID, p.Name, arguments) } c.tools[p.CallID] = s case "custom_tool_call_output", "function_call_output": + if bodies && p.CallID != "" { + t.codex.result(p.CallID, p.Output) + } s, ok := c.tools[p.CallID] if !ok { return nil @@ -444,15 +488,17 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { t.output = string(p.Item.Content) } return nil - case "CommandExecution", "McpToolCall", "FileChange", "ImageView", "ContextCompaction": + case "CommandExecution", "McpToolCall", "FileChange", "ImageView", "ContextCompaction", "Extension": // A recorded MCP completion is authoritative over the matching // inferred function_call/output pair, which uses the same call ID. if p.Item.Type == "McpToolCall" { delete(c.tools, p.Item.ID) } - name := map[string]string{"CommandExecution": "command", "McpToolCall": "mcp tool", "FileChange": "file change", "ImageView": "view image", "ContextCompaction": "compaction"}[p.Item.Type] + name := map[string]string{"CommandExecution": "command", "McpToolCall": "mcp tool", "FileChange": "file change", "ImageView": "view image", "ContextCompaction": "compaction", "Extension": "extension"}[p.Item.Type] if p.Item.Tool != "" { name = p.Item.Tool + } else if p.Item.Kind != "" { + name = p.Item.Kind } s := c.span(id, p.Item.ID, name, "tool", start, end) s.Error = p.Item.Status == "failed" || p.Item.Status == "error" || p.Item.ExitCode != nil && *p.Item.ExitCode != 0 @@ -465,9 +511,10 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { if s.Output == "" { s.Output = string(p.Item.Output) } - if s.Output == "" { + if s.Output == "" && p.Item.Type != "Extension" { s.Output = string(p.Item.Result) } + codexNativeBodies(&s, p.Item.Type, p.Item.Path, p.Item.Changes, p.Item.Stdout, p.Item.Stderr, p.Item.Query, p.Item.Action, p.Item.RevisedPrompt, p.Item.Results, p.Item.SavedPath, p.Item.Failure) } // exec may run commands which also have recorded completion events. // Keep those operations beneath the enclosing exec, rather than @@ -506,8 +553,12 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { s.Tokens = Tokens{Input: max(0, p.Usage.Input-p.Usage.Cached-p.Usage.CacheWrite), CacheRead: p.Usage.Cached, CacheWrite: p.Usage.CacheWrite, Output: p.Usage.Output} s.Reasoning = p.Usage.Reasoning if bodies { - s.Output = t.output - s.Input = t.input + // Only what this response produced; t.output is the turn's last + // reply, which a later tool-call-only response didn't write. + var ok bool + if s.Input, s.Output, ok = t.codex.response(c.codexBase); !ok { + s.Input = t.input + } } t.last = o.Timestamp return []TraceSpan{s} @@ -524,6 +575,7 @@ func (c *traceCursor) codex(line []byte, bodies bool) []TraceSpan { } s := c.root(t, end, p.Type == "turn_aborted") delete(c.turns, id) + c.endCodexTurn(id) var unfinished []TraceSpan for key, call := range c.tools { if call.Turn == id { diff --git a/internal/sessions/traces_codex.go b/internal/sessions/traces_codex.go new file mode 100644 index 000000000..d359b6eb4 --- /dev/null +++ b/internal/sessions/traces_codex.go @@ -0,0 +1,177 @@ +package sessions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// A Codex model response's bodies come from the rollout's response items, the +// record of what the model was sent and what it returned. Each usage record +// closes one response: its input is the turn's prompt (base instructions, +// developer and user messages) and what came back since the previous +// response (tool results); its output is only what that response produced +// (assistant text and tool calls, with their call IDs). The UI's +// item_completed echoes of the same messages are not part of it. +type codexTranscript struct { + prompt, fed, out []json.RawMessage +} + +type codexChatMessage struct { + Role string `json:"role"` + Content json.RawMessage `json:"content,omitempty"` + ToolCalls []codexChatCall `json:"tool_calls,omitempty"` + ToolCallID string `json:"tool_call_id,omitempty"` +} + +type codexChatCall struct { + ID string `json:"id"` + Type string `json:"type"` + Function struct { + Name string `json:"name"` + Arguments string `json:"arguments"` + } `json:"function"` +} + +func codexChat(m codexChatMessage) json.RawMessage { + b, _ := json.Marshal(m) + return b +} + +// codexTraceContent turns Codex's input_text/output_text parts into text parts. An +// inline image (a screenshot is megabytes) is named, not copied, since the +// prompt goes out again with every response of the turn. +func codexTraceContent(raw json.RawMessage) json.RawMessage { + var text string + if json.Unmarshal(raw, &text) == nil { + b, _ := json.Marshal(text) + return b + } + var parts []json.RawMessage + if json.Unmarshal(raw, &parts) != nil { + return raw + } + for i, part := range parts { + var p struct { + Type string + Text string + ImageURL string `json:"image_url"` + } + if json.Unmarshal(part, &p) != nil { + continue + } + switch p.Type { + case "input_text", "output_text", "text": + parts[i], _ = json.Marshal(map[string]string{"type": "text", "text": p.Text}) + case "input_image": + if media, data, ok := strings.Cut(p.ImageURL, ","); ok && strings.HasPrefix(media, "data:") { + label := fmt.Sprintf("[image %s, %d bytes not exported]", strings.TrimSuffix(strings.TrimPrefix(media, "data:"), ";base64"), len(data)) + parts[i], _ = json.Marshal(map[string]string{"type": "text", "text": label}) + } + } + } + b, _ := json.Marshal(parts) + return b +} + +// codexArguments gives a call's arguments as the string the model wrote: +// function_call arguments are a JSON string, custom_tool_call input free text. +func codexArguments(raw json.RawMessage) string { + var s string + if json.Unmarshal(raw, &s) == nil { + return s + } + return string(raw) +} + +func (x *codexTranscript) message(role string, content json.RawMessage) { + m := codexChat(codexChatMessage{Role: role, Content: codexTraceContent(content)}) + if role == "assistant" { + x.out = append(x.out, m) + return + } + x.prompt = append(x.prompt, m) +} + +func (x *codexTranscript) call(id, name string, arguments json.RawMessage) { + call := codexChatCall{ID: id, Type: "function"} + call.Function.Name, call.Function.Arguments = name, codexArguments(arguments) + x.out = append(x.out, codexChat(codexChatMessage{Role: "assistant", ToolCalls: []codexChatCall{call}})) +} + +func (x *codexTranscript) result(id string, output json.RawMessage) { + x.fed = append(x.fed, codexChat(codexChatMessage{Role: "tool", ToolCallID: id, Content: codexTraceContent(output)})) +} + +// response closes one model response. ok is false when the turn recorded no +// response items, so the caller keeps its older fallback. +func (x *codexTranscript) response(base string) (input, output string, ok bool) { + if len(x.prompt) == 0 && len(x.fed) == 0 && len(x.out) == 0 { + return "", "", false + } + var in []json.RawMessage + if base != "" { + content, _ := json.Marshal(base) + in = append(in, codexChat(codexChatMessage{Role: "system", Content: content})) + } + in = append(append(in, x.prompt...), x.fed...) + b, _ := json.Marshal(in) + input = string(b) + if len(x.out) > 0 { + b, _ = json.Marshal(x.out) + output = string(b) + } + x.fed, x.out = nil, nil + return input, output, true +} + +// codexNativeBodies fills what a native operation recorded besides command +// output: a file change's diff, the image viewed, an extension's query and +// results. An image generation's result is the image itself (megabytes of +// base64), so only where it was saved is kept. +func codexNativeBodies(s *TraceSpan, typ, path string, changes json.RawMessage, stdout, stderr string, query, action json.RawMessage, prompt string, results json.RawMessage, saved string, failure json.RawMessage) { + switch typ { + case "FileChange": + if len(changes) > 0 { + s.Input = string(changes) + } + if s.Output == "" && (stdout != "" || stderr != "") { + b, _ := json.Marshal(map[string]string{"stdout": stdout, "stderr": stderr}) + s.Output = string(b) + } + case "ImageView": + if path != "" { + b, _ := json.Marshal(map[string]string{"path": path}) + s.Input = string(b) + } + case "Extension": + in := map[string]any{} + if len(query) > 0 && string(query) != "null" { + in["query"] = query + } + if len(action) > 0 && string(action) != "null" { + in["action"] = action + } + if prompt != "" { + in["prompt"] = prompt + } + if len(in) > 0 { + b, _ := json.Marshal(in) + s.Input = string(b) + } + out := map[string]any{} + if len(results) > 0 && string(results) != "null" { + out["results"] = results + } + if saved != "" { + out["saved_path"] = saved + } + if len(failure) > 0 && string(failure) != "null" { + out["failure"] = failure + } + if len(out) > 0 { + b, _ := json.Marshal(out) + s.Output = string(b) + } + } +} diff --git a/internal/sessions/traces_codex_test.go b/internal/sessions/traces_codex_test.go new file mode 100644 index 000000000..1702414a0 --- /dev/null +++ b/internal/sessions/traces_codex_test.go @@ -0,0 +1,204 @@ +package sessions + +import ( + "bufio" + "encoding/json" + "fmt" + "os" + "path/filepath" + "strings" + "testing" +) + +func codexFixtureSpans(t *testing.T, name string, bodies bool) []TraceSpan { + t.Helper() + f, err := os.Open(filepath.Join("testdata", "traces", name)) + if err != nil { + t.Fatal(err) + } + defer f.Close() + c := traceTestCursor("codex") + var spans []TraceSpan + s := bufio.NewScanner(f) + s.Buffer(nil, 1<<20) + for s.Scan() { + spans = append(spans, c.line(s.Bytes(), bodies)...) + } + if s.Err() != nil { + t.Fatal(s.Err()) + } + return spans +} + +type codexTestMessage struct { + Role string + Content json.RawMessage + ToolCallID string `json:"tool_call_id"` + ToolCalls []struct { + ID string + Function struct{ Name, Arguments string } + } `json:"tool_calls"` +} + +func codexMessages(t *testing.T, body string) []codexTestMessage { + t.Helper() + var m []codexTestMessage + if body == "" { + return nil + } + if err := json.Unmarshal([]byte(body), &m); err != nil { + t.Fatalf("body is not a message list: %v\n%s", err, body) + } + for _, x := range m { + if x.Role == "" { + t.Fatalf("message without a role: %s", body) + } + } + return m +} + +// JuckZ's #2284 rollout: two Codex Desktop turns, 28 responses, 8 replies, +// most responses only calling a tool, and a settings notice between turns. +func TestCodexDesktopTraceEachResponseOwnsItsOutput(t *testing.T) { + for _, bodies := range []bool{false, true} { + spans := codexFixtureSpans(t, "codex-desktop-sanitized.jsonl", bodies) + roots, models, tools := spanKinds(spans) + ids := map[string]int{} + for _, r := range roots { + if !r.Pending { + ids[r.ID]++ + if r.Error || r.Inferred { + t.Errorf("bodies=%v: a completed turn exported as interrupted: %+v", bodies, r) + } + } + } + if len(ids) != 2 || len(roots)-2 != 2 { + t.Fatalf("bodies=%v: want 2 finished roots (plus 2 pending starts), got %d spans over %d IDs", bodies, len(roots)-2, len(ids)) + } + for id, n := range ids { + if n != 1 { + t.Fatalf("bodies=%v: root %s exported %d times", bodies, id, n) + } + } + if len(models) != 28 { + t.Fatalf("bodies=%v: %d model responses, want 28", bodies, len(models)) + } + web := 0 + for _, s := range tools { + if s.Name == "web" { + web++ + if bodies && !strings.Contains(s.Input, "Fixture search.") { + t.Fatalf("extension query missing: %+v", s) + } + } + if bodies && s.Name == "view image" && !strings.Contains(s.Input, "fixture.png") { + t.Fatalf("viewed image path missing: %+v", s) + } + if bodies && s.Name == "file change" && !strings.Contains(s.Input, "Fixture file diff.") { + t.Fatalf("file change diff missing: %+v", s) + } + } + if web != 4 { + t.Fatalf("bodies=%v: %d web extension operations, want 4", bodies, web) + } + if !bodies { + for _, s := range spans { + if s.Input != "" || s.Output != "" { + t.Fatalf("body exported while disabled: %+v", s) + } + } + continue + } + replies := map[string]int{} + called := map[string]bool{} + answered := map[string]bool{} + for _, m := range models { + for _, x := range codexMessages(t, m.Output) { + if x.Role != "assistant" { + t.Fatalf("non-assistant output %s", m.Output) + } + var text []struct{ Text string } + json.Unmarshal(x.Content, &text) + for _, p := range text { + replies[p.Text]++ + } + for _, call := range x.ToolCalls { + if called[call.ID] || call.Function.Name == "" { + t.Fatalf("tool call %s repeated or unnamed", call.ID) + } + called[call.ID] = true + } + } + in := codexMessages(t, m.Input) + if len(in) < 3 || in[0].Role != "system" || !strings.Contains(string(in[0].Content), "Fixture system instructions.") || in[1].Role != "developer" { + t.Fatalf("prompt missing system or developer message: %s", m.Input) + } + turn1 := strings.Contains(m.Input, "Fixture user message 1.") + turn2 := strings.Contains(m.Input, "Fixture user message 2.") + if turn1 == turn2 { + t.Fatalf("input holds the wrong turn's prompt: %s", m.Input) + } + for _, x := range in { + if x.Role == "tool" { + if !called[x.ToolCallID] { + t.Fatalf("result %s fed before its call", x.ToolCallID) + } + answered[x.ToolCallID] = true + } + } + } + for i := 1; i <= 8; i++ { + text := fmt.Sprintf("Fixture assistant message %d.", i) + if replies[text] != 1 { + t.Errorf("%q in %d responses' output, want 1", text, replies[text]) + } + } + if len(called) != 25 || len(answered) != 25 { + t.Fatalf("calls %d, results fed back %d; want 25 each", len(called), len(answered)) + } + } +} + +// The Codex CLI rollout records no turn ID on its response items; replies +// still belong only to the response that wrote them. +func TestCodexCLITraceRepliesStayWithTheirResponse(t *testing.T) { + _, models, _ := spanKinds(codexFixtureSpans(t, "codex-real-sanitized.jsonl", true)) + text := 0 + for _, m := range models { + for _, x := range codexMessages(t, m.Output) { + if len(x.Content) > 0 { + text++ + } + } + } + if len(models) != 5 || text != 3 { + t.Fatalf("%d responses carry reply text, want 3 of 5", text) + } +} + +// A screenshot in a tool result is megabytes of base64. The tool's own span +// keeps it as recorded; the prompt, sent with every response, names it. +func TestCodexTraceInlineImageNotRepeated(t *testing.T) { + image := "data:image/png;base64," + strings.Repeat("A", 4096) + c := traceTestCursor("codex") + spans := clientTraceFeed(t, c, true, + `{"type":"session_meta","payload":{"id":"session"}}`, + `{"type":"event_msg","timestamp":"2026-10-02T12:00:00Z","payload":{"type":"task_started","turn_id":"turn"}}`, + `{"type":"response_item","timestamp":"2026-10-02T12:00:01Z","payload":{"type":"message","role":"user","content":[{"type":"input_text","text":"look"},{"type":"input_image","image_url":"`+image+`"}]}}`, + `{"type":"response_item","timestamp":"2026-10-02T12:00:02Z","payload":{"type":"custom_tool_call","name":"exec","call_id":"shot","input":"screenshot"}}`, + `{"type":"token_usage_record","timestamp":"2026-10-02T12:00:03Z","payload":{"response_id":"r1"}}`, + `{"type":"response_item","timestamp":"2026-10-02T12:00:04Z","payload":{"type":"custom_tool_call_output","call_id":"shot","output":[{"type":"input_text","text":"done"},{"type":"input_image","image_url":"`+image+`"}]}}`, + `{"type":"token_usage_record","timestamp":"2026-10-02T12:00:05Z","payload":{"response_id":"r2"}}`) + _, models, tools := spanKinds(spans) + if len(models) != 2 || len(tools) != 1 || !strings.Contains(tools[0].Output, image) { + t.Fatalf("models %d tools %+v", len(models), tools) + } + for _, m := range models { + if strings.Contains(m.Input, "AAAA") || !strings.Contains(m.Input, "image/png, 4096 bytes") { + t.Fatalf("inline image copied into the prompt: %.200s", m.Input) + } + } + if !strings.Contains(models[1].Input, `"tool_call_id":"shot"`) || models[1].Output != "" { + t.Fatalf("second response: in %s out %s", models[1].Input, models[1].Output) + } +}