Skip to content

fix(agents): honor ACP alias model.primary overrides (Fixes #87381)#87404

Closed
deepujain wants to merge 1 commit into
openclaw:mainfrom
deepujain:fix/87381-acp-agent-model-primary
Closed

fix(agents): honor ACP alias model.primary overrides (Fixes #87381)#87404
deepujain wants to merge 1 commit into
openclaw:mainfrom
deepujain:fix/87381-acp-agent-model-primary

Conversation

@deepujain

@deepujain deepujain commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #87381

When sessions_spawn(runtime="acp") targets an OpenClaw agent alias backed by runtime.type="acp", ACP session initialization only forwarded an explicit model argument from the tool call. If the caller omitted model, the spawn path ignored the alias agent's configured model.primary, even though the alias had already resolved to the correct ACP harness id.

This patch keeps the fix narrow:

  • preserve explicit sessions_spawn.model precedence
  • when the requested agentId is a configured ACP alias, fall back to that alias agent's effective model before initializing the ACP session
  • keep raw ACP harness ids like codex unchanged so unrelated ACP spawns do not start inheriting config from some other alias

I did not change the separate Claude startup-env/model-switch behavior discussed later on the issue. This PR only fixes the missing OpenClaw-side model routing on the ACP alias spawn path.

Tests and validation

  • node scripts/run-vitest.mjs src/agents/acp-spawn.test.ts
  • git diff --check

Real behavior proof

Behavior addressed:

  • ACP alias spawns now pass the configured alias model into ACP session initialization even when the caller does not send an explicit model.

Environment tested:

  • macOS, Node v22, PR branch dbac0720

Exact validation:

  • node scripts/run-vitest.mjs src/agents/acp-spawn.test.ts --reporter=verbose

Evidence after the fix:

  • spawnAcpDirect > maps OpenClaw ACP runtime agent aliases to their configured harness id passes while asserting runtimeOptions.model = "openai/gpt-5.5-mini"
  • spawnAcpDirect > does not inherit configured alias model defaults for raw ACP harness ids passes while asserting raw harness-id spawns still leave runtimeOptions unset
  • the four invariant cases called out in the issue were also checked in a standalone logic reproduction: alias without explicit model, alias with explicit model, raw harness id, and a second alias resolving a different configured model

Observed result:

  • the focused ACP spawn suite passed, and the updated proof covers both alias-model fallback and raw-harness isolation on the PR branch

What was not tested:

  • I still did not run a live Claude/acpx process launch against a local ACP backend in this environment

Proof limitation:

  • this remains source-level/runtime-harness proof rather than a live external Claude session repro

Risk

Low to medium. The patch only changes ACP spawn model fallback when the requested agentId is a configured OpenClaw ACP alias and no explicit model was supplied. Explicit model overrides still win, and raw external harness ids keep their previous behavior.

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

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close: current main and release v2026.6.6 already fix the ACP alias model propagation problem through #88946, and this branch is now a less safe merge candidate because it uses broader effective-model fallback semantics.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the shipped v2026.6.6 implementation from #88946 and close this branch rather than reviving its broader fallback semantics.

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

No for current main: the old source path is fixed by current main and shipped in v2026.6.6. The pre-fix issue was source-reproducible from ACP spawn passing only params.model and acpx requiring sessionOptions.model.

Is this the best way to solve the issue?

No, this branch is no longer the best way to solve the issue. Current main fixes the same user problem with the existing subagent/agent model-selection seam plus acpx sessionOptions mapping, avoiding the branch's broader global-default fallback.

Security review:

Security review cleared: The diff changes TypeScript ACP model-routing logic and tests only; it does not touch dependencies, workflows, secrets, install scripts, or package metadata.

AGENTS.md: found and applied where relevant.

What I checked:

  • Root and scoped policy read: Root AGENTS.md and src/agents/AGENTS.md were read fully; ACP model routing is provider/config-sensitive under the repository review policy, and agent tests should stay focused/lightweight where possible. (AGENTS.md:1, 889bc52ba5b3)
  • Current main resolves configured ACP alias model options: Current main computes ACP runtime options through resolveConfiguredSubagentSpawnModelSelection using the configured alias id when present, then passes those runtimeOptions to ACP initialization. (src/agents/acp-spawn.ts:1021, 889bc52ba5b3)
  • Current main tests the fixed alias model behavior: The focused ACP spawn test now asserts a configured runtime=acp agent primary model is sent as runtimeOptions.model before ACP startup. (src/agents/acp-spawn.test.ts:1043, 889bc52ba5b3)
  • Current main maps OpenClaw model into acpx sessionOptions: AcpxRuntime now converts input.model into sessionOptions.model before calling the delegate, covering the second half of the reported ACPX handoff bug. (extensions/acpx/src/runtime.ts:579, 889bc52ba5b3)
  • acpx dependency contract inspected: The acpx 0.10.0 package types expose sessionOptions.model, and runtime.js reads input.sessionOptions?.model for requested model application and persistence. (package/dist/session-options-Bh1bIqQ2.d.ts:87)
  • Codex source contract checked: Sibling Codex source accepts explicit --model and model_reasoning_effort config controls, matching OpenClaw's Codex ACP startup-control normalization path. (../codex/sdk/typescript/src/exec.ts:102, 51316ead4a43)

Likely related people:

  • steipete: Authored the merged fix commit and Fix live model inference edge cases #88946, which fixed ACP startup model propagation and closed the linked issue. (role: recent area contributor; confidence: high; commits: bc78cd5f8ab6; files: src/agents/acp-spawn.ts, src/agents/acp-spawn.test.ts, extensions/acpx/src/runtime.ts)
  • vincentkoc: Current checkout blame and the v2026.6.6 release tag point to Vincent Koc carrying the released source snapshot that contains the fixed ACP model behavior. (role: recent release/current-main owner; confidence: medium; commits: 8c802aa68351, 97c5e6c2359a; files: src/agents/acp-spawn.ts, src/agents/acp-spawn.test.ts, extensions/acpx/src/runtime.ts)
  • Onur Solmaz: Earlier history introduced ACP thread-bound agents and the acpx runtime-library consumption that this model-routing path builds on. (role: ACP feature history owner; confidence: medium; commits: a7d56e3554d0, 154a7edb7cad; files: src/agents/acp-spawn.ts, extensions/acpx/src/runtime.ts, src/acp/control-plane/manager.core.ts)

Codex review notes: model internal, reasoning high; reviewed against 889bc52ba5b3; fix evidence: release v2026.6.6, commit bc78cd5f8ab6.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 27, 2026
@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@xiaoxuesheng123467

Copy link
Copy Markdown

Real Behavior Proof

Reproduced on macOS, Node v22, commit dbac0720 (PR branch).

1. Focused test suite (vitest)

$ node scripts/run-vitest.mjs src/agents/acp-spawn.test.ts --reporter=verbose

 ✓ spawnAcpDirect > maps OpenClaw ACP runtime agent aliases to their configured harness id 1ms
 ✓ spawnAcpDirect > does not inherit configured alias model defaults for raw ACP harness ids 1ms

 Tests  116 passed (116)

Test 1 — alias model resolution:

  • Config: agent reviewer with model.primary: "openai/gpt-5.5-mini", runtime.type: "acp", acp.agent: "codex"
  • Spawn: agentId="reviewer", no model param
  • Assert: initializeSession receives runtimeOptions.model = "openai/gpt-5.5-mini"

Test 2 — raw harness id isolation:

  • Same alias config present
  • Spawn: agentId="codex" (raw harness id, not the alias), no model param
  • Assert: initializeSession receives runtimeOptions as undefined (no model leak)

2. Standalone logic reproduction

Extracted the core resolution logic from acp-spawn.ts (lines 1270–1278) into a standalone script to verify the four key invariants:

$ node scripts/proof-standalone.mjs

Scenario 1: spawn ACP alias without model param
  PASS: alias model.primary is used → "provider/specific-model-a"

Scenario 2: spawn ACP alias WITH explicit model
  PASS: explicit model wins → "override/model"

Scenario 3: spawn raw harness id (not an alias)
  PASS: raw harness id gets no model → undefined

Scenario 4: different alias resolves different model
  PASS: different alias resolves different model → "provider/specific-model-b"

Results: 4 passed, 0 failed

3. Source-level walkthrough

The fix at src/agents/acp-spawn.ts:1270-1278:

const configuredAcpAliasId = resolveConfiguredAcpRuntimeAliasId({
  requestedAgentId: params.agentId,
  cfg,
});
const resolvedModel =
  params.model ??
  (configuredAcpAliasId
    ? resolveAgentEffectiveModelPrimary(cfg, configuredAcpAliasId)
    : undefined);
  • params.model ?? — explicit caller model always wins (precedence preserved)
  • resolveConfiguredAcpRuntimeAliasId — only returns an ID when requestedAgentId matches a configured agent with runtime.type === "acp"
  • resolveAgentEffectiveModelPrimary — reads the alias's model.primary, falls back to agents.defaults.model.primary
  • Raw harness ids like codex are not in agents.list, so configuredAcpAliasId is undefinedresolvedModel stays undefined

Environment

  • macOS Darwin 25.5.0
  • Node v22.22.3
  • pnpm 11.2.2
  • openclaw commit dbac072 (PR branch)

@xiaoxuesheng123467

Copy link
Copy Markdown

@clawsweeper re-review

@deepujain

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body to include the current proof details already captured on-thread, including the focused vitest run and the direct alias-vs-raw-runtime behavior checks.

@clawsweeper

clawsweeper Bot commented May 28, 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 P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels May 29, 2026
@clawsweeper

clawsweeper Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

@deepujain thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP runtime ignores per-agent model.primary override

3 participants