Skip to content

feat(observe): tool_call_input carries arguments ACP runtimes send after a call starts - #148

Merged
xxchan merged 2 commits into
mainfrom
tool-call-input
Oct 6, 2026
Merged

xxchan merged 2 commits into
mainfrom
tool-call-input

Conversation

@xxchan

@xxchan xxchan commented Oct 6, 2026

Copy link
Copy Markdown
Member

What

Some ACP runtimes send a tool call's real arguments only in a later tool_call_update. opencode opens a shell call with rawInput {cwd} and a file call with {}. kimi opens with no rawInput at all. tool_call_started.input was read only from the opening frame, so hosts never saw the command or the file path. Ferry showed bash {"cwd":"/tmp/x"} and read {}.

Closes #147.

Evidence (opencode 1.18.30 through Ferry, oar 0.23.0):

tool_call         title "bash"  kind execute  status pending      rawInput {"cwd":"/tmp/x"}
tool_call_update  title "echo hi > a.txt && cat a.txt"  status in_progress  rawInput {"command":"echo hi > a.txt && cat a.txt","cwd":"/tmp/x"}
tool_call         title "read"  kind read     status pending      rawInput {}
tool_call_update  title "read"  status in_progress  rawInput {"filePath":"/tmp/x/a.txt"}

Shape (as agreed in #147)

  • New event { kind: "tool_call_input"; callId: string; input: string } in RuntimeEventBody. It holds arguments the runtime reported after the call started. It is the WHOLE input, in the same form as tool_call_started.input (a string, JSON for ACP), and replaces the previous input. It is never a delta.
  • Emitted in the shared ACP projection. No runtime-specific code. The per-call state remembers the input last reported. A tool_call_update whose rawInput differs from it emits tool_call_input. An identical input is not emitted again. If the ending frame carries a new rawInput, tool_call_input comes before tool_call_ended. Nothing is read after the end. A running update with both a new input and rawOutput gives the input, then the progress.
  • tool_call_started is unchanged. It is not delayed and not rewritten.
  • The session view's tool part input takes the latest input. An input whose start was never seen renders as a ? part, like an end without a start. classifyTool gets the latest input through the view (and groupToolActivity, which reads the view).
  • kimi is fixed too. Its full rawInput ({command}) arrives in one later frame. The partial-JSON content chunks before it are still not read.
  • Other consumers handle the new kind:
    • the status fold treats it like tool_call_progress: the phase stays, the clock moves;
    • oar run prints the detail the new input adds, once, e.g. [Running command], then [Running command] echo hi > a.txt && cat a.txt.

classifyTool

Every entry comes from a recording. <key> placeholders are used as in #139.

runtime tool kind fields recording
opencode bash run_command (unchanged) command (new) opencode-acp-v1.vendor.json, tools[1]: {command, cwd}; opencode-acp-v1-files.vendor.json: {command, workdir}
opencode read read_file detail filePath opencode-acp-v1-files.vendor.json: {filePath}
opencode write edit_file detail filePath same: {content, filePath}
opencode edit edit_file detail filePath same: {filePath, newString, oldString}
opencode grep search detail path same: {path, pattern}
opencode glob search detail path same: {path, pattern}
kimi Bash run_command (unchanged) command (new) kimi-acp-v1.vendor.json, tools[2]: {command}

New recording. opencode's file tools had none. experiments/acp-vendor-snapshot.ts gains a files scenario: write, read, edit, grep, glob, then a shell cat, run in a scratch directory whose path is replaced by <cwd> in titles. It was recorded from opencode 1.18.30 (free opencode/big-pickle, no login) into tests/replay/fixtures/opencode-acp-v1-files.vendor.json.

Not added:

  • description for opencode bash. ACP view drops tool input that arrives in tool_call_update (opencode, kimi) #147 suggested it "if present", but no recording carries it (Ferry {command, cwd}, the shell fixture {command, cwd}, the files fixture {command, workdir}). It can follow once one does.
  • For grep / glob, the detail is the directory, not the pattern. This comes from the existing shared key order in detailOf (path before pattern, same as pi's and claude's grep). I left it alone.

Compatibility

RuntimeEventBody (and so EventBody / Event) gains a member. A host that switches exhaustively over event kinds (switch (event.kind) with a never check or switch-exhaustiveness-check) stops compiling until it handles tool_call_input. For release notes: ignoring it is safe, but then the host only shows the first input. A host that renders from viewOf / reduceSessionView gets the latest input with no change.

In this repo, the exhaustive switches over event kinds are all updated: observe/agent-status.ts, observe/session-view-events.ts, cli/src/progress.ts, and the test describers in tests/fixtures/acp-session-support.ts, tests/replay/claude-projection.test.ts, tests/replay/codex-projection.test.ts. Lint's switch-exhaustiveness-check found them.

Records written before this have no tool_call_input, so a replayed old log shows what it showed before.

Tests

  • tests/acp/acp-tool-input.test.ts (projection):
    • no or partial input at start, then supplied later (opencode's bash and read frames from the evidence, plus kimi's no-rawInput shape);
    • identical input not emitted again (equal to the start, or repeated);
    • ending frame with a new input: tool_call_input, then tool_call_ended, and nothing after the end;
    • running frame with input and output: input, then progress.
  • tests/acp/acp-kimi-wire-shapes.test.ts: kimi's late rawInput (0.42.0 frames) is now a tool_call_input. The started record is unchanged.
  • tests/tool-call-input.test.ts: the view's tool part takes the latest input and keeps its state, and an input without a start renders. The status fold keeps the tool phase and moves the clock.
  • tests/cli-progress.test.ts: oar run prints the detail a later input adds, once.
  • tests/replay/tool-activity.test.ts: the kimi and opencode fixtures now run through the projection AND viewOf. The activity snapshots changed as expected:
    • kimi-acp-v1.activity.txt: Bash │ Running command → Bash │ Running command: <command>
    • opencode-acp-v1.activity.txt: bash │ Running command → bash │ Running command: <command>
    • new opencode-acp-v1-files.activity.txt: Editing file: <filePath>, Reading file: <filePath>, Searching: <path>, Running command: <command>
    • grok's is unchanged. Its update adds is_background and variant, which now arrive as a tool_call_input; the classification stays the same.
    • inline snapshots pin each call's started and latest input and its ToolAction.

Verification:

  • CI=1 pnpm run check is green: typecheck, lint, 669 passed / 31 skipped, mock sea-trial 19/19.
  • pnpm run build passes.
  • pnpm tsx sea-trial/all.ts: mock, claude-aimock, codex-aimock and pi-aimock all clean.
  • OAR_TEST=opencode pnpm sea-trial: 19/19 on real opencode 1.18.30.
  • Ad-hoc oar run opencode with bash, read, edit and grep: each call got a tool_call_input on its first in-progress update and none on repeats, and the CLI printed the command and the file paths.

Docs

  • docs/spec/record-stream.md: a rule for the latest input, tool_call_input in the event list, and which runtimes emit it.
  • docs/design/chat-ui.md: the events → view mapping row.
  • docs/runtimes/kimi.md, docs/runtimes/opencode.md: the "no command" paragraphs now describe the new behaviour, with opencode's recorded input keys per tool. docs/runtimes/grok.md: a note on its later rawInput.
  • experiments/README.md: the snapshot recorder row (opencode, files).
  • Root and package READMEs: the event-kind list.

🤖 Generated with Claude Code

xxchan and others added 2 commits October 6, 2026 05:28
…arted

Some ACP runtimes put a tool call's real arguments only on a later
tool_call_update: opencode opens a shell call with rawInput {cwd} and a
file call with {}, kimi opens with no rawInput at all. The projection
read tool_call_started.input from the opening frame only, so hosts
never saw the command or the file path (#147).

The shared ACP projection now remembers the input it last reported for
each call. A tool_call_update whose rawInput differs from it adds a
tool_call_input event holding the whole input, in the same form as
tool_call_started.input, replacing the earlier one. An unchanged repeat
adds nothing. On the frame that ends the call it comes before
tool_call_ended, and nothing is read after the end. The rule names no
runtime; the opening tool_call_started is unchanged.

The consumers handle the new kind: the session view's tool part takes
the latest input (an input without a start renders like an end without
one), the status fold treats it as activity in the tool phase, and
`oar run` prints the detail the new input adds.

This adds a member to RuntimeEventBody, so a host with an exhaustive
switch over event kinds stops compiling until it handles
tool_call_input.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…shell commands

With tool_call_input in place, the latest input of a kimi `Bash` or an
opencode `bash` call holds its command, so both now get a `command`
field. The keys come from the recordings: kimi's late rawInput is
{command}; opencode's is {command, cwd} or {command, workdir}. No
recorded opencode input carries a `description`, so none is read.

opencode's file tools had no recording. `experiments/acp-vendor-snapshot.ts`
gains a `files` scenario (write, read, edit, grep, glob, then a shell
`cat`, in a scratch directory scrubbed from the titles), recorded from
opencode 1.18.30 as opencode-acp-v1-files.vendor.json. Each tool opens
with an empty rawInput and gets its arguments on the next update, so
classifyTool now maps read → read_file, write and edit → edit_file, and
grep and glob → search. The detail comes from filePath or path.

The replay test now runs the snapshot frames through the projection and
the session view, so a call's input is the latest one the view holds.
The kimi and opencode activity lines now show the command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 1ab29f1 into main Oct 6, 2026
13 checks passed
@xxchan
xxchan deleted the tool-call-input branch October 6, 2026 05:32
@xxchan xxchan mentioned this pull request Oct 6, 2026
xxchan added a commit that referenced this pull request Oct 6, 2026
Minor release: #148 (Ferryman) adds the `tool_call_input` event, the
arguments an ACP runtime reports after a call starts (opencode, kimi,
grok), folded into the session view's tool part and read by
`classifyTool` (opencode bash, read, write, edit, grep, glob; kimi Bash
command). New member of `RuntimeEventBody`: exhaustive switches over
event kinds must handle it. Version bump only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
stamp-build Bot added a commit that referenced this pull request Nov 1, 2026
<!-- stamp:review:v1 -->
<sup><img
src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp"
width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_6729fcef36ba34b6a3aa44fda20ef78b"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img
src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg"
width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp
→</a></sup>

---
<!-- /stamp:review:v1 -->

A cancellation can spend its one-second observation budget waiting
behind Windows process-table preparation. Previously, its queued read
still started after the caller had timed out. A later cancellation then
waited behind that unwanted read and needed another fresh query, which
could consume its own budget too.

Pass each caller's existing deadline on the `performance.now()` clock
into the internal batcher. At query start, discard expired callers and
skip an empty batch. Choose foreground/background handles from the
remaining callers. Requests without a deadline remain live; an
already-started query continues under its existing limit. The caller
still rejects results delivered at or after its deadline, even when its
timer callback has not run. No public API, observation budget, retry,
PID identity check or signalling rule changes.

This also applies the existing five-second preparation budget before a
queued preparation begins. A background request without a deadline still
runs. Skipped batches are removed before their result settles, so a
later request receives a new observation rather than the skipped result.
The spec documents these boundaries. This removes avoidable queue work;
it does not promise success when an active query or the next OS read
itself is slow.

Validation:

- Fifteen deadline regressions cover all-expired and mixed callers, late
arrivals, unbounded background requests, foreground handle ownership,
skipped-batch settlement, real preparation's existing budget, exact
deadline boundaries, wall-clock changes and rejection of late identity
evidence. The original implementation failed the new expiry/ownership
controls.
- The real ACP/process-table regression no longer waits for the expired
read between turns. Its first observation still times out and leaves its
tool unverified; its second observation succeeds and disposal reclaims
that turn's tool. An unwanted read is deliberately delayed so a
regression cannot hide behind a fast local query.
- Removing expiry filtering, the post-read deadline guard or serial
ordering each caused the relevant tests to fail. Mutations were
restored.
- `CI=1 pnpm run check`: type checking, lint, 2,964 tests and 18 mock
behavior cases passed. Build and all fourteen behavior backends passed
locally, using explicit CI-version binary paths and required
availability. The new controls also passed on Windows and macOS in PR
CI.
- All 35 PR checks passed. Windows check required one rerun after the
installer smoke test's temporary-directory cleanup threw `ENOTEMPTY` and
hid the installation result; the unchanged retry installed CodeBuddy
2.179.1 successfully. Preserving the primary result during cleanup is
tracked as a separate follow-up.

Task #148; follows the fixture-only fix in
[#595](#595).

Co-authored-by: Otter <[email protected]>
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.

ACP view drops tool input that arrives in tool_call_update (opencode, kimi)

1 participant