diff --git a/config.example.toml b/config.example.toml index 6219c137f..17f10e050 100644 --- a/config.example.toml +++ b/config.example.toml @@ -449,7 +449,7 @@ target = "127.0.0.1:9090" # REQUIRED. The State Store gRPC address arch # image: the workload Kit, then mixins, each pinned by digest. # [containers.profiles.claude] # kit = ["docker/claude-code-kit@sha256:"] -# adapter = "claude-code" # output adapter; empty runs without capture tools or usage +# adapter = "claude-code" # claude-code, codex, pi, omp or copilot; empty runs without capture tools or usage # At least one [[repos]] entry is required before archied will poll # anything -- it is deliberately left commented rather than shipped active: diff --git a/internal/agentexec/harness_adapters.go b/internal/agentexec/harness_adapters.go index 0901c027c..c989aab37 100644 --- a/internal/agentexec/harness_adapters.go +++ b/internal/agentexec/harness_adapters.go @@ -5,6 +5,14 @@ import "context" // AdapterClaudeCode names the Claude Code stream-json output adapter. const AdapterClaudeCode = "claude-code" +// Adapters for the other supported CLIs' JSON output streams. +const ( + AdapterCodex = "codex" + AdapterPi = "pi" + AdapterOMP = "omp" + AdapterCopilot = "copilot" +) + // HarnessAdapter is what archie knows about one CLI: how to read its output // stream and how to register archie's MCP server with it. type HarnessAdapter struct { @@ -17,6 +25,16 @@ var harnessAdapters = map[string]HarnessAdapter{ NewOutput: func() HarnessOutput { return newClaudeCodeHarnessOutput() }, MCPConfig: []string{"--mcp-config", mcpConfigPlaceholder}, }, + // Codex takes MCP servers only as inline -c overrides, and Pi and OMP + // read no MCP config file of this shape, so their stages serve no + // capture tools. + AdapterCodex: {NewOutput: func() HarnessOutput { return &codexHarnessOutput{} }}, + AdapterPi: {NewOutput: func() HarnessOutput { return &piHarnessOutput{} }}, + AdapterOMP: {NewOutput: func() HarnessOutput { return &piHarnessOutput{} }}, + AdapterCopilot: { + NewOutput: func() HarnessOutput { return newCopilotHarnessOutput() }, + MCPConfig: []string{"--additional-mcp-config", "@" + mcpConfigPlaceholder}, + }, } // LookupHarnessAdapter returns the named adapter. The empty name is a CLI diff --git a/internal/agentexec/harness_output_codex.go b/internal/agentexec/harness_output_codex.go new file mode 100644 index 000000000..797032443 --- /dev/null +++ b/internal/agentexec/harness_output_codex.go @@ -0,0 +1,105 @@ +package agentexec + +import ( + "encoding/json" + "strings" +) + +// codexHarnessOutput reads `codex exec --json`. Each tool item is reported +// when its item.completed event arrives; usage comes from turn.completed, so +// a run killed mid-turn reports none. +type codexHarnessOutput struct { + threadID string + usage Usage +} + +func (o *codexHarnessOutput) Line(line []byte, report ToolCallReporter) { + var event struct { + Type string `json:"type"` + ThreadID string `json:"thread_id"` + Usage *struct { + InputTokens int `json:"input_tokens"` + CachedInputTokens int `json:"cached_input_tokens"` + CacheWriteTokens int `json:"cache_write_input_tokens"` + OutputTokens int `json:"output_tokens"` + } `json:"usage"` + Item codexItem `json:"item"` + } + if json.Unmarshal(line, &event) != nil { + return + } + switch event.Type { + case "thread.started": + o.threadID = event.ThreadID + case "turn.completed": + if u := event.Usage; u != nil { + // Codex follows OpenAI: input_tokens already includes cached input. + o.usage = addUsage(o.usage, Usage{ + PromptTokens: u.InputTokens, CompletionTokens: u.OutputTokens, + TotalTokens: u.InputTokens + u.OutputTokens, + CachedTokens: u.CachedInputTokens, CacheCreationTokens: u.CacheWriteTokens, + }) + } + case "item.completed": + if call, ok := event.Item.report(); ok && report != nil { + report(call) + } + } +} + +type codexItem struct { + Type string `json:"type"` + Status string `json:"status"` + AggregatedOutput string `json:"aggregated_output"` + Tool string `json:"tool"` + Result *struct { + Content []struct { + Type string `json:"type"` + Text string `json:"text"` + } `json:"content"` + } `json:"result"` + Error *struct { + Message string `json:"message"` + } `json:"error"` + Changes []struct { + Path string `json:"path"` + } `json:"changes"` + Query string `json:"query"` +} + +func (item codexItem) report() (ToolCallReport, bool) { + call := ToolCallReport{Tool: item.Type, Failed: item.Status == "failed"} + switch item.Type { + case "command_execution": + call.Detail = item.AggregatedOutput + case "mcp_tool_call": + call.Tool = item.Tool + switch { + case item.Error != nil: + call.Detail, call.Failed = item.Error.Message, true + case item.Result != nil: + texts := make([]string, 0, len(item.Result.Content)) + for _, block := range item.Result.Content { + if block.Type == "text" { + texts = append(texts, block.Text) + } + } + call.Detail = strings.Join(texts, "\n") + } + case "file_change": + paths := make([]string, 0, len(item.Changes)) + for _, change := range item.Changes { + paths = append(paths, change.Path) + } + call.Detail = strings.Join(paths, "\n") + case "web_search": + call.Detail = item.Query + default: + return ToolCallReport{}, false + } + call.Detail = clipToolCallDetail(call.Detail) + return call, true +} + +func (o *codexHarnessOutput) SessionID() string { return o.threadID } +func (o *codexHarnessOutput) Usage() Usage { return o.usage } diff --git a/internal/agentexec/harness_output_copilot.go b/internal/agentexec/harness_output_copilot.go new file mode 100644 index 000000000..ff82f36ec --- /dev/null +++ b/internal/agentexec/harness_output_copilot.go @@ -0,0 +1,58 @@ +package agentexec + +import "encoding/json" + +// copilotHarnessOutput reads GitHub Copilot CLI's `--output-format json`. +// The stream carries no token counts, so a Copilot run reports no usage and +// its budget is wall clock. +type copilotHarnessOutput struct { + sessionID string + pending map[string]string +} + +func newCopilotHarnessOutput() *copilotHarnessOutput { + return &copilotHarnessOutput{pending: make(map[string]string)} +} + +func (o *copilotHarnessOutput) Line(line []byte, report ToolCallReporter) { + var event struct { + Type string `json:"type"` + SessionID string `json:"sessionId"` + Data struct { + ToolCallID string `json:"toolCallId"` + ToolName string `json:"toolName"` + MCPToolName string `json:"mcpToolName"` + Success bool `json:"success"` + Result struct { + Content string `json:"content"` + } `json:"result"` + } `json:"data"` + } + if json.Unmarshal(line, &event) != nil { + return + } + switch event.Type { + case "result": + o.sessionID = event.SessionID + case "tool.execution_start": + name := event.Data.MCPToolName + if name == "" { + name = event.Data.ToolName + } + if event.Data.ToolCallID != "" && name != "" { + o.pending[event.Data.ToolCallID] = name + } + case "tool.execution_complete": + tool, ok := o.pending[event.Data.ToolCallID] + if !ok { + return + } + delete(o.pending, event.Data.ToolCallID) + if report != nil { + report(ToolCallReport{Tool: tool, Detail: clipToolCallDetail(event.Data.Result.Content), Failed: !event.Data.Success}) + } + } +} + +func (o *copilotHarnessOutput) SessionID() string { return o.sessionID } +func (o *copilotHarnessOutput) Usage() Usage { return Usage{} } diff --git a/internal/agentexec/harness_output_pi.go b/internal/agentexec/harness_output_pi.go new file mode 100644 index 000000000..b8394025b --- /dev/null +++ b/internal/agentexec/harness_output_pi.go @@ -0,0 +1,64 @@ +package agentexec + +import ( + "encoding/json" + "strings" +) + +// piHarnessOutput reads `--mode json` from Pi and OMP, which share the +// event stream. Usage is summed from each assistant message_end, so an +// interrupted run still reports what it spent. +type piHarnessOutput struct { + sessionID string + usage Usage +} + +func (o *piHarnessOutput) Line(line []byte, report ToolCallReporter) { + var event struct { + Type string `json:"type"` + ID string `json:"id"` + ToolName string `json:"toolName"` + IsError bool `json:"isError"` + Result struct { + Content []struct { + Type string `json:"type"` + Text string `json:"text"` + } `json:"content"` + } `json:"result"` + Message struct { + Role string `json:"role"` + Usage *struct { + Input int `json:"input"` + Output int `json:"output"` + CacheRead int `json:"cacheRead"` + CacheWrite int `json:"cacheWrite"` + } `json:"usage"` + } `json:"message"` + } + if json.Unmarshal(line, &event) != nil { + return + } + switch event.Type { + case "session": + o.sessionID = event.ID + case "message_end": + // Pi's input excludes cache reads and writes, as Claude's does. + if u := event.Message.Usage; event.Message.Role == "assistant" && u != nil { + o.usage = addUsage(o.usage, usageFromFields(u.Input, u.Output, u.CacheRead, u.CacheWrite)) + } + case "tool_execution_end": + if event.ToolName == "" || report == nil { + return + } + texts := make([]string, 0, len(event.Result.Content)) + for _, block := range event.Result.Content { + if block.Type == "text" { + texts = append(texts, block.Text) + } + } + report(ToolCallReport{Tool: event.ToolName, Detail: clipToolCallDetail(strings.Join(texts, "\n")), Failed: event.IsError}) + } +} + +func (o *piHarnessOutput) SessionID() string { return o.sessionID } +func (o *piHarnessOutput) Usage() Usage { return o.usage } diff --git a/internal/agentexec/harness_output_test.go b/internal/agentexec/harness_output_test.go new file mode 100644 index 000000000..652928518 --- /dev/null +++ b/internal/agentexec/harness_output_test.go @@ -0,0 +1,129 @@ +package agentexec + +import ( + "bufio" + "os" + "reflect" + "strings" + "testing" +) + +func TestHarnessOutputFixtures(t *testing.T) { + const missing = "cat: /nonexistent-file: No such file or directory\n" + cases := []struct { + adapter string + fixture string + // stopAt truncates the stream before the first line containing it, + // as when the process is killed mid-run. + stopAt string + wantCalls []ToolCallReport + wantUsage Usage + wantSession string + }{ + { + adapter: AdapterCodex, fixture: "codex/run.jsonl", + wantCalls: []ToolCallReport{ + {Tool: "command_execution", Detail: "hello\n"}, + {Tool: "command_execution", Detail: missing, Failed: true}, + }, + wantUsage: Usage{PromptTokens: 72082, CompletionTokens: 118, TotalTokens: 72200, CachedTokens: 57600}, + wantSession: "01a0db18-e119-7872-bf13-3644369044fb", + }, + { + adapter: AdapterCodex, fixture: "codex/mcp.jsonl", + wantCalls: []ToolCallReport{ + {Tool: "record_verdict", Detail: "record_verdict recorded"}, + {Tool: "file_change", Detail: "/tmp/hfx/note.txt"}, + }, + wantUsage: Usage{PromptTokens: 96397, CompletionTokens: 203, TotalTokens: 96600, CachedTokens: 80896}, + wantSession: "01a0db19-f9d6-7ad2-870c-c29b7fd8ab0a", + }, + { + adapter: AdapterCodex, fixture: "codex/run.jsonl", stopAt: `"turn.completed"`, + wantCalls: []ToolCallReport{ + {Tool: "command_execution", Detail: "hello\n"}, + {Tool: "command_execution", Detail: missing, Failed: true}, + }, + wantSession: "01a0db18-e119-7872-bf13-3644369044fb", + }, + { + adapter: AdapterPi, fixture: "pi/run.jsonl", + wantCalls: []ToolCallReport{ + {Tool: "bash", Detail: "hello\n"}, + {Tool: "bash", Detail: missing + "\n\nCommand exited with code 1", Failed: true}, + }, + wantUsage: Usage{PromptTokens: 109198, CompletionTokens: 38, TotalTokens: 109236, CachedTokens: 62720}, + wantSession: "01a0db18-e183-7432-9e4b-4b16bfc83856", + }, + { + adapter: AdapterPi, fixture: "pi/run.jsonl", stopAt: `"agent_end"`, + wantCalls: []ToolCallReport{ + {Tool: "bash", Detail: "hello\n"}, + {Tool: "bash", Detail: missing + "\n\nCommand exited with code 1", Failed: true}, + }, + wantUsage: Usage{PromptTokens: 109198, CompletionTokens: 38, TotalTokens: 109236, CachedTokens: 62720}, + wantSession: "01a0db18-e183-7432-9e4b-4b16bfc83856", + }, + { + adapter: AdapterOMP, fixture: "omp/run.jsonl", + wantCalls: []ToolCallReport{ + {Tool: "bash", Detail: "hello\n\n\nWall time: 0.03 seconds"}, + {Tool: "bash", Detail: missing + "\n\nWall time: 0.00 seconds\n\nCommand exited with code 1", Failed: true}, + }, + wantUsage: Usage{PromptTokens: 75962, CompletionTokens: 161, TotalTokens: 76123, CachedTokens: 50304}, + wantSession: "01a0db18-e4a1-7000-9cbe-7467b0385e65", + }, + { + adapter: AdapterCopilot, fixture: "copilot/run.jsonl", + wantCalls: []ToolCallReport{ + {Tool: "bash", Detail: "hello\n"}, + {Tool: "bash", Detail: missing + ""}, + }, + wantSession: "bdf5531e-b8a4-4baf-bed2-d914242fa387", + }, + { + adapter: AdapterCopilot, fixture: "copilot/mcp.jsonl", + wantCalls: []ToolCallReport{{Tool: "record_verdict", Detail: "record_verdict recorded"}}, + wantSession: "46ce5d05-adf6-45ac-82bc-167a3c48a146", + }, + } + + for _, tc := range cases { + t.Run(tc.fixture+tc.stopAt, func(t *testing.T) { + adapter, ok := LookupHarnessAdapter(tc.adapter) + if !ok { + t.Fatalf("adapter %q is not registered", tc.adapter) + } + stream, err := os.Open("testdata/" + tc.fixture) + if err != nil { + t.Fatal(err) + } + defer stream.Close() + + output := adapter.NewOutput() + var calls []ToolCallReport + report := func(call ToolCallReport) { calls = append(calls, call) } + output.Line([]byte("{not json"), report) + scanner := bufio.NewScanner(stream) + scanner.Buffer(nil, 1<<20) + for scanner.Scan() { + if tc.stopAt != "" && strings.Contains(scanner.Text(), tc.stopAt) { + break + } + output.Line(scanner.Bytes(), report) + } + if err := scanner.Err(); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(calls, tc.wantCalls) { + t.Errorf("tool calls = %#v, want %#v", calls, tc.wantCalls) + } + if got := output.SessionID(); got != tc.wantSession { + t.Errorf("session ID = %q, want %q", got, tc.wantSession) + } + if got := output.Usage(); got != tc.wantUsage { + t.Errorf("usage = %#v, want %#v", got, tc.wantUsage) + } + }) + } +} diff --git a/internal/agentexec/testdata/codex/mcp.jsonl b/internal/agentexec/testdata/codex/mcp.jsonl new file mode 100644 index 000000000..a84bbdaa2 --- /dev/null +++ b/internal/agentexec/testdata/codex/mcp.jsonl @@ -0,0 +1,8 @@ +{"type":"thread.started","thread_id":"01a0db19-f9d6-7ad2-870c-c29b7fd8ab0a"} +{"type":"turn.started"} +{"type":"item.started","item":{"id":"item_0","type":"mcp_tool_call","server":"archie","tool":"record_verdict","arguments":{"verdict":"ok"},"result":null,"error":null,"status":"in_progress"}} +{"type":"item.completed","item":{"id":"item_0","type":"mcp_tool_call","server":"archie","tool":"record_verdict","arguments":{"verdict":"ok"},"result":{"content":[{"type":"text","text":"record_verdict recorded"}],"structured_content":null},"error":null,"status":"completed"}} +{"type":"item.started","item":{"id":"item_1","type":"file_change","changes":[{"path":"/tmp/hfx/note.txt","kind":"add"}],"status":"in_progress"}} +{"type":"item.completed","item":{"id":"item_1","type":"file_change","changes":[{"path":"/tmp/hfx/note.txt","kind":"add"}],"status":"completed"}} +{"type":"item.completed","item":{"id":"item_2","type":"agent_message","text":"done"}} +{"type":"turn.completed","usage":{"input_tokens":96397,"cached_input_tokens":80896,"cache_write_input_tokens":0,"output_tokens":203,"reasoning_output_tokens":87}} diff --git a/internal/agentexec/testdata/codex/run.jsonl b/internal/agentexec/testdata/codex/run.jsonl new file mode 100644 index 000000000..74047db0c --- /dev/null +++ b/internal/agentexec/testdata/codex/run.jsonl @@ -0,0 +1,9 @@ +{"type":"thread.started","thread_id":"01a0db18-e119-7872-bf13-3644369044fb"} +{"type":"turn.started"} +{"type":"item.completed","item":{"id":"item_0","type":"agent_message","text":"I’ll run the two requested shell commands in order, exactly as written."}} +{"type":"item.started","item":{"id":"item_1","type":"command_execution","command":"/usr/bin/bash -lc 'echo hello'","aggregated_output":"","exit_code":null,"status":"in_progress"}} +{"type":"item.completed","item":{"id":"item_1","type":"command_execution","command":"/usr/bin/bash -lc 'echo hello'","aggregated_output":"hello\n","exit_code":0,"status":"completed"}} +{"type":"item.started","item":{"id":"item_2","type":"command_execution","command":"/usr/bin/bash -lc 'cat /nonexistent-file'","aggregated_output":"","exit_code":null,"status":"in_progress"}} +{"type":"item.completed","item":{"id":"item_2","type":"command_execution","command":"/usr/bin/bash -lc 'cat /nonexistent-file'","aggregated_output":"cat: /nonexistent-file: No such file or directory\n","exit_code":1,"status":"failed"}} +{"type":"item.completed","item":{"id":"item_3","type":"agent_message","text":"done"}} +{"type":"turn.completed","usage":{"input_tokens":72082,"cached_input_tokens":57600,"cache_write_input_tokens":0,"output_tokens":118,"reasoning_output_tokens":0}} diff --git a/internal/agentexec/testdata/copilot/mcp.jsonl b/internal/agentexec/testdata/copilot/mcp.jsonl new file mode 100644 index 000000000..518730780 --- /dev/null +++ b/internal/agentexec/testdata/copilot/mcp.jsonl @@ -0,0 +1,12 @@ +{"type":"user.message","data":{"content":"Call the archie record_verdict tool with verdict \"ok\", then reply done.","transformedContent":"2026-09-26T10:24:51.899+10:00\n\nCall the archie record_verdict tool with verdict \"ok\", then reply done.","messageId":"6edfda87-baa7-43ae-9085-b35df7730a5b","supportedNativeDocumentMimeTypes":[],"delivery":"idle","interactionId":"ffa78343-e6f5-42aa-aea1-867cf22d8c62","turnId":"0","parentAgentTaskId":"695a0eb0-7c9f-403f-bf8a-11b359bbd6ef"},"id":"e6d6b78e-25a8-4718-9ab5-21730e4c1930","timestamp":"2026-09-26T00:24:51.899Z","parentId":"cf961d42-16aa-496f-81d2-f205e525c341"} +{"type":"assistant.turn_start","data":{"turnId":"0","interactionId":"ffa78343-e6f5-42aa-aea1-867cf22d8c62"},"id":"43c30d9f-a78d-49ab-a73d-a5059d6a8f33","timestamp":"2026-09-26T00:24:51.951Z","parentId":"d0f5807a-db5a-4bf5-bfca-0a0df80eb3e1"} +{"type":"assistant.message","data":{"messageId":"10378468-f2b3-4f1f-bbca-876991380095","originatingMessageId":"6edfda87-baa7-43ae-9085-b35df7730a5b","model":"mai-code-1.1-flash","content":"","toolRequests":[{"toolCallId":"call_SCpBb7giULn1ses3WUvaZ646","name":"archie-record_verdict","arguments":{"verdict":"ok"},"type":"function","toolTitle":"record_verdict","mcpServerName":"archie","mcpToolName":"record_verdict"}],"interactionId":"ffa78343-e6f5-42aa-aea1-867cf22d8c62","turnId":"0","rte":true,"apiCallId":"o4IeQmLtNQWeaj+YWo08mszPXOF1AP702ynApqaRloJ8MNMmCNuUlmqMMdwDx27Tz5AVPoX1PWYGPBcL7y+TQE22HWxuzkAPH8S8LdvfGV+ancUM6NM1SeWCj3Q3JzZNPxQUkRqNJ7D2vvMLcAVYOMHfOU9+Bu1dTI/+opLLn4L85IaRKa20wJ3cN5Lh0kRIoBYWrYQwImIBAkjaPlIOJRUNku2BLwFcBeNciBkvwBW6v0dUAE3GOvt8Wi8u2ierGofUYTmv4PNRZJnEjE69og/rOlP+b7x8Zf6amoEaZoFBET1Kw8Or57gcsdumstObCF+2MI8oFfnMg3igVm8/ZHMmTlUebjfNsc2PlzVyFWZfT5SwY+LjyzE22QTggIQwZ1kNUI7baA3JMqo5PQuoztdTWtJuz/u42q43kOLKhnj+P2YGP/I5FBvLbDcghIsS","serverTools":{"provider":"openai-responses"}},"id":"9adeb15a-b245-4b11-948e-9e688e7b1dad","timestamp":"2026-09-26T00:24:55.924Z","parentId":"43c30d9f-a78d-49ab-a73d-a5059d6a8f33"} +{"type":"tool.execution_start","data":{"toolCallId":"call_SCpBb7giULn1ses3WUvaZ646","toolName":"archie-record_verdict","arguments":{"verdict":"ok"},"turnId":"0","model":"mai-code-1.1-flash","toolTitle":"record_verdict","mcpServerName":"archie","mcpConfigServerName":"archie","mcpTransport":"stdio","mcpConfigSource":"user","mcpToolName":"record_verdict"},"id":"fffc906a-39af-4eb1-91ba-80fa0f8cb7f7","timestamp":"2026-09-26T00:24:55.927Z","parentId":"9adeb15a-b245-4b11-948e-9e688e7b1dad"} +{"type":"tool.execution_complete","data":{"toolCallId":"call_SCpBb7giULn1ses3WUvaZ646","model":"mai-code-1.1-flash","interactionId":"ffa78343-e6f5-42aa-aea1-867cf22d8c62","turnId":"0","rte":true,"success":true,"result":{"content":"record_verdict recorded","detailedContent":"record_verdict recorded","contents":[{"type":"text","text":"record_verdict recorded"}]},"toolTelemetry":{"metrics":{"mcp_result_content_bytes":23}}},"id":"97d661ef-f75b-4734-b358-c843a3e5543d","timestamp":"2026-09-26T00:24:55.931Z","parentId":"fffc906a-39af-4eb1-91ba-80fa0f8cb7f7"} +{"type":"assistant.turn_end","data":{"turnId":"0"},"id":"6a3adff0-7017-4c44-8d8d-b32d94442b7b","timestamp":"2026-09-26T00:24:55.936Z","parentId":"97d661ef-f75b-4734-b358-c843a3e5543d"} +{"type":"assistant.turn_start","data":{"turnId":"1","interactionId":"ffa78343-e6f5-42aa-aea1-867cf22d8c62"},"id":"20538fbe-354e-4c37-a66d-dd169baaae6c","timestamp":"2026-09-26T00:24:55.937Z","parentId":"6a3adff0-7017-4c44-8d8d-b32d94442b7b"} +{"type":"assistant.message_start","data":{"messageId":"fd2cd067-22f8-45a3-996e-5b5170455259","phase":"final_answer"},"ephemeral":true,"id":"0aa849db-670e-4d8c-bf28-4b67fedbfefd","timestamp":"2026-09-26T00:24:58.682Z","parentId":"20538fbe-354e-4c37-a66d-dd169baaae6c"} +{"type":"assistant.message","data":{"messageId":"fd2cd067-22f8-45a3-996e-5b5170455259","originatingMessageId":"6edfda87-baa7-43ae-9085-b35df7730a5b","model":"mai-code-1.1-flash","content":"done","toolRequests":[],"interactionId":"ffa78343-e6f5-42aa-aea1-867cf22d8c62","turnId":"1","phase":"final_answer","rte":true,"apiCallId":"rQ30ntxRLGIEBrvhcd/a8wMwoTOBA1A5DiGkpF5vfM/MXyIvo81P2W19LNGRYtko/DuDhi1S2NbJp2REVkOsV7QiReoS59ABuGoME9Jp5ccwWfjR4dtfrwZY7ARBkDjoE79/dt0e+73SvAIoP6Vc5DoJ1aBOlDb1Uo7sGxyPDUPNfnjFc0ZSSr1YHviwGcVOoSkB66IrY+zzdz+s43b+Kn9sDiFD/28bvxdH3o6tqmuuVYL35qGuyhoDUlRKk4JXTB8aAjw1IS+lXYVYHfoGhv6F+ZEIf9H/KOVioWCfW3wPEyNOiPyA0qH9gy8g6V1rminPG+6JgwPdZ3QVEuOddFQjj8OjpTLHYKyKVDRxwNq7p0WEH1Wgb8wPpSZpHtAHoHL5rlsSCWcZcoAKFU/Eh+pi9ms073CsMyjhwu+x93O5x8z/pv8CD8BRkJuT0lH6","serverTools":{"provider":"openai-responses"}},"id":"c1b6cb34-b547-4b09-a057-042129d8e8e6","timestamp":"2026-09-26T00:24:59.033Z","parentId":"20538fbe-354e-4c37-a66d-dd169baaae6c"} +{"type":"assistant.turn_end","data":{"turnId":"1"},"id":"ac711ef0-98c9-4903-8605-d0a075038156","timestamp":"2026-09-26T00:24:59.037Z","parentId":"c1b6cb34-b547-4b09-a057-042129d8e8e6"} +{"type":"assistant.idle","data":{},"ephemeral":true,"id":"3cdd0759-c01f-4670-bd89-1d7d265057c5","timestamp":"2026-09-26T00:24:59.042Z","parentId":"dde7674c-f216-47d1-99dc-b1a42340e3ab"} +{"type":"result","timestamp":"2026-09-26T00:24:59.048Z","sessionId":"46ce5d05-adf6-45ac-82bc-167a3c48a146","exitCode":0,"usage":{"premiumRequests":1,"totalApiDurationMs":7028,"sessionDurationMs":10510,"codeChanges":{"linesAdded":0,"linesRemoved":0,"filesModified":[]}}} diff --git a/internal/agentexec/testdata/copilot/run.jsonl b/internal/agentexec/testdata/copilot/run.jsonl new file mode 100644 index 000000000..935338613 --- /dev/null +++ b/internal/agentexec/testdata/copilot/run.jsonl @@ -0,0 +1,21 @@ +{"type":"user.message","data":{"content":"Run exactly these two shell commands, one at a time, then reply \"done\": 1) echo hello 2) cat /nonexistent-file","transformedContent":"2026-09-26T10:24:05.291+10:00\n\nRun exactly these two shell commands, one at a time, then reply \"done\": 1) echo hello 2) cat /nonexistent-file","messageId":"592e4a25-4edd-4138-8428-04377528629d","supportedNativeDocumentMimeTypes":[],"delivery":"idle","interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a","turnId":"0","parentAgentTaskId":"a7334356-386f-4883-a45b-c0202257c75e"},"id":"30170ef7-73c3-4ddc-b68a-420fa53126c5","timestamp":"2026-09-26T00:24:05.291Z","parentId":"c5779a53-653b-4d88-9a5d-5d04392191bc"} +{"type":"assistant.turn_start","data":{"turnId":"0","interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a"},"id":"7eaf3f4d-f167-4458-87ee-3d5590b00c18","timestamp":"2026-09-26T00:24:05.334Z","parentId":"14d0190b-e039-42f9-a4b9-0a75ae807f1f"} +{"type":"assistant.message","data":{"messageId":"6b6bea7c-2344-47a1-95db-1f8d6e682666","originatingMessageId":"592e4a25-4edd-4138-8428-04377528629d","model":"mai-code-1.1-flash","content":"","toolRequests":[{"toolCallId":"call_B7mfLIxqUZJ0U7TPuq7AICf6","name":"bash","arguments":{"command":"echo hello","description":"Run the first required shell command","mode":"sync","initial_wait":10},"type":"function","intentionSummary":"Run the first required shell command"}],"interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a","turnId":"0","rte":true,"apiCallId":"f62pmo58wYEiXCowGq2scylnq7Sl72p0HPwz/uzwyAxSnDimAMaUhplE5ob+c/7UI4GlY/FKov+OuTgP6cZYK7vKyWfmHE9irEusbHzDNwaNyfjyJzDuyko5LEHYhPYh4tVFCdob6X764KL1JPVls66S+KZU6pxGyqW5Z9SuYNl1pw/T/mtRZamdmejkxNtprl6c6SZjn//mGF8QAUE5TTHGCUf4ZVynuCu8OplI6+WU4ecM86bUgFHRxHdAml3UpXrLnhhqGf/24sMtIaZdm5XhxNYtpTn1HD5ZDHsyS0pJBAstHCT3zpdjkkg+oy+9I7cfZ8D/aE8tLJjRO36rY69+r2QhLB7gko41WnZhgeTlxtgIaUpEbA5RT325gzH2y70ryklfEwUfM3vecHLbSmBPBVo/2Si5tAMzaX9/fePrelVxJZmogzX2zFEM7oZH","serverTools":{"provider":"openai-responses"}},"id":"18daf5a9-28ad-4e32-a964-c7a7b2fa3561","timestamp":"2026-09-26T00:24:07.616Z","parentId":"7eaf3f4d-f167-4458-87ee-3d5590b00c18"} +{"type":"tool.execution_start","data":{"toolCallId":"call_B7mfLIxqUZJ0U7TPuq7AICf6","toolName":"bash","arguments":{"command":"echo hello","description":"Run the first required shell command","mode":"sync","initial_wait":10},"turnId":"0","model":"mai-code-1.1-flash","shellToolInfo":{"possiblePaths":[],"hasWriteFileRedirection":false}},"id":"495b5003-1cae-48ab-a3cf-299aebdbcd57","timestamp":"2026-09-26T00:24:07.617Z","parentId":"18daf5a9-28ad-4e32-a964-c7a7b2fa3561"} +{"type":"tool.execution_partial_result","data":{"toolCallId":"call_B7mfLIxqUZJ0U7TPuq7AICf6","partialOutput":"hello\n"},"ephemeral":true,"id":"bfa8c93e-8702-4405-9f34-fcf2e488a5f7","timestamp":"2026-09-26T00:24:07.671Z","parentId":"495b5003-1cae-48ab-a3cf-299aebdbcd57"} +{"type":"tool.execution_partial_result","data":{"toolCallId":"call_B7mfLIxqUZJ0U7TPuq7AICf6","partialOutput":"hello\n"},"ephemeral":true,"id":"f2a7773b-fc90-4dec-90a2-7f59a9703002","timestamp":"2026-09-26T00:24:07.671Z","parentId":"495b5003-1cae-48ab-a3cf-299aebdbcd57"} +{"type":"tool.execution_complete","data":{"toolCallId":"call_B7mfLIxqUZJ0U7TPuq7AICf6","model":"mai-code-1.1-flash","interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a","turnId":"0","rte":true,"shellExecution":{"exitCode":0},"success":true,"result":{"content":"hello\n","detailedContent":"hello\n"},"toolTelemetry":{"properties":{"customTimeout":"true","executionMode":"sync","detached":"false","sandboxApplied":"false","sandboxOptOutRequested":"false"},"metrics":{"commandTimeout":30000}}},"id":"1998c4e2-5bc7-48ec-b25a-22e09e0b8c94","timestamp":"2026-09-26T00:24:07.676Z","parentId":"495b5003-1cae-48ab-a3cf-299aebdbcd57"} +{"type":"assistant.turn_end","data":{"turnId":"0"},"id":"5f5a4959-c817-4e68-b29b-393bc2489708","timestamp":"2026-09-26T00:24:07.681Z","parentId":"1998c4e2-5bc7-48ec-b25a-22e09e0b8c94"} +{"type":"assistant.turn_start","data":{"turnId":"1","interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a"},"id":"e637d527-fe9a-40a3-b686-7d351233ac5e","timestamp":"2026-09-26T00:24:07.682Z","parentId":"5f5a4959-c817-4e68-b29b-393bc2489708"} +{"type":"assistant.message","data":{"messageId":"ee78bdc4-8346-4970-95ed-de15d5b92dbb","originatingMessageId":"592e4a25-4edd-4138-8428-04377528629d","model":"mai-code-1.1-flash","content":"","toolRequests":[{"toolCallId":"call_KOZ6Yo6H2tFaGF8JSeHhROJ1","name":"bash","arguments":{"command":"cat /nonexistent-file","description":"Run the second required shell command to trigger the expected error","mode":"sync","initial_wait":10},"type":"function","intentionSummary":"Run the second required shell command to trigger the expected error"}],"interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a","turnId":"1","rte":true,"apiCallId":"KG3rWA5KnDXtL/Ftwooj+JjuuS+L+ah1aYHMcnKw9dFSwz3o2iOv3slDRYSqE5e2KrWgrIFsDtMAgiXlXahwtf8vnIpJgcRQrv2dJqpiPx955GxFNfsv0y+LitYKH69Iv+707wPPOfekR97bhzfXA2QGjna6+0FzEW/ZHT8LfAIfiyqai9XiXiOhZOTKVxAJ5xmJSZqDTtt8V+Ut2EL/3LCl19/wYTTF0YAHEjSovoQP19hx3RAqXCMhnJd1Uy4q4mlsNNvbGIPbcZwLrfNVTnVa9BV4mECvecH9IeJ9axMUZS/lA/jU3Da5VNCEtsXOYnhk6DX8tSNQLB+NYumqzmk2X+dUq2Wb3Y8W/MoL7c0//NSYqYDbRjLkEpaaKZYiibA/KFE5XVp48Gdd+cnzODhH1K4O39xTwAHjQlflj1s39qRqMRw6CL6tDf/frGwU","serverTools":{"provider":"openai-responses"}},"id":"64c89fe7-be35-41f2-9127-034874b52d95","timestamp":"2026-09-26T00:24:09.954Z","parentId":"e637d527-fe9a-40a3-b686-7d351233ac5e"} +{"type":"tool.execution_start","data":{"toolCallId":"call_KOZ6Yo6H2tFaGF8JSeHhROJ1","toolName":"bash","arguments":{"command":"cat /nonexistent-file","description":"Run the second required shell command to trigger the expected error","mode":"sync","initial_wait":10},"turnId":"1","model":"mai-code-1.1-flash","shellToolInfo":{"possiblePaths":[],"hasWriteFileRedirection":false}},"id":"a240e698-9aaa-43d3-bdb8-517399bb9c2a","timestamp":"2026-09-26T00:24:09.956Z","parentId":"64c89fe7-be35-41f2-9127-034874b52d95"} +{"type":"tool.execution_partial_result","data":{"toolCallId":"call_KOZ6Yo6H2tFaGF8JSeHhROJ1","partialOutput":"cat: /nonexistent-file: No such file or directory\n"},"ephemeral":true,"id":"554fa3fb-6bb0-4b8d-b2ec-723131f48064","timestamp":"2026-09-26T00:24:09.966Z","parentId":"a240e698-9aaa-43d3-bdb8-517399bb9c2a"} +{"type":"tool.execution_partial_result","data":{"toolCallId":"call_KOZ6Yo6H2tFaGF8JSeHhROJ1","partialOutput":"cat: /nonexistent-file: No such file or directory\n"},"ephemeral":true,"id":"94dae986-d597-40a5-831c-388182db7301","timestamp":"2026-09-26T00:24:09.966Z","parentId":"a240e698-9aaa-43d3-bdb8-517399bb9c2a"} +{"type":"tool.execution_complete","data":{"toolCallId":"call_KOZ6Yo6H2tFaGF8JSeHhROJ1","model":"mai-code-1.1-flash","interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a","turnId":"1","rte":true,"shellExecution":{"exitCode":1},"success":true,"result":{"content":"cat: /nonexistent-file: No such file or directory\n","detailedContent":"cat: /nonexistent-file: No such file or directory\n"},"toolTelemetry":{"properties":{"customTimeout":"true","executionMode":"sync","detached":"false","sandboxApplied":"false","sandboxOptOutRequested":"false","shell_error_category":"command_nonzero_exit"},"metrics":{"commandTimeout":30000,"exit_code":1}}},"id":"f22d0b04-9056-4d5c-b798-6a3eb26cc2b1","timestamp":"2026-09-26T00:24:09.971Z","parentId":"a240e698-9aaa-43d3-bdb8-517399bb9c2a"} +{"type":"assistant.turn_end","data":{"turnId":"1"},"id":"f823f0b3-33d8-4ca5-a111-733fa58c66e9","timestamp":"2026-09-26T00:24:09.975Z","parentId":"f22d0b04-9056-4d5c-b798-6a3eb26cc2b1"} +{"type":"assistant.turn_start","data":{"turnId":"2","interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a"},"id":"361e7d6b-7832-4137-9d71-b2ca66d90526","timestamp":"2026-09-26T00:24:09.975Z","parentId":"f823f0b3-33d8-4ca5-a111-733fa58c66e9"} +{"type":"assistant.message_start","data":{"messageId":"d92c3a5f-329a-4b84-8548-76a9f6acf6a9","phase":"final_answer"},"ephemeral":true,"id":"09bcf00a-0f8e-44c7-9539-98ac6b25f150","timestamp":"2026-09-26T00:24:11.613Z","parentId":"361e7d6b-7832-4137-9d71-b2ca66d90526"} +{"type":"assistant.message","data":{"messageId":"d92c3a5f-329a-4b84-8548-76a9f6acf6a9","originatingMessageId":"592e4a25-4edd-4138-8428-04377528629d","model":"mai-code-1.1-flash","content":"done","toolRequests":[],"interactionId":"6bd23866-01a9-4330-a002-3630c4c1fe7a","turnId":"2","phase":"final_answer","rte":true,"apiCallId":"HnNPE0K4S9Sfzu3aBEKNBu0bN71YXywM7Iou7HJYeGMBSegpo3BPJcfUERt8oGnSgEpfS5aEntUzNMfpuS91+3QbHxfDkApmOYcWeU/YXFlpQkgeT8bhYmNQ0g+Lpo7Zf45jMikQQ23xdX7r4zQHEXBud6cWLde+ujXNZ4Tc3mq1fPTvsa2Z4qD9gCRKwFksOqOQR4UeRuRRxIr2qWEXs61qj4xfH7BM0IAbm07zCyv6arLfHHhtbe/wXkv7fBWCbtQufB+KRW8Z5Wo+6peGgEi4x9ayQETTUG3K/q6nUY3wbHVquOI/UYHZewJFwPDfleQq2l6Okim8ftIIvoNfyvIy1GRDS/n/UnrUpDG1NNmgJDDcDIManTx9wpywEGR/K8gzfl98ddcd5N+6RC4G678wPu9AQef65ztQyKJB5jFLzkhI1LPc5+yTY0V8gZMA","serverTools":{"provider":"openai-responses"}},"id":"4657559f-58ec-4922-bed9-7fc89cdc7de9","timestamp":"2026-09-26T00:24:11.832Z","parentId":"361e7d6b-7832-4137-9d71-b2ca66d90526"} +{"type":"assistant.turn_end","data":{"turnId":"2"},"id":"b5ad8a1e-47f2-460b-ac09-0fe63f266271","timestamp":"2026-09-26T00:24:11.833Z","parentId":"4657559f-58ec-4922-bed9-7fc89cdc7de9"} +{"type":"assistant.idle","data":{},"ephemeral":true,"id":"1bcbd91f-9903-4b9a-8c22-cfea0d567a80","timestamp":"2026-09-26T00:24:11.838Z","parentId":"e800bf25-1659-4023-8e1c-55270f374526"} +{"type":"result","timestamp":"2026-09-26T00:24:11.847Z","sessionId":"bdf5531e-b8a4-4baf-bed2-d914242fa387","exitCode":0,"usage":{"premiumRequests":1,"totalApiDurationMs":6371,"sessionDurationMs":14653,"codeChanges":{"linesAdded":0,"linesRemoved":0,"filesModified":[]}}} diff --git a/internal/agentexec/testdata/omp/run.jsonl b/internal/agentexec/testdata/omp/run.jsonl new file mode 100644 index 000000000..7525bedda --- /dev/null +++ b/internal/agentexec/testdata/omp/run.jsonl @@ -0,0 +1,29 @@ +{"type":"session","version":3,"id":"01a0db18-e4a1-7000-9cbe-7467b0385e65","timestamp":"2026-09-26T00:23:56.833Z","cwd":"/tmp/hfx"} +{"type":"agent_start"} +{"type":"turn_start"} +{"type":"message_start","message":{"role":"user","content":[{"type":"text","text":"Run exactly these two shell commands, one at a time, then reply \"done\": 1) echo hello 2) cat /nonexistent-file"}],"attribution":"user","timestamp":1790382237281}} +{"type":"message_end","message":{"role":"user","content":[{"type":"text","text":"Run exactly these two shell commands, one at a time, then reply \"done\": 1) echo hello 2) cat /nonexistent-file"}],"attribution":"user","timestamp":1790382237281}} +{"type":"message_start","message":{"role":"assistant","content":[{"type":"thinking","thinking":"Simple","thinkingSignature":"reasoning_content"}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"stopReason":"stop","timestamp":1790382237472,"responseId":"065106e6-b09d-48f7-b6c6-e4e85fde221b"}} +{"type":"message_end","message":{"role":"assistant","content":[{"type":"thinking","thinking":"Simple: run echo hello, then cat /nonexistent-file. One at a time.","thinkingSignature":"reasoning_content"},{"type":"toolCall","id":"call_00_nr3UPjdQx9tkGIlERsCP4300","name":"bash","arguments":{"command":"echo hello","i":"Running echo hello"},"partialArgs":"{\"command\": \"echo hello\", \"i\": \"Running echo hello\"}","streamIndex":0,"intent":"Running echo hello"}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":25222,"output":75,"cacheRead":0,"cacheWrite":0,"totalTokens":25297,"reasoningTokens":19,"cost":{"input":0.0037833,"output":0.000044999999999999996,"cacheRead":0,"cacheWrite":0,"total":0.0038282999999999998}},"stopReason":"toolUse","timestamp":1790382237472,"responseId":"065106e6-b09d-48f7-b6c6-e4e85fde221b","duration":1472.9358650000001,"ttft":1164.486779,"completedAt":1790382238970}} +{"type":"tool_execution_start","toolCallId":"call_00_nr3UPjdQx9tkGIlERsCP4300","toolName":"bash","args":{"command":"echo hello"},"intent":"Running echo hello"} +{"type":"tool_execution_update","toolCallId":"call_00_nr3UPjdQx9tkGIlERsCP4300","toolName":"bash","args":{"command":"echo hello"},"partialResult":{"content":[{"type":"text","text":"hello\n"}],"details":{}}} +{"type":"tool_execution_update","toolCallId":"call_00_nr3UPjdQx9tkGIlERsCP4300","toolName":"bash","args":{"command":"echo hello"},"partialResult":{"content":[{"type":"text","text":"hello\n\n\nWall time: 0.03 seconds"}],"details":{"timeoutSeconds":300,"wallTimeMs":28.820365000000038}}} +{"type":"tool_execution_end","toolCallId":"call_00_nr3UPjdQx9tkGIlERsCP4300","toolName":"bash","result":{"content":[{"type":"text","text":"hello\n\n\nWall time: 0.03 seconds"}],"details":{"timeoutSeconds":300,"wallTimeMs":28.820365000000038}},"isError":false} +{"type":"message_start","message":{"role":"toolResult","toolCallId":"call_00_nr3UPjdQx9tkGIlERsCP4300","toolName":"bash","content":[{"type":"text","text":"hello\n\n\nWall time: 0.03 seconds"}],"details":{"timeoutSeconds":300,"wallTimeMs":28.820365000000038},"isError":false,"timestamp":1790382239011}} +{"type":"message_end","message":{"role":"toolResult","toolCallId":"call_00_nr3UPjdQx9tkGIlERsCP4300","toolName":"bash","content":[{"type":"text","text":"hello\n\n\nWall time: 0.03 seconds"}],"details":{"timeoutSeconds":300,"wallTimeMs":28.820365000000038},"isError":false,"timestamp":1790382239011}} +{"type":"turn_end","message":{"role":"assistant","content":[{"type":"thinking","thinking":"Simple: run echo hello, then cat /nonexistent-file. One at a time.","thinkingSignature":"reasoning_content"},{"type":"toolCall","id":"call_00_nr3UPjdQx9tkGIlERsCP4300","name":"bash","arguments":{"command":"echo hello","i":"Running echo hello"},"partialArgs":"{\"command\": \"echo hello\", \"i\": \"Running echo hello\"}","streamIndex":0,"intent":"Running echo hello"}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":25222,"output":75,"cacheRead":0,"cacheWrite":0,"totalTokens":25297,"reasoningTokens":19,"cost":{"input":0.0037833,"output":0.000044999999999999996,"cacheRead":0,"cacheWrite":0,"total":0.0038282999999999998}},"stopReason":"toolUse","timestamp":1790382237472,"responseId":"065106e6-b09d-48f7-b6c6-e4e85fde221b","duration":1472.9358650000001,"ttft":1164.486779},"toolResults":[{"role":"toolResult","toolCallId":"call_00_nr3UPjdQx9tkGIlERsCP4300","toolName":"bash","content":[{"type":"text","text":"hello\n\n\nWall time: 0.03 seconds"}],"details":{"timeoutSeconds":300,"wallTimeMs":28.820365000000038},"isError":false,"timestamp":1790382239011}]} +{"type":"turn_start"} +{"type":"message_start","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","name":"bash","arguments":{"command":"cat /nonexistent-file","i":"Reading nonexistent file"},"partialArgs":"{\"command\": \"cat /nonexistent-file\", \"i\": \"Reading nonexistent file\"}","streamIndex":0}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"stopReason":"stop","timestamp":1790382239018,"responseId":"d232767b-4ac0-4264-b166-1234dd27e949"}} +{"type":"message_end","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","name":"bash","arguments":{"command":"cat /nonexistent-file","i":"Reading nonexistent file"},"partialArgs":"{\"command\": \"cat /nonexistent-file\", \"i\": \"Reading nonexistent file\"}","streamIndex":0,"intent":"Reading nonexistent file"}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":231,"output":61,"cacheRead":25088,"cacheWrite":0,"totalTokens":25380,"cost":{"input":0.000034649999999999995,"output":0.000036599999999999995,"cacheRead":0.000075264,"cacheWrite":0,"total":0.000146514}},"stopReason":"toolUse","timestamp":1790382239018,"responseId":"d232767b-4ac0-4264-b166-1234dd27e949","duration":1915.5203490000004,"completedAt":1790382240956}} +{"type":"tool_execution_start","toolCallId":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","toolName":"bash","args":{"command":"cat /nonexistent-file"},"intent":"Reading nonexistent file"} +{"type":"tool_execution_update","toolCallId":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","toolName":"bash","args":{"command":"cat /nonexistent-file"},"partialResult":{"content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n"}],"details":{}}} +{"type":"tool_execution_update","toolCallId":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","toolName":"bash","args":{"command":"cat /nonexistent-file"},"partialResult":{"content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nWall time: 0.00 seconds\n\nCommand exited with code 1"}],"details":{"timeoutSeconds":300,"wallTimeMs":2.267550999999912,"exitCode":1}}} +{"type":"tool_execution_end","toolCallId":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","toolName":"bash","result":{"content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nWall time: 0.00 seconds\n\nCommand exited with code 1"}],"details":{"timeoutSeconds":300,"wallTimeMs":2.267550999999912,"exitCode":1},"isError":true},"isError":true} +{"type":"message_start","message":{"role":"toolResult","toolCallId":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","toolName":"bash","content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nWall time: 0.00 seconds\n\nCommand exited with code 1"}],"details":{"timeoutSeconds":300,"wallTimeMs":2.267550999999912,"exitCode":1},"isError":true,"timestamp":1790382240960}} +{"type":"message_end","message":{"role":"toolResult","toolCallId":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","toolName":"bash","content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nWall time: 0.00 seconds\n\nCommand exited with code 1"}],"details":{"timeoutSeconds":300,"wallTimeMs":2.267550999999912,"exitCode":1},"isError":true,"timestamp":1790382240960}} +{"type":"turn_end","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","name":"bash","arguments":{"command":"cat /nonexistent-file","i":"Reading nonexistent file"},"partialArgs":"{\"command\": \"cat /nonexistent-file\", \"i\": \"Reading nonexistent file\"}","streamIndex":0,"intent":"Reading nonexistent file"}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":231,"output":61,"cacheRead":25088,"cacheWrite":0,"totalTokens":25380,"cost":{"input":0.000034649999999999995,"output":0.000036599999999999995,"cacheRead":0.000075264,"cacheWrite":0,"total":0.000146514}},"stopReason":"toolUse","timestamp":1790382239018,"responseId":"d232767b-4ac0-4264-b166-1234dd27e949","duration":1915.5203490000004},"toolResults":[{"role":"toolResult","toolCallId":"call_00_ET_2IFtDySsuHmiOftiTqJg7979","toolName":"bash","content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nWall time: 0.00 seconds\n\nCommand exited with code 1"}],"details":{"timeoutSeconds":300,"wallTimeMs":2.267550999999912,"exitCode":1},"isError":true,"timestamp":1790382240960}]} +{"type":"turn_start"} +{"type":"message_start","message":{"role":"assistant","content":[{"type":"text","text":"done\n\n("}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"stopReason":"stop","timestamp":1790382240964,"responseId":"5183f0c3-4531-44b6-b80a-61b6290dfb22"}} +{"type":"message_end","message":{"role":"assistant","content":[{"type":"text","text":"done\n\n(2) exited 1: `cat: /nonexistent-file: No such file or directory`"}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":205,"output":25,"cacheRead":25216,"cacheWrite":0,"totalTokens":25446,"cost":{"input":0.000030749999999999995,"output":0.000014999999999999999,"cacheRead":0.000075648,"cacheWrite":0,"total":0.00012139799999999999}},"stopReason":"stop","timestamp":1790382240964,"responseId":"5183f0c3-4531-44b6-b80a-61b6290dfb22","duration":1189.6723079999992,"ttft":1106.6433019999995,"completedAt":1790382242178}} +{"type":"turn_end","message":{"role":"assistant","content":[{"type":"text","text":"done\n\n(2) exited 1: `cat: /nonexistent-file: No such file or directory`"}],"api":"openai-completions","provider":"deepseek","model":"deepseek-flash","usage":{"input":205,"output":25,"cacheRead":25216,"cacheWrite":0,"totalTokens":25446,"cost":{"input":0.000030749999999999995,"output":0.000014999999999999999,"cacheRead":0.000075648,"cacheWrite":0,"total":0.00012139799999999999}},"stopReason":"stop","timestamp":1790382240964,"responseId":"5183f0c3-4531-44b6-b80a-61b6290dfb22","duration":1189.6723079999992,"ttft":1106.6433019999995},"toolResults":[]} +{"type":"agent_end","messages":[],"isTerminal":true} diff --git a/internal/agentexec/testdata/pi/run.jsonl b/internal/agentexec/testdata/pi/run.jsonl new file mode 100644 index 000000000..885e6dfe0 --- /dev/null +++ b/internal/agentexec/testdata/pi/run.jsonl @@ -0,0 +1,30 @@ +{"type":"session","version":3,"id":"01a0db18-e183-7432-9e4b-4b16bfc83856","timestamp":"2026-09-26T00:23:56.037Z","cwd":"/tmp/hfx"} +{"type":"agent_start"} +{"type":"turn_start"} +{"type":"message_start","message":{"role":"user","content":[{"type":"text","text":"Run exactly these two shell commands, one at a time, then reply \"done\": 1) echo hello 2) cat /nonexistent-file"}],"timestamp":1790382237711}} +{"type":"message_end","message":{"role":"user","content":[{"type":"text","text":"Run exactly these two shell commands, one at a time, then reply \"done\": 1) echo hello 2) cat /nonexistent-file"}],"timestamp":1790382237711}} +{"type":"message_start","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_4w3gr4ma","name":"bash","arguments":{"command":"echo hello"},"partialArgs":"{\"command\":\"echo hello\"}","streamIndex":0}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"stopReason":"pending","timestamp":1790382237724,"responseId":"chatcmpl-176"}} +{"type":"message_end","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_4w3gr4ma","name":"bash","arguments":{"command":"echo hello"}}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":36426,"output":12,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":36438,"cost":{"input":0.0054639,"output":0.000006,"cacheRead":0,"cacheWrite":0,"total":0.0054699}},"stopReason":"toolUse","timestamp":1790382237724,"responseId":"chatcmpl-176","rawStopReason":"tool_calls"}} +{"type":"tool_execution_start","toolCallId":"call_4w3gr4ma","toolName":"bash","args":{"command":"echo hello"}} +{"type":"tool_execution_update","toolCallId":"call_4w3gr4ma","toolName":"bash","args":{"command":"echo hello"},"partialResult":{"content":[]}} +{"type":"tool_execution_update","toolCallId":"call_4w3gr4ma","toolName":"bash","args":{"command":"echo hello"},"partialResult":{"content":[{"type":"text","text":"hello\n"}],"details":{}}} +{"type":"tool_execution_end","toolCallId":"call_4w3gr4ma","toolName":"bash","result":{"content":[{"type":"text","text":"hello\n"}]},"isError":false} +{"type":"message_start","message":{"role":"toolResult","toolCallId":"call_4w3gr4ma","toolName":"bash","content":[{"type":"text","text":"hello\n"}],"isError":false,"timestamp":1790382240554}} +{"type":"message_end","message":{"role":"toolResult","toolCallId":"call_4w3gr4ma","toolName":"bash","content":[{"type":"text","text":"hello\n"}],"isError":false,"timestamp":1790382240554}} +{"type":"turn_end","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_4w3gr4ma","name":"bash","arguments":{"command":"echo hello"}}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":36426,"output":12,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":36438,"cost":{"input":0.0054639,"output":0.000006,"cacheRead":0,"cacheWrite":0,"total":0.0054699}},"stopReason":"toolUse","timestamp":1790382237724,"responseId":"chatcmpl-176","rawStopReason":"tool_calls"},"toolResults":[{"role":"toolResult","toolCallId":"call_4w3gr4ma","toolName":"bash","content":[{"type":"text","text":"hello\n"}],"isError":false,"timestamp":1790382240554}]} +{"type":"turn_start"} +{"type":"message_start","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_cta082t7","name":"bash","arguments":{"command":"cat /nonexistent-file"},"partialArgs":"{\"command\":\"cat /nonexistent-file\"}","streamIndex":0}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"stopReason":"pending","timestamp":1790382240561,"responseId":"chatcmpl-207"}} +{"type":"message_end","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_cta082t7","name":"bash","arguments":{"command":"cat /nonexistent-file"}}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":5007,"output":15,"cacheRead":31360,"cacheWrite":0,"reasoning":0,"totalTokens":36382,"cost":{"input":0.00075105,"output":0.000007499999999999999,"cacheRead":0,"cacheWrite":0,"total":0.00075855}},"stopReason":"toolUse","timestamp":1790382240561,"responseId":"chatcmpl-207","rawStopReason":"tool_calls"}} +{"type":"tool_execution_start","toolCallId":"call_cta082t7","toolName":"bash","args":{"command":"cat /nonexistent-file"}} +{"type":"tool_execution_update","toolCallId":"call_cta082t7","toolName":"bash","args":{"command":"cat /nonexistent-file"},"partialResult":{"content":[]}} +{"type":"tool_execution_update","toolCallId":"call_cta082t7","toolName":"bash","args":{"command":"cat /nonexistent-file"},"partialResult":{"content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n"}],"details":{}}} +{"type":"tool_execution_end","toolCallId":"call_cta082t7","toolName":"bash","result":{"content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nCommand exited with code 1"}],"details":{}},"isError":true} +{"type":"message_start","message":{"role":"toolResult","toolCallId":"call_cta082t7","toolName":"bash","content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nCommand exited with code 1"}],"details":{},"isError":true,"timestamp":1790382242598}} +{"type":"message_end","message":{"role":"toolResult","toolCallId":"call_cta082t7","toolName":"bash","content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nCommand exited with code 1"}],"details":{},"isError":true,"timestamp":1790382242598}} +{"type":"turn_end","message":{"role":"assistant","content":[{"type":"toolCall","id":"call_cta082t7","name":"bash","arguments":{"command":"cat /nonexistent-file"}}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":5007,"output":15,"cacheRead":31360,"cacheWrite":0,"reasoning":0,"totalTokens":36382,"cost":{"input":0.00075105,"output":0.000007499999999999999,"cacheRead":0,"cacheWrite":0,"total":0.00075855}},"stopReason":"toolUse","timestamp":1790382240561,"responseId":"chatcmpl-207","rawStopReason":"tool_calls"},"toolResults":[{"role":"toolResult","toolCallId":"call_cta082t7","toolName":"bash","content":[{"type":"text","text":"cat: /nonexistent-file: No such file or directory\n\n\nCommand exited with code 1"}],"details":{},"isError":true,"timestamp":1790382242598}]} +{"type":"turn_start"} +{"type":"message_start","message":{"role":"assistant","content":[{"type":"thinking","thinking":"Both","thinkingSignature":"reasoning"}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"stopReason":"pending","timestamp":1790382242606,"responseId":"chatcmpl-491"}} +{"type":"message_end","message":{"role":"assistant","content":[{"type":"thinking","thinking":"Both commands run. Reply \"done\".","thinkingSignature":"reasoning"},{"type":"text","text":"done"}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":5045,"output":11,"cacheRead":31360,"cacheWrite":0,"reasoning":0,"totalTokens":36416,"cost":{"input":0.0007567499999999999,"output":0.0000055,"cacheRead":0,"cacheWrite":0,"total":0.0007622499999999999}},"stopReason":"stop","timestamp":1790382242606,"responseId":"chatcmpl-491","rawStopReason":"stop"}} +{"type":"turn_end","message":{"role":"assistant","content":[{"type":"thinking","thinking":"Both commands run. Reply \"done\".","thinkingSignature":"reasoning"},{"type":"text","text":"done"}],"api":"openai-completions","provider":"ollama-cloud","model":"glm-5.3-flash","usage":{"input":5045,"output":11,"cacheRead":31360,"cacheWrite":0,"reasoning":0,"totalTokens":36416,"cost":{"input":0.0007567499999999999,"output":0.0000055,"cacheRead":0,"cacheWrite":0,"total":0.0007622499999999999}},"stopReason":"stop","timestamp":1790382242606,"responseId":"chatcmpl-491","rawStopReason":"stop"},"toolResults":[]} +{"type":"agent_end","messages":[],"willRetry":false} +{"type":"agent_settled"}