fix(spawn): capture tool args from tool_execution_start + journal filesTouched (#60) - #72
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 therun:endedjournal event had nofilesTouchedfield at all.Root cause (confirmed against the SDK)
The pi SDK's
tool_execution_endevent carries{ toolCallId, toolName, result, isError }— noargs. Onlytool_execution_startcarries args. The engine reade.argsoff the end event (alwaysundefinedon real runs):extractTouchedFilesgotundefined→ no paths →filesTouchedempty;buildToolEventstringifiedundefined→ the journal's tool events showedargs: "".The unit tests passed because their fake children put args on the end event — the exact "mocked shape ≠ SDK shape" dogfood pattern.
Changes
spawnSubagentcaptures args pertoolCallIdattool_execution_startand uses them on the end event (?? e.argsfallback keeps hand-rolled fakes working).run:endednow journalsfilesTouched(previously SpawnResult-only — the durable journal a controller reads post-hoc lacked it).RunEndedEventgainsfilesTouched?.Tests
filesTouchedpopulated from the start event's args + journal tool event carries the real path (was"").SpawnResult.filesTouched+run:ended.filesTouchedboth populated.pnpm typecheckclean.Closes #60