Skip to content

fix(observe): classify page fetches and subagent calls - #322

Merged
xxchan merged 5 commits into
mainfrom
fix/tool-classification-gaps
Oct 10, 2026
Merged

xxchan merged 5 commits into
mainfrom
fix/tool-classification-gaps

Conversation

@xxchan

@xxchan xxchan commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Closes #321.

Two new ToolActionKinds:

  • fetch: claude WebFetch and cursor webFetch read one page. They were classified web and worded "Searching the web". They now read "Fetching page", and in a group summary "fetched 2 pages". The call's url is the detail.
  • subagent: claude Agent (and Task, its alias in 2.1.292, under which a call is recorded as Task) and opencode subagent were unclassified ("Running Agent", or other on opencode). They now read "Running subagent", and in a group summary "ran 2 subagents". Both runtimes' recorded inputs carry the subagent's task as description (tests/replay/fixtures/claude-background-tasks.raw.jsonl, opencode-acp-v2-child.json). It becomes the call's description and its detail. A command in such an input is never read as one.

web now means a web search only: its writing and failed labels read "Preparing web search" and "Web search failed".

Not changed, after checking: the issue also listed codex shell and kimi Shell. Neither tool exists in the runtimes OAR drives. codex reports every shell call as a commandExecution item, and OAR emits only its five classified item types as tools (codex/projection.ts). Kimi Code names its shell tool Bash (recorded in kimi-acp-v1.vendor.json, and Bash is in the installed 2.1.1 binary), which is already run_command. Shell is the Python kimi-cli's name, and OAR does not drive that CLI.

Also: the file-path helpers moved from tool-activity.ts into tool-paths.ts unchanged, to stay under the file length limit.

Behavior changes: hosts with an exhaustive switch or Record over ToolActionKind need the two new cases. Counts that grouped page fetches under web now show them as fetch.

Tests: recorded Agent (also as Task), subagent and WebFetch inputs in tests/tool-activity.test.ts; summaries for both kinds in tests/tool-groups.test.ts; the opencode classification snapshot. Lookout verified WebFetch, Agent and Task against the real claude 2.1.292 with a mock provider, and opencode subagent on a real OpenCode v2 recording. Lint, typecheck and the classification, grouping, CLI progress and replay tests pass.

🤖 Generated with Claude Code

exe.dev user and others added 2 commits October 10, 2026 07:56
groupToolActivity called classifyTool, which parses each call's whole
input, for every tool part each time it ran. A host that words a live turn
on every record (Ferry on iOS) paid tools x input size per record, and
since 0.52 streamed arguments are records too. A view replaces a part on
every change and never mutates one, so each part's kind is now cached by
the part object (per runtime) in a WeakMap.

