Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
{"ts":1787347885004,"run":1787347884248,"seq":10.181818181818182,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"item.open\",\"key\":{\"providerItemId\":\"call_3QgildbOHVjGT66p1suULaki|fc_09c945c948332c68016a88c3ae95cc87d0807292b80067b702\"},\"item\":{\"type\":\"tool\",\"tool\":\"read\",\"args\":{\"path\":\"math.js\"}},\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_start\",\"toolCallId\":\"call_3QgildbOHVjGT66p1suULaki|fc_09c945c948332c68016a88c3ae95cc87d0807292b80067b702\",\"toolName\":\"read\",\"args\":{\"path\":\"math.js\"}}}},\"rawType\":\"sdk/tool_execution_start\"}}]}}"}
{"ts":1787347885005,"run":1787347884248,"seq":10.227272727272727,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"item.close\",\"key\":{\"providerItemId\":\"call_3QgildbOHVjGT66p1suULaki|fc_09c945c948332c68016a88c3ae95cc87d0807292b80067b702\"},\"status\":\"completed\",\"resultText\":\"export function add(a, b) {\\n return a + b;\\n}\\n\",\"exitCode\":0,\"item\":{\"type\":\"tool\",\"tool\":\"read\",\"args\":{\"path\":\"math.js\"}},\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_end\",\"toolCallId\":\"call_3QgildbOHVjGT66p1suULaki|fc_09c945c948332c68016a88c3ae95cc87d0807292b80067b702\",\"toolName\":\"read\",\"result\":{\"content\":[{\"type\":\"text\",\"text\":\"export function add(a, b) {\\n return a + b;\\n}\\n\"}]},\"isError\":false}}},\"rawType\":\"sdk/tool_execution_end\"}}]}}"}
{"ts":1787347885006,"run":1787347884248,"seq":10.272727272727273,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"contextWindow\",\"used\":3546,\"size\":272000,\"estimated\":true,\"attach\":\"currentOrLast\"}]}}"}
{"ts":1787347885007,"run":1787347884248,"seq":10.318181818181818,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"item.open\",\"key\":{\"providerItemId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\"},\"item\":{\"type\":\"fileChange\",\"changes\":[{\"path\":\"math.js\",\"kind\":\"add\"}]},\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_start\",\"toolCallId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\",\"toolName\":\"edit\",\"args\":{\"path\":\"math.js\",\"edits\":[{\"oldText\":\"export function add(a, b) {\\n return a + b;\\n}\\n\",\"newText\":\"export function add(a, b) {\\n return a + b;\\n}\\n\\nexport function subtract(a, b) {\\n return a - b;\\n}\\n\"}]}}}},\"rawType\":\"sdk/tool_execution_start\"}}]}}"}
{"ts":1787347885008,"run":1787347884248,"seq":10.363636363636363,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"item.close\",\"key\":{\"providerItemId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\"},\"status\":\"completed\",\"resultText\":\"Successfully replaced 1 block(s) in math.js.\",\"exitCode\":0,\"item\":{\"type\":\"fileChange\",\"changes\":[{\"path\":\"math.js\",\"kind\":\"add\"}]},\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_end\",\"toolCallId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\",\"toolName\":\"edit\",\"result\":{\"content\":[{\"type\":\"text\",\"text\":\"Successfully replaced 1 block(s) in math.js.\"}],\"details\":{\"diff\":\" 1 export function add(a, b) {\\n 2 return a + b;\\n 3 }\\n+4 \\n+5 export function subtract(a, b) {\\n+6 return a - b;\\n+7 }\",\"patch\":\"--- math.js\\n+++ math.js\\n@@ -1,3 +1,7 @@\\n export function add(a, b) {\\n return a + b;\\n }\\n+\\n+export function subtract(a, b) {\\n+ return a - b;\\n+}\\n\",\"firstChangedLine\":4}},\"isError\":false}}},\"rawType\":\"sdk/tool_execution_end\"}}]}}"}
{"ts":1787347885007,"run":1787347884248,"seq":10.318181818181818,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"item.open\",\"key\":{\"providerItemId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\"},\"item\":{\"type\":\"fileChange\",\"changes\":[{\"path\":\"math.js\",\"kind\":\"update\"}]},\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_start\",\"toolCallId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\",\"toolName\":\"edit\",\"args\":{\"path\":\"math.js\",\"edits\":[{\"oldText\":\"export function add(a, b) {\\n return a + b;\\n}\\n\",\"newText\":\"export function add(a, b) {\\n return a + b;\\n}\\n\\nexport function subtract(a, b) {\\n return a - b;\\n}\\n\"}]}}}},\"rawType\":\"sdk/tool_execution_start\"}}]}}"}
{"ts":1787347885008,"run":1787347884248,"seq":10.363636363636363,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"item.close\",\"key\":{\"providerItemId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\"},\"status\":\"completed\",\"resultText\":\"Successfully replaced 1 block(s) in math.js.\",\"exitCode\":0,\"item\":{\"type\":\"fileChange\",\"changes\":[{\"path\":\"math.js\",\"kind\":\"update\"}]},\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_end\",\"toolCallId\":\"call_wawtqW4IaZ4neYkDnjgiA3RK|fc_09c945c948332c68016a88c3b065f087d0a620114e3315fc05\",\"toolName\":\"edit\",\"result\":{\"content\":[{\"type\":\"text\",\"text\":\"Successfully replaced 1 block(s) in math.js.\"}],\"details\":{\"diff\":\" 1 export function add(a, b) {\\n 2 return a + b;\\n 3 }\\n+4 \\n+5 export function subtract(a, b) {\\n+6 return a - b;\\n+7 }\",\"patch\":\"--- math.js\\n+++ math.js\\n@@ -1,3 +1,7 @@\\n export function add(a, b) {\\n return a + b;\\n }\\n+\\n+export function subtract(a, b) {\\n+ return a - b;\\n+}\\n\",\"firstChangedLine\":4}},\"isError\":false}}},\"rawType\":\"sdk/tool_execution_end\"}}]}}"}
{"ts":1787347885009,"run":1787347884248,"seq":10.409090909090908,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"contextWindow\",\"used\":3656,\"size\":272000,\"estimated\":true,\"attach\":\"currentOrLast\"}]}}"}
{"ts":1787347885010,"run":1787347884248,"seq":10.454545454545455,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"item.open\",\"key\":{\"providerItemId\":\"call_WvPlJkWmGzqSANq2hX6wgubH|fc_09c945c948332c68016a88c3b2c3a487d0b31e55957fcd3985\"},\"item\":{\"type\":\"command\",\"command\":\"node -e \\\"import(\\\\\\\"./math.js\\\\\\\").then(m => console.log(m.subtract(5, 3)))\\\"\",\"cwd\":\"/tmp/bb-recording-ws\"},\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_start\",\"toolCallId\":\"call_WvPlJkWmGzqSANq2hX6wgubH|fc_09c945c948332c68016a88c3b2c3a487d0b31e55957fcd3985\",\"toolName\":\"bash\",\"args\":{\"command\":\"node -e \\\"import(\\\\\\\"./math.js\\\\\\\").then(m => console.log(m.subtract(5, 3)))\\\"\"}}}},\"rawType\":\"sdk/tool_execution_start\"}}]}}"}
{"ts":1787347885011,"run":1787347884248,"seq":10.5,"dir":"bridge→runtime","line":"{\"jsonrpc\":\"2.0\",\"method\":\"thread/delta\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"deltas\":[{\"kind\":\"command.outputSnapshot\",\"key\":{\"providerItemId\":\"call_WvPlJkWmGzqSANq2hX6wgubH|fc_09c945c948332c68016a88c3b2c3a487d0b31e55957fcd3985\"},\"text\":\"2\\n\",\"noTurnFallback\":{\"raw\":{\"jsonrpc\":\"2.0\",\"method\":\"sdk/message\",\"params\":{\"threadId\":\"thr_xc2ssvyvdk\",\"message\":{\"type\":\"tool_execution_update\",\"toolCallId\":\"call_WvPlJkWmGzqSANq2hX6wgubH|fc_09c945c948332c68016a88c3b2c3a487d0b31e55957fcd3985\",\"toolName\":\"bash\",\"partialResult\":{\"content\":[{\"type\":\"text\",\"text\":\"2\\n\"}],\"details\":{}},\"args\":{\"command\":\"node -e \\\"import(\\\\\\\"./math.js\\\\\\\").then(m => console.log(m.subtract(5, 3)))\\\"\"}}}},\"rawType\":\"sdk/tool_execution_update\"}}]}}"}
Expand Down
25 changes: 25 additions & 0 deletions plugins/provider-pi/src/delta-translation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,31 @@ describe("pi delta translation equivalence", () => {
);
});

it("tool_execution_start with edit batch args marks the change as an update", () => {
const harness = createHarness();
harness.translate(loadFixture("agent-start.json"));

const events = harness.translate({
type: "tool_execution_start",
toolCallId: "tool-edit-batch",
toolName: "edit",
args: {
path: "src/app.ts",
edits: [{ oldText: "before", newText: "after" }],
},
} as AgentSessionEvent);

const started = events.find(
(event): event is Extract<ThreadEvent, { type: "item/started" }> =>
event.type === "item/started",
);
expect(started?.item).toMatchObject({
type: "fileChange",
status: "pending",
changes: [{ path: "src/app.ts", kind: "update" }],
});
});

it("tool_execution_start with content-only write args marks the change as an add", () => {
const harness = createHarness();
harness.translate(loadFixture("agent-start.json"));
Expand Down
5 changes: 4 additions & 1 deletion plugins/provider-pi/src/delta-translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ function classifyPiToolUse(
changes: [
{
path: parsed.data.path,
kind: parsed.data.oldText === undefined ? "add" : "update",
kind:
toolName === "edit" || parsed.data.oldText !== undefined
? "update"
: "add",
...(parsed.data.oldText === undefined
? {}
: { oldText: parsed.data.oldText }),
Expand Down
Loading