Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(acp): surface the real claude-agent-acp "default" model (#1415)

simonrosenberga68c47f6ebef
diff --git a/__tests__/api/agent-server-adapter.test.ts b/__tests__/api/agent-server-adapter.test.ts
index 20957fde77..18b3e13aa6 100644
--- a/__tests__/api/agent-server-adapter.test.ts
+++ b/__tests__/api/agent-server-adapter.test.ts
@@ -870,7 +870,12 @@ describe("toAppConversation", () => {
expect(result.llm_model).toBe("Claude Sonnet 4.6");
});
- it("does not surface ACP default placeholders when a configured model exists", () => {
+ it("surfaces the runtime ACP default model over a configured acp_model", () => {
+ // claude-agent-acp 0.44+ exposes ``default`` ("Default (recommended)")
+ // as a real, selectable model in its configOptions select. The runtime
+ // ``current_model_*`` fields take precedence over the configured
+ // ``acp_model``, so a session actually running on ``default`` must
+ // surface that on the chip instead of the stale configured value.
const result = toAppConversation({
...baseInfo,
current_model_id: "default",
@@ -882,7 +887,7 @@ describe("toAppConversation", () => {
},
});
expect(result.agent_kind).toBe("acp");
- expect(result.llm_model).toBe("claude-sonnet-4-6");
+ expect(result.llm_model).toBe("Default (recommended)");
});
it("falls back to a non-sentinel ACP llm.model for SDKs that mirror acp_model there", () => {
@@ -894,11 +899,10 @@ describe("toAppConversation", () => {
expect(result.llm_model).toBe("claude-sonnet-4-6");
});
- it("filters ACP default placeholders surfaced via the configured acp_model", () => {
- // Older settings may have persisted the SDK's literal "default" string
- // into ``acp_model``. Surfacing it on the chip would lie about what's
- // running β€” the placeholder filter is applied to every candidate, not
- // just the runtime fields.
+ it("surfaces ACP default model surfaced via the configured acp_model", () => {
+ // ``default`` / ``Default (recommended)`` is a real claude-agent-acp
+ // model id (not an SDK placeholder), so it must surface like any other
+ // configured model.
const result = toAppConversation({
...baseInfo,
agent: {
@@ -908,17 +912,18 @@ describe("toAppConversation", () => {
},
});
expect(result.agent_kind).toBe("acp");
- expect(result.llm_model).toBeNull();
+ expect(result.llm_model).toBe("Default (recommended)");
});
- it("filters ACP default placeholders surfaced via agent.llm.model", () => {
- // Same defense, one rung lower in the precedence chain.
+ it("surfaces ACP default model surfaced via agent.llm.model", () => {
+ // Same as above, one rung lower in the precedence chain: ``default`` is
+ // a real model id and should surface as-is.
const result = toAppConversation({
...baseInfo,
agent: { kind: "ACPAgent", llm: { model: "default" } },
});
expect(result.agent_kind).toBe("acp");
- expect(result.llm_model).toBeNull();
+ expect(result.llm_model).toBe("default");
});
it("surfaces acp_server from tags.acpserver for ACP conversations", () => {
diff --git a/src/api/agent-server-adapter.ts b/src/api/agent-server-adapter.ts
index 6998da09d4..37b78915ea 100644
--- a/src/api/agent-server-adapter.ts
+++ b/src/api/agent-server-adapter.ts
@@ -317,10 +317,10 @@ export function toAppConversation(
pr_number: [],
agent_kind: isAcp ? "acp" : "openhands",
acp_server: acpServer,
- // Chip path: no ``providerDefault`` β€” the chip must distinguish
- // "no concrete model" (fall back to the provider display name in
- // ConversationCardFooter) from "default" (would lie about what's
- // running on the subprocess).
+ // Chip path: omit ``providerDefault`` so that when no concrete model
+ // resolves, the chip falls back to the provider display name in
+ // ConversationCardFooter rather than a registry default the session may
+ // not actually be running.
llm_model: isAcp
? resolveEffectiveAcpModel({
runtimeName: info.current_model_name,
diff --git a/src/constants/acp-providers.test.ts b/src/constants/acp-providers.test.ts
new file mode 100644
index 0000000000..0994156e6e
--- /dev/null
+++ b/src/constants/acp-providers.test.ts
@@ -0,0 +1,56 @@
+import { describe, expect, it } from "vitest";
+import {
+ ACP_MANAGED_SENTINEL,
+ resolveEffectiveAcpModel,
+} from "./acp-providers";
+
+describe("resolveEffectiveAcpModel", () => {
+ it("surfaces the real claude-agent-acp 0.44+ 'default' model", () => {
+ // ``default`` ("Default (recommended)") is a real, selectable Claude model
+ // in the configOptions select β€” the server reports it as the current model.
+ // It must NOT be suppressed as a placeholder (regression: the chip would
+ // otherwise show no model for a session genuinely running on 'default').
+ expect(resolveEffectiveAcpModel({ runtimeId: "default" })).toBe("default");
+ expect(
+ resolveEffectiveAcpModel({ runtimeName: "Default (recommended)" }),
+ ).toBe("Default (recommended)");
+ });
+
+ it("follows the runtime β†’ configured β†’ sdkLlm precedence", () => {
+ expect(
+ resolveEffectiveAcpModel({
+ runtimeName: "Sonnet",
+ runtimeId: "sonnet",
+ configured: "haiku",
+ }),
+ ).toBe("Sonnet");
+ expect(resolveEffectiveAcpModel({ configured: "haiku" })).toBe("haiku");
+ expect(resolveEffectiveAcpModel({ sdkLlm: "gpt-5.5/medium" })).toBe(
+ "gpt-5.5/medium",
+ );
+ });
+
+ it("still suppresses the legacy acp-managed sentinel and blanks", () => {
+ expect(
+ resolveEffectiveAcpModel({ sdkLlm: ACP_MANAGED_SENTINEL }),
+ ).toBeNull();
+ expect(resolveEffectiveAcpModel({ runtimeId: " " })).toBeNull();
+ expect(resolveEffectiveAcpModel({})).toBeNull();
+ });
+
+ it("falls back to providerDefault only when no concrete model resolves", () => {
+ expect(
+ resolveEffectiveAcpModel({
+ sdkLlm: ACP_MANAGED_SENTINEL,
+ providerDefault: "opus[1m]",
+ }),
+ ).toBe("opus[1m]");
+ // A real 'default' wins over providerDefault β€” it is a concrete model.
+ expect(
+ resolveEffectiveAcpModel({
+ runtimeId: "default",
+ providerDefault: "opus[1m]",
+ }),
+ ).toBe("default");
+ });
+});
diff --git a/src/constants/acp-providers.ts b/src/constants/acp-providers.ts
index 126b3f7c24..9cb627a424 100644
--- a/src/constants/acp-providers.ts
+++ b/src/constants/acp-providers.ts
@@ -17,28 +17,25 @@ export type ACPProviderIcon =
export const ACP_PROVIDER_FALLBACK_ICON: ACPProviderIcon = "cli-generic";
-// SDK placeholder strings the ACP wrapper returns before the user has
-// chosen a real model β€” surfacing either would lie about what's running.
-export const ACP_DEFAULT_PLACEHOLDERS = new Set([
- "default",
- "default (recommended)",
-]);
-
// Sentinel ``agent.llm.model`` returned by older SDKs for ACP conversations
// in lieu of a real model. Suppressed at every consumer that resolves a
// display string.
+//
+// NB: ``"default"`` is NOT a placeholder. claude-agent-acp 0.44+ exposes
+// ``default`` ("Default (recommended)") as a real, selectable model in its
+// configOptions select β€” the server reports it as ``currentModelId`` and lists
+// it in ``availableModels`` β€” so it must surface like any other model id.
export const ACP_MANAGED_SENTINEL = "acp-managed";
/**
- * Filter for "real" ACP model strings β€” non-empty, not the SDK's "default"
- * placeholder, not the legacy ``acp-managed`` sentinel. Returns the trimmed
- * value on success, ``null`` otherwise.
+ * Filter for "real" ACP model strings β€” non-empty and not the legacy
+ * ``acp-managed`` sentinel. Returns the trimmed value on success, ``null``
+ * otherwise.
*/
function realAcpModel(value: unknown): string | null {
if (typeof value !== "string") return null;
const trimmed = value.trim();
if (!trimmed) return null;
- if (ACP_DEFAULT_PLACEHOLDERS.has(trimmed.toLowerCase())) return null;
if (trimmed === ACP_MANAGED_SENTINEL) return null;
return trimmed;
}