Skip to content

fix(spawn): capture tool args from tool_execution_start + journal filesTouched (#60) - #72

Merged
rz1989s merged 1 commit into
mainfrom
fix/60-tool-args-capture
Aug 29, 2026
Merged

rz1989s merged 1 commit into
mainfrom
fix/60-tool-args-capture

Conversation

@rz1989s

@rz1989s rz1989s commented Aug 29, 2026

Copy link
Copy Markdown
Member

Problem (#60#49 regression)

filesTouched (#49's structured partial-result) was empty on real edit-tool runs despite passing unit tests. The archived T1 run (2 edits + 13 bash calls, 17 files modified) reported "(none detected)", and the run:ended journal event had no filesTouched field at all.

Root cause (confirmed against the SDK)

The pi SDK's tool_execution_end event carries { toolCallId, toolName, result, isError }no args. Only tool_execution_start carries args. The engine read e.args off the end event (always undefined on real runs):

  • extractTouchedFiles got undefined → no paths → filesTouched empty;
  • buildToolEvent stringified undefined → the journal's tool events showed args: "".
    The unit tests passed because their fake children put args on the end event — the exact "mocked shape ≠ SDK shape" dogfood pattern.

Changes

  • spawnSubagent captures args per toolCallId at tool_execution_start and uses them on the end event (?? e.args fallback keeps hand-rolled fakes working).
  • run:ended now journals filesTouched (previously SpawnResult-only — the durable journal a controller reads post-hoc lacked it). RunEndedEvent gains filesTouched?.

Tests

  • Real SDK event pair (start with args, end without) on a completed run: filesTouched populated from the start event's args + journal tool event carries the real path (was "").
  • Turn-budget cut: SpawnResult.filesTouched + run:ended.filesTouched both populated.
  • 722/722 pass, pnpm typecheck clean.

Closes #60

…esTouched

#60 (#49 regression): the pi SDK's tool_execution_end carries NO args
({toolCallId, toolName, result, isError}) - only tool_execution_start
does. The engine read args off the END event, so on real runs
filesTouched stayed empty (edit path never extracted) and the journal
serialized args as '' - exactly the 'unit tests pass, real shape
differs' dogfood pattern. The archived T1 run (2 edits, 17 files) named
'(none detected)'.

- spawnSubagent captures args per toolCallId at tool_execution_start
  and uses them on the end event (?? e.args keeps hand-rolled fakes
  that put args on end working).
- run:ended now carries filesTouched (was SpawnResult-only; the durable
  journal - what a controller reads post-hoc - lacked it).
- RunEndedEvent: filesTouched?.

Tests drive the REAL SDK event pair (start with args, end without) on
both a completed run and a turn-budget cut.
@rz1989s
rz1989s merged commit 51cb6a9 into main Aug 29, 2026
1 check passed
@rz1989s
rz1989s deleted the fix/60-tool-args-capture branch August 29, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#49 regression: filesTouched empty on real edit-tool runs — args serialized as empty, run:ended missing the field

1 participant