Skip to content

feat: trace Claude Code CLI model calls - #108304

Merged
amknight merged 5 commits into
mainfrom
ak/claude-cli-model-call-tracing
Jul 17, 2026
Merged

amknight merged 5 commits into
mainfrom
ak/claude-cli-model-call-tracing

Conversation

@amknight

@amknight amknight commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Claude Code CLI turns did not emit trusted model.call.started, model.call.completed, and model.call.error diagnostics. Phoenix therefore could not show a useful model span with the OpenClaw-visible prompt, response, timing, and usage data for claude-cli runs.

Why This Change Was Made

Add synthetic turn-level model-call tracing at the honest Claude Code CLI boundary for one-shot, managed persistent stdio, and paired-node execution. Each admitted attempt now receives exactly one terminal lifecycle event, including retry attempts, aborts, timeouts, process/parse failures, deferred background completion, persistence failure, and cleanup failure.

Content capture reuses the existing trusted capture policy and remains disabled by default. Granular capture includes only the effective OpenClaw prompt, OpenClaw-appended system prompt, and visible assistant blocks. It intentionally excludes Claude Code private prompts, hidden resume/compaction payloads, native tool schemas and arguments, raw Anthropic HTTP traffic, internal retries, upstream request IDs, and network TTFB.

Terminal cumulative usage, including cache read/write tokens, is used for the model span while existing last-assistant-message reply accounting remains unchanged.

User Impact

Operators using OpenTelemetry/Phoenix can inspect a truthful Claude CLI model span with useful lifecycle, prompt/response, byte, timing, and aggregate usage data when content capture is explicitly enabled. Default installations remain metadata-only, and native OpenClaw/Codex tracing behavior is unchanged.

AI-assisted: yes (Codex). I reviewed the implementation and validation results.

Evidence

image
  • node scripts/run-vitest.mjs src/agents/cli-output.test.ts src/agents/cli-runner.spawn.test.ts src/agents/cli-runner/claude-live-session.background-tasks.test.ts: 3 files, 170 tests passed.
  • Retry lifecycle regression filter: 6 tests passed; proves matched started → error and started → completed call IDs across fresh-session recovery.
  • Post-success cleanup regression filter: 2 tests passed; proves cleanup rejection emits error rather than completion.
  • node scripts/run-vitest.mjs extensions/diagnostics-otel/src/service.test.ts: 1 file, 108 tests passed, including gen_ai.input.messages, gen_ai.output.messages, and gen_ai.system_instructions.
  • Blacksmith Testbox: core production types, core test types, extension test types, and touched-file lint passed. Final correction proof: run 29416165438.
  • oxfmt --check and git diff --check: passed.
  • Fresh structured autoreview after fixes: clean, no accepted/actionable findings; patch correct (0.86).

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jul 15, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 9:13 AM ET / 13:13 UTC.

Summary
Adds synthetic turn-level model-call lifecycle, content, timing, and usage tracing for Claude Code CLI runs; distinguishes request and agent-turn telemetry in OpenTelemetry and Prometheus; and updates Codex classification, documentation, and regression tests.

PR surface: Source +679, Tests +1230, Docs +90. Total +1999 across 25 files.

Reproducibility: not applicable. as a bug reproduction: current main's source lacks Claude CLI turn-level model-call events, while the supplied Phoenix screenshot demonstrates the new behavior on the PR head.

Review metrics: 2 noteworthy metrics.

  • Prometheus label surface: 2 existing metric families add 1 label. Adding observation_unit changes emitted time-series identity and may require dashboard or alert-query updates.
  • Existing Codex telemetry identity: 1 operation classification changed. Codex app-server spans move from a request-derived operation to invoke_agent, which is operator-visible even though runtime behavior is unchanged.

Stored data model
Persistent data-model change detected: serialized state: extensions/codex/src/app-server/run-attempt.hooks.test.ts, vector/embedding metadata: src/agents/cli-runner/model-call-diagnostics.ts, vector/embedding metadata: src/agents/cli-runner/run-diagnostics.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Obtain explicit maintainer approval for including Claude thinking under output-content capture.
  • [P1] Rebase onto current main, complete the required direct ../codex source check, and rerun exact-head validation.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The screenshot proof is not enough for browser runtime or security behavior; include console, network, terminal, live output, or logs showing the changed behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Existing Codex dashboards and alerts may require updates because the GenAI operation changes to invoke_agent and two Prometheus metric families gain an observation_unit label.
  • [P1] Enabling output-content capture will export Claude thinking summaries to trusted diagnostic listeners and downstream telemetry; the opt-in default limits exposure, but maintainers must explicitly accept this privacy boundary.
  • [P1] The branch is behind current main, and the repository-required direct sibling Codex contract check could not be completed in this review environment; merge should wait for refreshed exact-head validation and that local dependency inspection.

Maintainer options:

  1. Approve and document both boundaries (recommended)
    Accept the turn telemetry identity and opt-in thinking capture, add explicit operator-facing migration/privacy wording, then rebase and validate the exact merge head.
  2. Narrow captured Claude content
    Remove thinking blocks from Claude CLI diagnostic output while retaining lifecycle, visible text, tool identity, timing, and usage tracing.
  3. Pause the telemetry contract change
    Hold the PR if maintainers do not want synthetic agent turns represented as model-call spans or cannot support the dashboard migration.

Next step before merge

  • [P2] A maintainer should decide the Claude thinking-capture boundary, confirm the operator-visible telemetry migration, and require refreshed exact-head dependency validation before merge.

Maintainer decision needed

  • Question: Should Claude Code CLI diagnostic output capture include streamed thinking blocks under the existing opt-in captureContent.outputMessages policy?
  • Rationale: Native model-call diagnostics already include reasoning under this opt-in policy, but extending that behavior to Claude CLI exports additional potentially sensitive debugging content to downstream telemetry and requires an explicit privacy-boundary decision.
  • Likely owner: steipete — This choice spans the Claude CLI runtime, established diagnostic capture behavior, and user-facing privacy expectations rather than being a mechanical exporter repair.
  • Options:
    • Keep opt-in parity (recommended): Include Claude thinking under the existing disabled-by-default trusted capture policy and document that content explicitly alongside the telemetry migration notes.
    • Exclude CLI thinking: Capture visible text and tool identity only until a separate reasoning-specific capture control and migration contract are approved.

Security
Needs attention: The implementation preserves metadata-only defaults but requires explicit approval because opt-in output capture now includes Claude thinking content.

Review details

Best possible solution:

Provide a documented turn-level invoke_agent span that remains metadata-only by default, explicitly states whether Claude thinking is included when output capture is enabled, and gives existing telemetry users a clear dashboard migration path.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction: current main's source lacks Claude CLI turn-level model-call events, while the supplied Phoenix screenshot demonstrates the new behavior on the PR head.

Is this the best way to solve the issue?

Unclear pending maintainer intent. Turn-level invoke_agent classification is a coherent and well-tested boundary, but the thinking-capture policy and upgrade contract must be explicitly accepted before calling it the best solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against da69daeb72cf.

Label changes

Label changes:

  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The screenshot proof is not enough for browser runtime or security behavior; include console, network, terminal, live output, or logs showing the changed behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: This is a substantial but opt-in observability improvement with bounded operator impact rather than an urgent runtime regression.
  • merge-risk: 🚨 compatibility: The PR changes existing Codex operation identity and Prometheus label sets, which can affect deployed dashboards, recording rules, and alerts.
  • merge-risk: 🚨 security-boundary: The PR expands trusted telemetry capture to include Claude thinking content when output capture is explicitly enabled.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The screenshot proof is not enough for browser runtime or security behavior; include console, network, terminal, live output, or logs showing the changed behavior after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The screenshot proof is not enough for browser runtime or security behavior; include console, network, terminal, live output, or logs showing the changed behavior after the fix.
Evidence reviewed

PR surface:

Source +679, Tests +1230, Docs +90. Total +1999 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 12 721 42 +679
Tests 10 1250 20 +1230
Docs 3 100 10 +90
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 25 2071 72 +1999

Security concerns:

  • [medium] Confirm the Claude thinking export boundary — src/agents/cli-runner/model-call-diagnostics.ts:45
    assistantContentBlock copies streamed thinking text into trusted diagnostic private data, allowing configured exporters to send it downstream; maintainers should explicitly accept and document that privacy boundary or exclude it.
    Confidence: 0.96

What I checked:

Likely related people:

  • amknight: Prior merged observability work credited to this person established related diagnostic-event and OpenTelemetry behavior, and they supplied the current privacy and compatibility rationale beyond merely opening this PR. (role: observability feature owner; confidence: high; files: extensions/diagnostics-otel/src/service.ts, src/infra/diagnostic-events.ts, docs/gateway/opentelemetry.md)
  • steipete: Recent merged work on Claude CLI output diagnostics and broad ownership of the affected agent runtime make this person a useful second decision route for the capture boundary and upgrade impact. (role: recent adjacent runtime contributor; confidence: medium; commits: 5518ac9; files: src/agents/cli-output.ts, src/agents/cli-runner.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-17T06:23:52.430Z sha ed0cb04 :: found issues before merge. :: [P1] Keep aggregate CLI turns out of model.call
  • reviewed 2026-07-17T07:03:12.457Z sha a10a7a2 :: found issues before merge. :: [P1] Keep aggregate CLI turns out of model.call
  • reviewed 2026-07-17T07:19:07.445Z sha 6286b01 :: found issues before merge. :: [P1] Keep aggregate CLI turns out of model.call
  • reviewed 2026-07-17T07:58:52.181Z sha 6286b01 :: found issues before merge. :: [P1] Keep aggregate CLI turns out of model.call | [P1] Exclude non-visible thinking from diagnostic output capture
  • reviewed 2026-07-17T08:41:46.728Z sha 6286b01 :: found issues before merge. :: [P1] Keep opaque CLI turns out of model.call | [P1] Exclude non-visible thinking from captured output
  • reviewed 2026-07-17T11:28:48.897Z sha 602992c :: needs changes before merge. :: [P1] Exclude hidden Claude thinking from output capture
  • reviewed 2026-07-17T12:11:44.136Z sha 602992c :: needs changes before merge. :: [P1] Exclude hidden thinking from captured Claude output
  • reviewed 2026-07-17T12:30:44.607Z sha 602992c :: needs maintainer review before merge. :: none

@amknight
amknight marked this pull request as ready for review July 16, 2026 08:09
@amknight
amknight force-pushed the ak/claude-cli-model-call-tracing branch from 1336524 to 0f6c4e5 Compare July 16, 2026 12:43
@amknight
amknight marked this pull request as draft July 16, 2026 12:43
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 16, 2026
@amknight
amknight marked this pull request as ready for review July 17, 2026 05:16
@amknight

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 17, 2026
@amknight
amknight force-pushed the ak/claude-cli-model-call-tracing branch from 0f6c4e5 to ed0cb04 Compare July 17, 2026 05:35
@amknight

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@amknight
amknight force-pushed the ak/claude-cli-model-call-tracing branch from a10a7a2 to 6286b01 Compare July 17, 2026 07:14
@amknight

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 17, 2026
@amknight

Copy link
Copy Markdown
Member Author

Both P1s reviewed; one is addressed in 602992c, one I'm keeping with rationale.

[P1] Keep opaque CLI turns out of model.call — addressed in 602992c9fc3. Turn-scoped lifecycles stay model.call events (so exporters keep rendering input/output/usage/hierarchy for free), but they are now explicitly distinguished everywhere instead of blending into request telemetry:

  • gen_ai.operation.name becomes invoke_agent for observationUnit: "turn" (extensions/diagnostics-otel/src/service-genai-attributes.ts:30-38), so turn latency/usage never aggregates with chat request series; the earlier blanket exclusion from gen_ai.client.operation.duration is gone — turns record under their own operation name instead of disappearing.
  • Spans and openclaw.model_call.* metrics carry openclaw.model_call.observation_unit; diagnostics-prometheus gets the matching observation_unit label (extensions/diagnostics-prometheus/src/service.ts:336). Missing values default to request for older/external emitters.
  • docs/gateway/opentelemetry.md ("Model-call observation units") documents the semantics, including that Codex app-server calls now report invoke_agent — that operation-name shift is the one operator-visible change for existing Codex dashboards.

[P1] Exclude non-visible thinking from captured output — intentionally kept, matching shipped native capture. The embedded runner already exports the full terminal assistant message — reasoning and tool arguments — when captureContent.outputMessages is enabled (src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.ts:272-287), and the serializer has first-class reasoning parts (extensions/diagnostics-otel/src/service-genai-content.ts:114-115). The Claude CLI capture is strictly narrower: it keeps text/thinking/tool-call identity and drops tool arguments and opaque signatures (src/agents/cli-runner/model-call-diagnostics.ts:57-59). Excluding thinking here would make CLI spans less consistent than native ones and remove the main debugging payload capture exists for. It stays opt-in, granular, and trusted-listener-only; documented in the fidelity section.

CI is rerunning on the new head.

@amknight

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 17, 2026
@amknight
amknight merged commit ddb4ed9 into main Jul 17, 2026
172 of 187 checks passed
@amknight
amknight deleted the ak/claude-cli-model-call-tracing branch July 17, 2026 20:23
@steipete steipete self-assigned this Jul 17, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
* feat: trace Claude CLI model calls

* fix: align Claude CLI trace hierarchy

* fix: distinguish model request and turn telemetry

* fix: satisfy diagnostics CI checks

* fix: distinguish agent-turn telemetry

---------

Authored-by: Alex Knight <[email protected]>
steipete added a commit that referenced this pull request Oct 15, 2026
Share lifecycle hook capture, native policy loops and gated diagnostic content
construction. Combine initial session metadata updates through the existing
writer and reuse the persisted-input notifier. Keep delivery evidence in a
typed WeakMap without mutating or wrapping frozen error objects.

Security checks, public contracts, transcript durability, parallel tool
correlation and ordinary shutdown settlement remain. No schema, configuration,
dependency, protocol or public SDK signature changes. The standalone session
memory backend and its lifecycle machinery are untouched.

Best-effort tradeoffs accepted:
- Reusing the same engine during active disposal no longer has a WeakRef
  tombstone rejection. #168789 cites synthetic #143426/#143592 disposal cases,
  not a human production report. Misuse may fail in the engine normally;
  closing admission and actual resource settlement remain.
- Fresh bounded primitive diagnostics are not redundantly cloned before
  publication (#108304). Listener egress still isolates its payloads.
- Internal delivery-evidence readers receive the attachment-time snapshot,
  not another defensive copy (0ea0807). No human mutation report was found;
  unsupported internal mutation could affect a later reader. Confirmed-send
  suppression and attachment-time copying remain.

Lane y08: 105 net production lines removed (165 added / 270 removed), excluding
tests; tests add 67 net lines. Below-500 branch-only handoff for coordinator
bundling after recent, older and largest-owner audits found no further sound
candidate. No PR or hosted-CI success is claimed.

Proof: production and affected test types, changed-file lint/format, runtime
and madge cycles (zero), lint-suppressions (3/3), and independent P2 review
passed. Maintenance resources (6/6), CLI spawn (40/40), and restart recovery
(33/33) completed. Support proof was stopped after ten minutes without an
assertion result; Gateway cancellation timed out during startup/imports with
no assertion result, and deletion was not reached. CLI reliability was only
partially exercised in an earlier interrupted selection. These are unresolved
proof gaps, not attributed main failures.
steipete added a commit that referenced this pull request Oct 15, 2026
* refactor(ui): consolidate chat owners and remove obsolete adapters

Keep both live rendering routes and the existing DOM, text, persisted shapes,
security boundaries, draft durability, and ordinary session concurrency.
Consolidate effective-tool loading, header registration, transcript refs,
history target capture, and PCM output ownership. Remove unused adapters
after their completed native-control cutovers and redundant internal work.

Best-effort tradeoffs accepted:
- Pending-page/live-update overlap: #145240 records synthetic request-order
  proof, not a cited human incident. Displayed disposition can briefly lag
  until the next ordinary refresh; durable receipts remain authoritative.
- Synchronous rail self-retirement: #153245 records a synthetic benchmark,
  not a cited human incident. Focus restoration is best effort in that case.
- Obsolete intersection callbacks: #142227 records synthetic E2E proof, not
  a cited stale-delivery incident. Target maps ignore retired rows; a late
  callback can request redundant layout.
- Obsolete mutation callbacks: the same #142227 provenance. Native disconnect
  remains; a late delivery can resample the current scroller.
- Obsolete resize callbacks: #162617 records synthetic performance traces,
  not a cited stale-delivery incident. Native cleanup remains; a late callback
  can sample current layout.
- Wrong bundled Gateway PR identity: #148070/#147952 describe the feature,
  not a wrong-target incident. The producer constructs the exact requested
  target; a contract violation now displays its returned result.
- Cross-tab prefetch election: #125128 covered a retired five-session idle
  sweep with synthetic performance proof. Two tabs can now redundantly read
  one explicitly hover/focus-intended target; per-tab limits remain.
- Malformed internal sidebar maps: #113712 introduced feature normalization,
  not a cited incident. Settings validates load/save and all callers use that
  output; impossible malformed typed values are not repaired at every update.

* refactor(ui): consolidate chat lifecycle and internal state paths

Continue the y01 largest-owner, export/caller and duplicate-helper audit.
Delegate composer mounting to the canonical interop boundary while retaining
field equality, keyed renderer identity and foreground picker cleanup. Remove
test-only panel refresh methods and commit counters; exercise the actual view,
polling and committed DOM instead. Trust admitted immutable composer metadata
and the full tool-stream owner contract. Narrow sidebar traversal to its
normalized single column and simplify browser/Gateway realtime decoding.

Both shipping Lit/Solid paths and rendered markup remain unchanged. No config,
protocol, storage, dependency, security-boundary or Phase E backend changes.

Best-effort tradeoffs accepted

- Malformed internal tool-stream hosts: #158032 introduced shape probes during
  a bookkeeping refactor, not a human incident. Real owners have complete state;
  a broken internal caller now fails rather than silently skipping cleanup.
  #125197's human steering/order report still justifies the unchanged causal
  reconciliation algorithm; no report ties malformed-host probes to that bug.
- In-place mutation of admitted draft metadata: #158335 added reply persistence
  and #166682 moved the annotation copies, without a mutation incident. Actual
  editors replace records/arrays. A future in-place mutator must follow that
  contract or it may alter a pending snapshot. Durable receipts/revisions stay.
- Non-JSON relay events: #146676 added transport machinery without a human
  cyclic-frame incident. Frames already crossed JSON decoding; an impossible
  internal cycle or BigInt now throws. Activation count/byte bounds remain.
- Older Gateway close-disposition support: #171377 added a compatibility path,
  but UI/Gateway ship together and the current server advertises the field.
  Unsupported skew now rejects. Accepted-answer durability from the real human
  report #171310 and fixes #171377/#172159 remains intact.
- Blob/typed-array/arbitrary Google message representations: c399fb7
  added these alternate decoder branches without a linked human report. The
  browser WebSocket is configured as arraybuffer before listeners. Unsupported
  synthetic representations are ignored; actual strings/ArrayBuffers still
  decode, and removal of the artificial await needs no post-await stale check.
- Extra sidebar columns after normalization: #123874 flattened the flexible
  #113712 layout to one tabbed panel. A broken internal producer is no longer
  searched as a multi-column layout; persisted legacy flattening still runs.

The earlier commit records the original eight accepted best-effort scenarios.
Coverage and remaining justified owners are logged in .local/y01-ledger.md for
coordinator bundling. Combined candidate removes 416 net production lines
against 5716bb1 (tests/support excluded).

* test(ui): align talk fixtures with transport contracts

Require detach disposition when append rejection closes the relay. The UI and
Gateway ship together; the prior fallback's omitted field is no longer valid.

Close the Google socket before start settles when testing startup rejection.
Synchronous frame decoding removed the fixture's former artificial decode
microtask; waiting one turn now settles start before the close. Preserve all
error, callback, microphone, socket and timer assertions.

No production change or new best-effort tradeoff. The preceding commit records
the accepted transport assumptions and their provenance.

* refactor(agents): consolidate runner lifecycle plumbing

Share lifecycle hook capture, native policy loops and gated diagnostic content
construction. Combine initial session metadata updates through the existing
writer and reuse the persisted-input notifier. Keep delivery evidence in a
typed WeakMap without mutating or wrapping frozen error objects.

Security checks, public contracts, transcript durability, parallel tool
correlation and ordinary shutdown settlement remain. No schema, configuration,
dependency, protocol or public SDK signature changes. The standalone session
memory backend and its lifecycle machinery are untouched.

Best-effort tradeoffs accepted:
- Reusing the same engine during active disposal no longer has a WeakRef
  tombstone rejection. #168789 cites synthetic #143426/#143592 disposal cases,
  not a human production report. Misuse may fail in the engine normally;
  closing admission and actual resource settlement remain.
- Fresh bounded primitive diagnostics are not redundantly cloned before
  publication (#108304). Listener egress still isolates its payloads.
- Internal delivery-evidence readers receive the attachment-time snapshot,
  not another defensive copy (0ea0807). No human mutation report was found;
  unsupported internal mutation could affect a later reader. Confirmed-send
  suppression and attachment-time copying remain.

Lane y08: 105 net production lines removed (165 added / 270 removed), excluding
tests; tests add 67 net lines. Below-500 branch-only handoff for coordinator
bundling after recent, older and largest-owner audits found no further sound
candidate. No PR or hosted-CI success is claimed.

Proof: production and affected test types, changed-file lint/format, runtime
and madge cycles (zero), lint-suppressions (3/3), and independent P2 review
passed. Maintenance resources (6/6), CLI spawn (40/40), and restart recovery
(33/33) completed. Support proof was stopped after ten minutes without an
assertion result; Gateway cancellation timed out during startup/imports with
no assertion result, and deletion was not reached. CLI reliability was only
partially exercised in an earlier interrupted selection. These are unresolved
proof gaps, not attributed main failures.

* refactor(agents): remove duplicate runner preparation work

Trust canonical inline model modalities and waiter-owned cleanup. Fold the
sole-caller HTTP setup wrapper and stage warning predicate into their owners,
and remove an unused diagnostic clock option.

This pass removes 32 net production lines; the branch total is 137. Core and
affected test types, lint, format, cycle checks, stage timing and suppression
tests pass. Independent P2 review is clean. Wider focused runtime selections
remain incomplete under host load; coordinator bundling needs broad CI proof.

* refactor: withdraw inconclusive stream cleanup and repair bundle ratchets

Retain current main stream-state contracts after the UI failure replay could not establish an exact-main comparison. Shrink the delivery-evidence assertion allowance and keep its frozen/primitive regression intact in a focused unit file.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…w#173015)

* refactor(ui): consolidate chat owners and remove obsolete adapters

Keep both live rendering routes and the existing DOM, text, persisted shapes,
security boundaries, draft durability, and ordinary session concurrency.
Consolidate effective-tool loading, header registration, transcript refs,
history target capture, and PCM output ownership. Remove unused adapters
after their completed native-control cutovers and redundant internal work.

Best-effort tradeoffs accepted:
- Pending-page/live-update overlap: openclaw#145240 records synthetic request-order
  proof, not a cited human incident. Displayed disposition can briefly lag
  until the next ordinary refresh; durable receipts remain authoritative.
- Synchronous rail self-retirement: openclaw#153245 records a synthetic benchmark,
  not a cited human incident. Focus restoration is best effort in that case.
- Obsolete intersection callbacks: openclaw#142227 records synthetic E2E proof, not
  a cited stale-delivery incident. Target maps ignore retired rows; a late
  callback can request redundant layout.
- Obsolete mutation callbacks: the same openclaw#142227 provenance. Native disconnect
  remains; a late delivery can resample the current scroller.
- Obsolete resize callbacks: openclaw#162617 records synthetic performance traces,
  not a cited stale-delivery incident. Native cleanup remains; a late callback
  can sample current layout.
- Wrong bundled Gateway PR identity: openclaw#148070/openclaw#147952 describe the feature,
  not a wrong-target incident. The producer constructs the exact requested
  target; a contract violation now displays its returned result.
- Cross-tab prefetch election: openclaw#125128 covered a retired five-session idle
  sweep with synthetic performance proof. Two tabs can now redundantly read
  one explicitly hover/focus-intended target; per-tab limits remain.
- Malformed internal sidebar maps: openclaw#113712 introduced feature normalization,
  not a cited incident. Settings validates load/save and all callers use that
  output; impossible malformed typed values are not repaired at every update.

* refactor(ui): consolidate chat lifecycle and internal state paths

Continue the y01 largest-owner, export/caller and duplicate-helper audit.
Delegate composer mounting to the canonical interop boundary while retaining
field equality, keyed renderer identity and foreground picker cleanup. Remove
test-only panel refresh methods and commit counters; exercise the actual view,
polling and committed DOM instead. Trust admitted immutable composer metadata
and the full tool-stream owner contract. Narrow sidebar traversal to its
normalized single column and simplify browser/Gateway realtime decoding.

Both shipping Lit/Solid paths and rendered markup remain unchanged. No config,
protocol, storage, dependency, security-boundary or Phase E backend changes.

Best-effort tradeoffs accepted

- Malformed internal tool-stream hosts: openclaw#158032 introduced shape probes during
  a bookkeeping refactor, not a human incident. Real owners have complete state;
  a broken internal caller now fails rather than silently skipping cleanup.
  openclaw#125197's human steering/order report still justifies the unchanged causal
  reconciliation algorithm; no report ties malformed-host probes to that bug.
- In-place mutation of admitted draft metadata: openclaw#158335 added reply persistence
  and openclaw#166682 moved the annotation copies, without a mutation incident. Actual
  editors replace records/arrays. A future in-place mutator must follow that
  contract or it may alter a pending snapshot. Durable receipts/revisions stay.
- Non-JSON relay events: openclaw#146676 added transport machinery without a human
  cyclic-frame incident. Frames already crossed JSON decoding; an impossible
  internal cycle or BigInt now throws. Activation count/byte bounds remain.
- Older Gateway close-disposition support: openclaw#171377 added a compatibility path,
  but UI/Gateway ship together and the current server advertises the field.
  Unsupported skew now rejects. Accepted-answer durability from the real human
  report openclaw#171310 and fixes openclaw#171377/openclaw#172159 remains intact.
- Blob/typed-array/arbitrary Google message representations: 2a4c20f
  added these alternate decoder branches without a linked human report. The
  browser WebSocket is configured as arraybuffer before listeners. Unsupported
  synthetic representations are ignored; actual strings/ArrayBuffers still
  decode, and removal of the artificial await needs no post-await stale check.
- Extra sidebar columns after normalization: openclaw#123874 flattened the flexible
  openclaw#113712 layout to one tabbed panel. A broken internal producer is no longer
  searched as a multi-column layout; persisted legacy flattening still runs.

The earlier commit records the original eight accepted best-effort scenarios.
Coverage and remaining justified owners are logged in .local/y01-ledger.md for
coordinator bundling. Combined candidate removes 416 net production lines
against 7f7310a (tests/support excluded).

* test(ui): align talk fixtures with transport contracts

Require detach disposition when append rejection closes the relay. The UI and
Gateway ship together; the prior fallback's omitted field is no longer valid.

Close the Google socket before start settles when testing startup rejection.
Synchronous frame decoding removed the fixture's former artificial decode
microtask; waiting one turn now settles start before the close. Preserve all
error, callback, microphone, socket and timer assertions.

No production change or new best-effort tradeoff. The preceding commit records
the accepted transport assumptions and their provenance.

* refactor(agents): consolidate runner lifecycle plumbing

Share lifecycle hook capture, native policy loops and gated diagnostic content
construction. Combine initial session metadata updates through the existing
writer and reuse the persisted-input notifier. Keep delivery evidence in a
typed WeakMap without mutating or wrapping frozen error objects.

Security checks, public contracts, transcript durability, parallel tool
correlation and ordinary shutdown settlement remain. No schema, configuration,
dependency, protocol or public SDK signature changes. The standalone session
memory backend and its lifecycle machinery are untouched.

Best-effort tradeoffs accepted:
- Reusing the same engine during active disposal no longer has a WeakRef
  tombstone rejection. openclaw#168789 cites synthetic openclaw#143426/openclaw#143592 disposal cases,
  not a human production report. Misuse may fail in the engine normally;
  closing admission and actual resource settlement remain.
- Fresh bounded primitive diagnostics are not redundantly cloned before
  publication (openclaw#108304). Listener egress still isolates its payloads.
- Internal delivery-evidence readers receive the attachment-time snapshot,
  not another defensive copy (8c995fb). No human mutation report was found;
  unsupported internal mutation could affect a later reader. Confirmed-send
  suppression and attachment-time copying remain.

Lane y08: 105 net production lines removed (165 added / 270 removed), excluding
tests; tests add 67 net lines. Below-500 branch-only handoff for coordinator
bundling after recent, older and largest-owner audits found no further sound
candidate. No PR or hosted-CI success is claimed.

Proof: production and affected test types, changed-file lint/format, runtime
and madge cycles (zero), lint-suppressions (3/3), and independent P2 review
passed. Maintenance resources (6/6), CLI spawn (40/40), and restart recovery
(33/33) completed. Support proof was stopped after ten minutes without an
assertion result; Gateway cancellation timed out during startup/imports with
no assertion result, and deletion was not reached. CLI reliability was only
partially exercised in an earlier interrupted selection. These are unresolved
proof gaps, not attributed main failures.

* refactor(agents): remove duplicate runner preparation work

Trust canonical inline model modalities and waiter-owned cleanup. Fold the
sole-caller HTTP setup wrapper and stage warning predicate into their owners,
and remove an unused diagnostic clock option.

This pass removes 32 net production lines; the branch total is 137. Core and
affected test types, lint, format, cycle checks, stage timing and suppression
tests pass. Independent P2 review is clean. Wider focused runtime selections
remain incomplete under host load; coordinator bundling needs broad CI proof.

* refactor: withdraw inconclusive stream cleanup and repair bundle ratchets

Retain current main stream-state contracts after the UI failure replay could not establish an exact-main comparison. Shrink the delivery-evidence assertion allowance and keep its frozen/primitive regression intact in a focused unit file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex extensions: diagnostics-otel Extension: diagnostics-otel extensions: diagnostics-prometheus gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants