Skip to content

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

Description

@rz1989s

Dogfood finding (2026-08-08, SPEC-6-5 T1 build)

#49 (PR #50) added a filesTouched[] to the structured partial-result on turn-budget exhaustion. Dogfooding it during the SPEC-6-5 T1 build revealed it does NOT work end-to-end on real edit tool calls — the unit tests passed but the real SDK event shape differs.

Evidence

The T1 implementer run fl-msnbley6-a7gs2f (archived) used 2 × edit + 13 × bash + 3 × read tool calls and modified 17 files. The turn-budget partial result reported:

Files modified before the cut: (none detected)

And the run:ended journal event has NO filesTouched field:

{"type":"run:ended","runId":"fl-msnbley6-a7gs2f","status":"failed","endedAt":...,"resultSummary":"...","tokenTotal":11425494,"costTotal":0,"contextTokens":0}

Root cause (two-fold)

  1. The edit tool event's args is serialized as "" in the run-log tool event. The logged edit events show:

    {"type":"tool","toolName":"edit","args":"","result":"{\"content\":[{\"type\":\"text\",\"text\":\"Successfully replaced 1 block(s) in /Users/.../test/spawnSubagent.test.mts\"}]}..."}

    The file path is in the result text ("Successfully replaced 1 block(s) in /Users/.../test/spawnSubagent.test.mts"), NOT in args (which is empty). subagent: turn-budget exhaustion on multi-step tasks leaves inconsistent multi-file state; partial-result report doesn't surface what's pending #49's extractTouchedFiles reads args (the path arg) — empty args → no path extracted → filesTouched stays empty. The real SDK's tool_execution_end event for edit doesn't carry the args in the field subagent: turn-budget exhaustion on multi-step tasks leaves inconsistent multi-file state; partial-result report doesn't surface what's pending #49 reads (or buildToolEvent serializes them as empty).

  2. run:ended has no filesTouched field on the turn-budget-failed path. finishRun on the turn-budget branch apparently doesn't pass filesTouchedList into the run:ended event the RunLog writes (the event above has no filesTouched key at all). The SpawnResult / subagent tool details may carry it (unverified), but the durable journal — the thing the Runs tab + a controller reads post-hoc — doesn't.

(Side note: contextTokens: 0 on that run:ended is also suspicious for an 18-tool run — separate concern, possibly the turn-budget path didn't process a message_end, but worth a look.)

Impact

The #49 feature's whole point — "the controller re-inspects only what changed after a turn-budget cut, instead of the whole repo" — is defeated: filesTouched is empty on real edit-driven runs. The controller (me, dogfooding) had to git diff the whole repo to salvage the cutoff, exactly the friction #49 was meant to eliminate. This is the dogfood-gotcha-#6 pattern: unit tests with a mocked event shape pass, but the real SDK event shape differs.

Proposed fix (bug)

  1. extractTouchedFiles for edit/write: the path isn't in args — parse it from the result text ("Successfully replaced 1 block(s) in " / "wrote ") OR fix buildToolEvent to serialize the real args (the edit tool's path/edits payload) instead of "". Likely the latter is the real bug — buildToolEvent should capture args properly. Investigate why args is empty in the logged tool event (is (e as any).args undefined on the real SDK event? the mock provided it).
  2. run:ended filesTouched: thread filesTouchedList into the run:ended RunLog event on the turn-budget path (and all terminal paths), not just the SpawnResult/details.
  3. Integration test: add a test that drives a REAL edit tool call (not a mocked event with a hand-rolled args) and asserts filesTouched is populated end-to-end through the journal. The current unit tests assert against a mocked event shape that doesn't match the SDK.

Repro: dispatch a subagent that edits a file + hits the turn budget; read the run:ended event — filesTouched is absent.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions