fix(sessions): report ACP-runtime metadata for ACP-keyed sessions#79550
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Source inspection shows current main builds ACP-aware session rows but does not pass persisted ACP metadata/backend into runtime metadata resolution, and the PR body includes a deployed-container repro showing auto/implicit for ACP rows before the fix. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the ACP metadata overlay after normal CI and maintainer merge checks, keeping the entry.acp-gated bridge-session guard and backend-derived runtime id. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main builds ACP-aware session rows but does not pass persisted ACP metadata/backend into runtime metadata resolution, and the PR body includes a deployed-container repro showing auto/implicit for ACP rows before the fix. Is this the best way to solve the issue? Yes. The patch is the narrow maintainable fix: keep model/runtime policy pure, then overlay runtime metadata only when both the ACP key shape and persisted ACP metadata identify a control-plane session. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3ce922437fb6. Re-review progress:
|
|
Bot feedback (P2) addressed in commit |
… only at resolveModelAgentRuntimeMetadata
…time-overlay and agent-runtime-metadata Move AgentRuntimeMetadata type definition into acp-runtime-overlay.ts (the leaf module) so agent-runtime-metadata.ts can import both the type and applyAcpRuntimeOverlay from a single direction. agent-runtime-metadata.ts re-exports the type to keep all existing consumers unchanged. Fixes check:madge-import-cycles failure in check-additional-runtime-topology-architecture CI shard.
82ecdb1 to
4ebbf1d
Compare
|
Landing proof for PR #79550 at head SHA Behavior addressed: ACP control-plane session rows now report ACP runtime metadata from persisted Local verification from maintainer worktree: pnpm test src/commands/sessions.acp-runtime-metadata.test.ts src/commands/sessions.acp-model-display.test.ts -- --reporter=verbose
pnpm tsgo:core
pnpm tsgo:core:test
pnpm exec oxfmt --check --threads=1 src/agents/acp-runtime-overlay.ts src/agents/agent-runtime-metadata.ts src/commands/sessions.acp-runtime-metadata.test.ts src/commands/sessions.ts src/commands/status.summary.runtime.ts src/gateway/session-utils.ts src/gateway/server-methods/sessions.ts
git diff --check upstream/main...HEADObserved local result: focused tests passed 10/10; User-facing seeded CLI proof after the maintainer fix: CI / GitHub proof:
Known proof gap / unrelated red check: No live ACP provider/harness turn with external credentials was run after the maintainer rebase fix; the proof is seeded session-store CLI behavior plus focused regression/type/format checks. |
Summary
ACP sessions reported
agentRuntime.id: "auto"(post-02fe0d8978) — which is also wrong, since they aren't routed via the auto runtime; they're driven byacpx. Add a session-key-aware overlay applied at the production resolver so ACP-keyed rows report{ id: "acpx", source: "session-key" }. Closes catalog #18.Bug detail
Running
openclaw sessions --all-agents --jsonagainst the deployed container produced (excerpt, redacted UUIDs):{ "key": "agent:copilot:acp:86b7b5af-…", "agentId": "copilot", "agentRuntime": { "id": "auto", "source": "implicit" }, "kind": "direct" }The
:acp:segment unambiguously marks an ACP session, yet the JSON labels it as runtime"auto". The original catalog finding documented"pi", but commit02fe0d8978("Keep OpenAI Codex migrations on automatic runtime routing") had already shifted the unrecognized-model default from"pi"to"auto"before this PR was opened. The remaining bug — the production path returning the wrong runtime identifier for ACP sessions — is what this PR addresses.How to reproduce
Live repro before fix (deployed container, OpenClaw 2026.5.6):
7/7 ACP sessions report
auto/implicit.Unit-level:
Root cause
The 6 production emit sites all call
resolveModelAgentRuntimeMetadata(...), which had zero session-key awareness — it routed off model identity / config policy only. ACP sessions, having no special model identity, fell into the post-02fe0d8978default of"auto".Fix approach
Caller-side overlay. Keeps the resolver pure; aligns with the same pattern PR 7 (catalog #20) uses for the
model/modelProvidercolumns:src/agents/acp-runtime-overlay.ts— exportsapplyAcpRuntimeOverlay(meta, sessionKey). WhenisAcpSessionKey(sessionKey)is true, returns{ id: "acpx", source: "session-key" }; otherwise returnsmetaunchanged.AgentRuntimeMetadata.sourceunion with"session-key". Two downstream type unions (GatewayAgentRuntime.source,AgentListEntry.agentRuntime.source) needed the same| "session-key"addition for type compatibility — included as additive type-propagation.resolveModelAgentRuntimeMetadatacalls the overlay with the session key. The 6 emit sites all already call this resolver and inherit the fix automatically — no per-call-site change needed.resolveAgentRuntimeMetadataleft untouched as the02fe0d8978stub. The original implementation attempted to revert that contributor's intentional refactor (which had stubbedresolveAgentRuntimeMetadatato return{ id: "auto", source: "implicit" }); after review, the stub-revert was undone in cleanup commit952afa3114to respect the upstream direction. Production already routes throughresolveModelAgentRuntimeMetadata, where the overlay correctly applies.Tests
src/commands/sessions.acp-runtime-metadata.test.ts— 3 cases:"auto"(the post-02fe0d8978default) — overlay must take precedence"acpx"— overlay sentinel"acpx"sentinel (control)src/commands/(vitest.commands.config.ts shard) — passing.952afa3114): reverted the unauthorized stub-restoration, kept the production overlay, retargeted the test atresolveModelAgentRuntimeMetadata.Catalog reference
Catalog finding: #18. Investigation lives in branch
edpiva/acp-native-session-investigation(not yet upstream) atdocs/plans/2026-05-08-acp-findings-catalog.md.Verification commands
Updates
Bot feedback addressed (P2, commit
d4a6eb0b92): the overlay now readsentry.acp.backendinstead of hard-coding"acpx". When a session entry carries an explicitacp.backend(configurable ACP backend, binding/agent override, or persistedentry.acp.backend), that value is used as the runtime id. Fallback to"acpx"only when no backend is set on the entry.acpBackendis threaded from call sites that have the session entry in scope (sessions.ts,session-utils.ts,server-methods/sessions.ts,status.summary.runtime.ts); call sites without an entry in scope (agents-list-tool.ts,session-utils.tsagent-list path,doctor-claude-cli.ts) continue to receive the"acpx"fallback. Two new test cases added: one proving a custom backend is reported, one proving the fallback fires when no backend is set. All 5 test cases green.Notes for reviewers
"pi"is stale —02fe0d8978shifted unrecognized-model default to"auto". The actual production-path bug is the ACP runtime not being identified at all; this PR fixes that without touchingresolveAgentRuntimeMetadata's stub.src/shared/session-types.ts,src/agents/tools/agents-list-tool.ts) add| "session-key"to keep the gateway/tools row types compatible with the new source variant. Additive only.acp-runtime-overlay.tshelper is reused by PR 7 (catalog Heartbeat skipped when last inbound message is from a group chat #20 —model/modelProviderACP-aware), which currently inlines the equivalent logic awaiting this PR. After both land, PR 7 can be slimmed via a small follow-up to import from this file.Real behavior proof
Behavior addressed: ACP control-plane rows from
openclaw sessions --json, status, and Gateway session RPC metadata now report ACP runtime metadata from persisted ACP session metadata/backend instead of the implicit model runtime. ACP-shaped bridge rows withoutentry.acpare not overlaid.Real environment tested: Maintainer Linux worktree at PR SHA
4ebbf1d7e9242924df520cdaefd1f2e3bedc91dc, rebased on upstream/main97ed9b2d82950dd64b94c4fd1ac732e701b54a24. Earlier Azure Crabbox seeded-session proof for the original runtime overlay ran onamber-lobster/cbx_4c7c7efb6dc7; the new bridge guard was verified locally after the rebase fix.Exact steps or command run after this patch: Seeded a temp
OPENCLAW_CONFIG_PATHand explicit session store with an ACP control-plane row carryingentry.acp.backend = "acpx", an ACP-shaped bridge row with noentry.acp, and a non-ACP control row, then ran:Evidence after fix: Copied terminal output from the after-fix CLI run and focused tests:
Observed result after fix: The ACP control-plane session row reports
agentRuntime.id: "acpx"andsource: "session-key"; the ACP-shaped bridge row keepsmodelProvider: "microsoft-foundry",model: "gpt-5.3-codex", and normal implicit runtime metadata, so key shape alone no longer triggers the ACP runtime overlay.What was not tested: No live ACP provider/harness turn with external credentials was run after the maintainer rebase fix; this was seeded session-store CLI proof plus focused regression/type/format checks.