Skip to content

fix: create tool cards when scheduled events are missing - #82

Merged
william0wang merged 1 commit into
william0wang:mainfrom
guanbear:fix/tool-lifecycle-without-scheduled
Aug 31, 2026
Merged

fix: create tool cards when scheduled events are missing#82
william0wang merged 1 commit into
william0wang:mainfrom
guanbear:fix/tool-lifecycle-without-scheduled

Conversation

@guanbear

Copy link
Copy Markdown
Contributor

Summary

  • create ToolCallNew from the first observed tool lifecycle event instead of
    requiring tool.updated { kind: "scheduled" }
  • recover tool name/input from the cached model.streaming { kind: "tool_call" }
    payload when later lifecycle events omit them
  • preserve seenToolIds deduplication so a late scheduled event cannot create
    a duplicate card
  • emit a best-effort in-progress card before a first-seen terminal result/error,
    preserving the existing completion and Bash terminal-exit paths

Fixes #81.

Why

ZCode runtime 0.16.5 was observed emitting started and result for a
foreground Bash call without a scheduled event. The bridge therefore sent
only tool_call_update notifications. ACP clients had no active tool card
while the process was running and later received an orphan completion.

The regression tests drive the translator directly with that captured event
ordering. Before this change they fail because the first event is
ToolCallUpdate; after this change the lifecycle is:

started without scheduled
  -> ToolCallNew(in_progress)

result without any prior lifecycle event
  -> ToolCallNew(in_progress)
  -> ToolCallUpdate(completed)

Test plan

./node_modules/.bin/vitest run tests/event-translator.test.ts
./node_modules/.bin/vitest run
./node_modules/.bin/tsc --noEmit
./node_modules/.bin/eslint src/translators/event-translator.ts tests/event-translator.test.ts
./node_modules/.bin/tsc

Results locally:

  • EventTranslator: 22/22 passed
  • Full suite: 794/794 passed
  • Typecheck, ESLint, and build passed

Scope

This PR does not change turn timeout or stale-projection policy from #80. It
only repairs ACP tool lifecycle ordering at the translator boundary.

@william0wang
william0wang merged commit a6420bd into william0wang:main Aug 31, 2026
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.

Tool updates can be orphaned when the scheduled lifecycle event is missing

2 participants