Skip to content

[codex] Map ACP thinking to advertised effort key - #79926

Merged
steipete merged 3 commits into
openclaw:mainfrom
InTheCloudDan:codex/acp-thinking-effort-mapping
May 9, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
InTheCloudDan:codex/acp-thinking-effort-mapping

Conversation

@InTheCloudDan

@InTheCloudDan InTheCloudDan commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a canonical ACP runtime-option mapping layer that resolves OpenClaw options to backend-advertised config keys before calling session/set_config_option.
  • Keep OpenClaw state canonical (thinking, permissionProfile, timeoutSeconds) while supporting backend wire aliases such as effort, reasoning_effort, thought_level, permissions, and timeout_seconds.
  • Apply the mapping for both automatic pre-turn runtime controls and explicit setSessionConfigOption updates.
  • Document the canonical option mapping and add regression coverage for Claude/Codex/Gemini-style config key dialects.

Root Cause

Claude ACP advertises effort instead of thinking. OpenClaw persisted the abstract runtime option as thinking, then rejected the pre-turn config update because the backend advertised a strict key list that did not contain thinking. In a fresh real acpx Claude session, capabilities can also omit configOptionKeys while session/status.details.configOptions advertises mode, model, and effort; this path still needed the same canonical-to-wire-key translation. The inverse parser also treated plain effort as an opaque backend extra instead of canonical thinking state.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed:
    Claude ACP/acpx rejects the OpenClaw canonical runtime option key thinking because the real adapter advertises effort instead. This patch maps canonical OpenClaw thinking state to the backend-advertised wire key while keeping persisted OpenClaw runtime options canonical.

  • Real environment tested:
    Local OpenClaw gateway/install on May 9, 2026 after hot-patching the installed 2026.5.9-beta.1 bundle with this branch's ACP control-plane changes and restarting the LaunchAgent gateway. openclaw --version reported OpenClaw 2026.5.9-beta.1 (0d3141e). Gateway was 2026.5.9-beta.1, LaunchAgent pid 14036, using the NVM install at /Users/danobrien/.nvm/versions/node/v24.13.0/lib/node_modules/openclaw/dist/index.js. The acpx plugin was @openclaw/[email protected], dependency [email protected], with @agentclientprotocol/[email protected].

  • Exact steps or command run after this patch:
    Patched the installed OpenClaw gateway bundle with this branch's control-plane changes, ran node --check /Users/danobrien/.nvm/versions/node/v24.13.0/lib/node_modules/openclaw/dist/manager-CgmKcnsi.js, restarted the real gateway with /Users/danobrien/.nvm/versions/node/v24.13.0/bin/openclaw gateway restart, then ran a one-off node --input-type=module script that imported the installed OpenClaw config/session manager, loaded the installed @openclaw/acpx runtime service, initialized a fresh real Claude ACP session, called manager.setSessionConfigOption({ key: "thinking", value: "low" }), called manager.setSessionConfigOption({ key: "thinking", value: "high" }), read status, and closed/cleared the proof session.

  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):
    Copied live terminal output from the fresh real Claude ACP session:

    {
      "proofTimestamp": "2026-05-09T19:10:04.918Z",
      "openclawVersion": "2026.5.9-beta.1 (installed gateway package)",
      "acpxPluginVersion": "2026.5.9-beta.1",
      "acpxDependencyVersion": "0.7.0",
      "sessionKey": "agent:claude:acp:proof-thinking-4fc9ed05-b157-411e-89f8-bc1a58650560",
      "backend": "acpx",
      "agent": "claude",
      "runtimeSessionName": "acpx:v2:<redacted>",
      "acpxRecordId": "agent:claude:acp:proof-thinking-4fc9ed05-b157-411e-89f8-bc1a58650560",
      "backendSessionId": "de61dc19-2381-4773-8a31-3eede62f57c7",
      "advertisedConfigKeysFromStatus": [
        "mode",
        "model",
        "effort"
      ],
      "beforeRuntimeOptions": {
        "cwd": "/Users/danobrien/.openclaw/workspace"
      },
      "setThinkingLowReturned": {
        "thinking": "low",
        "cwd": "/Users/danobrien/.openclaw/workspace"
      },
      "setThinkingHighReturned": {
        "thinking": "high",
        "cwd": "/Users/danobrien/.openclaw/workspace"
      },
      "afterRuntimeOptions": {
        "thinking": "high",
        "cwd": "/Users/danobrien/.openclaw/workspace"
      },
      "runtimeStatusSummary": "session=agent:claude:acp:proof-thinking-4fc9ed05-b157-411e-89f8-bc1a58650560 backendSessionId=de61dc19-2381-4773-8a31-3eede62f57c7 pid=14549 open",
      "cleanup": {
        "runtimeClosed": true,
        "metaCleared": true
      }
    }
  • Observed result after fix:
    The real Claude ACP adapter advertised effort, not thinking, while both setSessionConfigOption({ key: "thinking" }) calls completed successfully. OpenClaw returned and persisted canonical thinking runtime state (low, then high) instead of surfacing the previous ACP Internal error / Unknown config option: thinking failure. The proof session was closed and metadata was cleared after the check.

  • What was not tested:
    No known gaps for the Claude/acpx regression path. Gemini and Codex provider dialects were covered by manager regression tests, but I did not run live Gemini or Codex ACP sessions in this local proof.

  • Before evidence (optional but encouraged):
    Before the status-derived key refinement, the same real local Claude/acpx path reproduced the original failure as AcpRuntimeError: Internal error, caused by ACP data { details: "Unknown config option: thinking" }.