Closes #318.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
classifyTool's kind never depends on the call's input, so grouping no
longer passes it and needs no cache keyed on part identity (Lookout's
review of #319).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
xxchan pushed a commit that referenced this pull request Oct 10, 2026
claude 2.1.292 defines Task as an alias of its Agent tool, and a call the
model makes under it is recorded as Task (Lookout's run on #322).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
exe.dev user and others added 3 commits October 10, 2026 08:23
claude WebFetch and cursor webFetch read one page; they were worded as
web searches. They are now the new fetch kind. claude Agent and opencode
subagent were unclassified; they are now the new subagent kind, with the
recorded description as their detail. web's writing and failed labels
now say search.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
claude 2.1.292 defines Task as an alias of its Agent tool, and a call the
model makes under it is recorded as Task (Lookout's run on #322).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan force-pushed the fix/tool-classification-gaps branch from 7ceee16 to d9b8c7f Compare October 10, 2026 08:27
@xxchan
xxchan merged commit e5793f9 into main Oct 10, 2026
17 checks passed
@xxchan
xxchan deleted the fix/tool-classification-gaps branch October 10, 2026 08:54
@xxchan xxchan mentioned this pull request Oct 10, 2026
xxchan added a commit that referenced this pull request Oct 10, 2026
Release OAR and CLI 0.54.0. This PR changes only the two package version
fields.

**Added: session lineage is in the records** (#312, #320)
- New event `session_linked { parent, child, via: "tool_call" }`,
carried by the native frame that names the relationship: codex
collaboration items, ACP lineage notifications (grok) and OpenCode v2
child attribution. A host that folds the records now gets the same
session graph and the same `usage().withChildren` as a live `Session`.
- `graphOf(records)` is exported (root, observe and browser entries).
`Session.graph()` is the same fold, kept as each record is appended. A
live graph starts with its root id; `graphOf` learns the root from its
first record. An edge reported many times is in the graph once.
- `usageOf(records, sessionId)` derives lineage from the records by
default and still takes an explicit graph. Old records without
`session_linked` have no edges and no `withChildren`.
- grok child ledgers stay native-only, as before: the root's prompt
ledger already includes a foreground child's spend. A background child's
spend (grok's default) and the root turn grok runs after it are not in
`usage()` yet (#325).

**Added: a tool phase says when claude is still writing its arguments**
(#314, #317)
- `RunningPhase` `{ tool, callId }` gains `writing?: true` while a
call's arguments stream (`tool_call_input_delta`); the complete input or
the call's result clears it.
- `phaseLabel(phase, runtimeId?)` names the action when given the
runtime: "Preparing command", "Preparing file edit", "Running command",
"Reading file". MCP and unclassified tools read "Writing <name>
arguments" and "Running <name>". Without `runtimeId` it reads "Running
<tool>" as before, or "Writing <tool> arguments".
- `toolActionLabel` takes a `"writing"` state.

**Added: page fetches and subagent calls are classified** (#321, #322)
- New `ToolActionKind` `fetch`: claude `WebFetch` and cursor `webFetch`,
worded "Fetching page" and "fetched 2 pages". They were `web`, worded as
web searches. `web` now means a web search only.
- New `ToolActionKind` `subagent`: claude `Agent` (and its alias `Task`,
under which a call is recorded as `Task`) and opencode `subagent`,
worded "Running subagent" and "ran 2 subagents", with the subagent's
task (`description`) as `detail` and `description`.

**Fixed**
- `groupToolActivity` no longer parses every call's input on each
grouping: a call's kind depends only on its runtime and tool name (#318,
#319). A host that groups a live turn on every record pays far less: 400
calls went from 2,160 ms to about 300 ms.
- pi: the model catalog's `providers()[].configured` is true from the
start for a provider with a key or login in `auth.json`, not only after
`refresh()` (#291, #323). An environment key still counts only after
`refresh()`. As in pi itself, `configured` means the provider has an
entry, not that its key works.

**Behavior changes**
- New event kind `session_linked`, and new `ToolActionKind`s `fetch` and
`subagent`. Hosts with an exhaustive `switch` or `Record` need the new
cases.
- Counts that grouped page fetches under `web` now show them as `fetch`;
claude `Agent`/`Task` and opencode `subagent` calls count as `subagent`,
not `other`.
- An incremental `SessionView` checkpoint must keep `sessionGraph` and
`usageBySession`; replay the raw records when upgrading an older
checkpoint.
- Adapter authors: put the event `kernel.link(edge)` returns in the
source frame's events. `kernel.node()` is removed.

Validation: every PR passed all 17 checks on its final head. #317
differed from its CI tree only in the version fields from the 0.53.0
release, and #320's merged tree equals its CI tree. #319, #323 and #322
each merged after typecheck, lint and the full test suite passed locally
on top of the PRs merged before them, and each merged tree equals that
verified tree. Lookout verified each with no account: #320 against real
codex 0.162.0 and grok 1.0.50 with a mock provider and OpenCode v2
2.0.26 on a free model (the live graph equals `graphOf` of the records
after every one of 222 records, and replayed usage equals live); #317
and #322 against the real claude CLI 2.1.292 with a mock provider,
including `WebFetch`, `Agent` and `Task`; #319 with identical groups to
0.53.0 on recordings of 1,487 and 4,917 records; #323 with temporary
`auth.json` files and the network blocked. After this PR passes CI and
merges, tag its exact squash commit as `v0.54.0` to trigger npm trusted
publishing.

🤖 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 pushed a commit that referenced this pull request Nov 19, 2026
A host that wants to list and launch runtimes without knowing any by name
needs, before opening a session, everything that depends on the installed
version. `Runtime.sessionCapabilities(installation)` already answered steer
and images; it now also carries this installation's complete
`refusedSessionOptions` (the static map plus refusals a release adds below
its floor), its `manualCompaction`, and `compactionEvents` (whether native
automatic compaction reports compaction_started / compaction_ended).

`defineRuntime` merges the static declarations into the member, and the new
`installedSessionCapabilities(runtime, installation)` does the same for any
Runtime. `orient()` returns the answer in each available installation's
entry, and the whole report stays plain JSON so a host can send it from the
machine unchanged and key it by runtime and installed version.

No adapter declares a version-dependent refusal, manual compaction or
compaction events through it yet; those follow with native evidence
(OpenCode 2.x prompt floors after #989, manual compaction in #core:#322).

Agreed in #oar-raft:#39 with Archer and Raft's Otter for Raft's
no-per-runtime-code integration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stamp-build Bot added a commit that referenced this pull request Nov 19, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_170563be60a5141d64e1368ecba99f3e"><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 -->

Raft wants to list and launch every OAR runtime with no per-runtime code (xxchan in #oar-raft, agreed with Archer and Raft's Otter in #oar-raft:#39). Before opening a session it needs everything that depends on the installed version, in one answer, as plain data.

## What changes

- `SessionCapabilityDeclaration` (the return of `Runtime.sessionCapabilities(installation)`, which already answered `steer` and `images`) gains:
  - `refusedSessionOptions?`: this installation's complete set, the static map plus refusals a release adds below its floor. Same rule as the static map: declared means refused at open.
  - `manualCompaction?`: this installation's value.
  - `compactionEvents?: { started, ended }`: whether native automatic compaction reports those events. Absent means not established.
- `defineRuntime` merges the static `refusedSessionOptions` and `manualCompaction` into the member; `installedSessionCapabilities(runtime, installation)` does the same for any `Runtime`.
- `orient()` returns `sessionCapabilities` in each available installation's entry. The whole report is plain JSON (tested by a round trip), so a host can send it from the machine unchanged and key it by runtime and installed version.

No adapter declares a version-dependent refusal, manual compaction or compaction events yet; each follows with native evidence (OpenCode 2.x prompt floors after #989, manual compaction in #core:#322, compaction events per runtime afterwards).

## Checks

- Every built-in runtime: the member exists, answers synchronously, contains its static declarations, and survives a JSON round trip with `brand` and `minVersion`.
- Merge order, per-version manual compaction, a runtime without the member, idempotent merging.
- `orient()` carries the merged answer for an available installation and none for a missing one.
- Full local typecheck, lint and tests pass.

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

Co-authored-by: Cindy <[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.

observe: tool classification gaps (WebFetch, Agent/Task, codex shell, kimi Shell)

1 participant