Validation

  • pnpm exec oxfmt --check src/acp/control-plane/manager.core.ts src/acp/control-plane/manager.runtime-controls.ts src/acp/control-plane/manager.test.ts
  • git diff --check
  • pnpm vitest src/acp/control-plane/manager.test.ts
  • pnpm tsgo:core:test

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
@clawsweeper

clawsweeper Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR adds ACP runtime-option alias resolution, status-derived config option key discovery, ACP docs updates, and manager regression tests for canonical option mapping.

Reproducibility: yes. Source and dependency inspection show current main sends canonical thinking while Claude ACP advertises/enforces effort; the linked issue comments and PR proof cover the real runtime failure path.

Real behavior proof
Sufficient (live_output): The PR body includes copied live output from a real Claude/acpx session after the fix showing effort advertised, canonical thinking writes succeeding, and cleanup completed.

Next step before merge
A narrow automated repair can complete the permission_mode inverse mapping and test coverage without changing the broader ACP timeout policy.

Security
Cleared: The diff changes ACP runtime-option mapping, docs, and tests only; it does not add dependencies, workflow permissions, downloaded artifacts, lifecycle scripts, or secret handling.

Review findings

  • [P3] Canonicalize permission_mode updates — src/acp/control-plane/runtime-options.ts:24
Review details

Best possible solution:

Merge the focused thinking/effort alias mapping after completing the small permission_mode inverse-mapping gap, and leave the broader timeout/fail-soft policy to the canonical ACP config-option follow-ups.

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

Yes. Source and dependency inspection show current main sends canonical thinking while Claude ACP advertises/enforces effort; the linked issue comments and PR proof cover the real runtime failure path.

Is this the best way to solve the issue?

Yes for the central thinking/effort bug. The alias resolver is narrow and keeps OpenClaw state canonical while sending backend-advertised keys, but permission_mode should be added to the inverse parser for consistency with the new alias table and docs.

Full review comments:

  • [P3] Canonicalize permission_mode updates — src/acp/control-plane/runtime-options.ts:24
    The new alias table advertises permission_mode as a permissionProfile wire alias, but inferRuntimeOptionPatchFromConfigOption does not recognize it. An explicit /acp set permission_mode strict can be sent to a backend that advertises that key, yet OpenClaw will persist it as a backend extra instead of canonical permissionProfile; add the inverse mapping and a focused test.
    Confidence: 0.88

Overall correctness: patch is correct
Overall confidence: 0.87

Acceptance criteria:

  • pnpm exec oxfmt --check src/acp/control-plane/runtime-options.ts src/acp/control-plane/manager.test.ts
  • pnpm test src/acp/control-plane/manager.test.ts

What I checked:

  • Current main sends canonical ACP config keys: buildRuntimeConfigOptionPairs on current main emits canonical keys including thinking, approval_policy, and timeout before any advertised-key translation. (src/acp/control-plane/runtime-options.ts:316, a2aab81e059c)
  • Current main rejects strict advertised-key mismatches: applyManagerRuntimeControls builds config options and rejects a key when capabilities.configOptionKeys is present and does not contain the generated key, which matches the reported thinking vs effort failure mode. (src/acp/control-plane/manager.runtime-controls.ts:64, a2aab81e059c)
  • Claude ACP advertises and enforces effort: The published @agentclientprotocol/[email protected] package builds a config option with id effort and rejects setSessionConfigOption calls whose configId is not in the session config option list.
  • PR maps canonical thinking to advertised aliases: The PR adds RUNTIME_CONFIG_OPTION_ALIASES, resolveRuntimeConfigOptionKey, status-derived config option key extraction, and uses the resolved wire key for both pre-turn and explicit config writes. (src/acp/control-plane/runtime-options.ts:21, b55015da431c)
  • PR adds focused regression coverage: The new manager tests cover pre-turn thinking to effort, generic alias mapping, explicit thinking updates via status-derived config options, and canonical persistence for explicit native effort. (src/acp/control-plane/manager.test.ts:3008, b55015da431c)
  • Real behavior proof is now supplied: The PR body includes copied live output from a local OpenClaw 2026.5.9-beta.1 gateway using @openclaw/[email protected] and Claude ACP where the adapter advertised effort, setSessionConfigOption({ key: "thinking" }) succeeded for low and high, and OpenClaw persisted canonical thinking. (b55015da431c)

Likely related people:

  • osolmaz: The ACP thread-bound agents work introduced the central ACP control-plane runtime option and manager paths involved in this bug class. (role: introduced behavior; confidence: high; commits: a7d56e3554d0; files: src/acp/control-plane/runtime-options.ts, src/acp/control-plane/manager.runtime-controls.ts, src/acp/control-plane/manager.core.ts)
  • steipete: Recent local history and blame show repeated maintenance on the ACP control-plane files and adjacent acpx runtime surface, including the current main lines inspected here. (role: recent maintainer; confidence: medium; commits: bafe49f0620d, eeef4864494f, 5659d7f985eb; files: src/acp/control-plane/runtime-options.ts, src/acp/control-plane/manager.runtime-controls.ts, src/acp/control-plane/manager.core.ts)

Remaining risk / open question:

  • The broader unsupported Claude ACP timeout/config-option behavior remains open in BUG: ACP runtime sends unsupported config options to Claude ACP adapter #73875 and related PRs, so this PR should not be treated as the full fix for that whole class.
  • I did not rerun a live Claude ACP session locally in this read-only review; the real behavior proof assessment relies on the PR body's copied live output plus source and dependency inspection.

Codex review notes: model gpt-5.5, reasoning high; reviewed against a1fe4ae646eb.

@InTheCloudDan
InTheCloudDan force-pushed the codex/acp-thinking-effort-mapping branch from 648192b to a79fe7b Compare May 9, 2026 18:42
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M and removed size: S labels May 9, 2026
@InTheCloudDan
InTheCloudDan force-pushed the codex/acp-thinking-effort-mapping branch from a79fe7b to af0f0f9 Compare May 9, 2026 19:14
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
@InTheCloudDan
InTheCloudDan marked this pull request as ready for review May 9, 2026 19:19
@InTheCloudDan
InTheCloudDan force-pushed the codex/acp-thinking-effort-mapping branch from af0f0f9 to b55015d Compare May 9, 2026 19:25
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@steipete
steipete force-pushed the codex/acp-thinking-effort-mapping branch from b55015d to f954cb0 Compare May 9, 2026 23:02
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@steipete
steipete merged commit c2f4f25 into openclaw:main May 9, 2026
110 checks passed
@steipete

steipete commented May 9, 2026

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

Proof:

  • Local: pnpm exec oxfmt --check --threads=1 src/acp/control-plane/runtime-options.ts src/acp/control-plane/manager.test.ts CHANGELOG.md; pnpm test src/acp/control-plane/manager.test.ts; git diff --check; pnpm tsgo:core:test
  • CI blocker fix: pnpm exec oxfmt --check --threads=1 extensions/amazon-bedrock/index.test.ts; pnpm lint:plugins:no-extension-test-core-imports; pnpm test extensions/amazon-bedrock/index.test.ts
  • GitHub CI: exact PR head 45c6c45 passed before merge
  • Issue: closed BUG: ACP runtime sends unsupported config options to Claude ACP adapter #73875 as fixed

Thanks @InTheCloudDan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation proof: supplied External PR includes structured after-fix real behavior proof. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants