Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: strip routing prefix from native model name in conversation chip (#1390) (#1391)

simonrosenberg800c877bf933
diff --git a/__tests__/utils/format-model-name.test.ts b/__tests__/utils/format-model-name.test.ts
new file mode 100644
index 0000000000..d8aa702281
--- /dev/null
+++ b/__tests__/utils/format-model-name.test.ts
@@ -0,0 +1,29 @@
+import { describe, expect, it } from "vitest";
+import { formatNativeModelName } from "#/utils/format-model-name";
+
+describe("formatNativeModelName", () => {
+ it("strips the provider route prefix", () => {
+ expect(formatNativeModelName("anthropic/claude-sonnet-4-5-20250929")).toBe(
+ "claude-sonnet-4-5-20250929",
+ );
+ expect(formatNativeModelName("openai/gpt-4o")).toBe("gpt-4o");
+ });
+
+ it("strips nested routing prefixes to the last segment", () => {
+ expect(formatNativeModelName("litellm_proxy/openai/gpt-4o")).toBe("gpt-4o");
+ });
+
+ it("returns the original string when there is no prefix", () => {
+ expect(formatNativeModelName("gpt-4o")).toBe("gpt-4o");
+ });
+
+ it("falls back to the original string instead of returning empty (trailing slash)", () => {
+ expect(formatNativeModelName("openai/")).toBe("openai/");
+ });
+
+ it("returns null for empty / nullish input", () => {
+ expect(formatNativeModelName("")).toBeNull();
+ expect(formatNativeModelName(null)).toBeNull();
+ expect(formatNativeModelName(undefined)).toBeNull();
+ });
+});
diff --git a/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsx b/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsx
index 61077a381c..31a7b583fd 100644
--- a/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsx
+++ b/src/components/features/conversation-panel/conversation-card/conversation-card-footer.tsx
@@ -10,6 +10,7 @@ import {
labelForAcpModel,
resolveAcpProviderIcon,
} from "#/constants/acp-providers";
+import { formatNativeModelName } from "#/utils/format-model-name";
import {
AgentBrandIcon,
type AgentBrandIconKind,
@@ -93,7 +94,13 @@ export function ConversationCardFooter({
tooltip: modelLabel ? `${providerName} Β· ${modelLabel}` : providerName,
};
} else if (llmModel) {
- chip = { kind: "openhands", text: llmModel, tooltip: llmModel };
+ // Strip the routing prefix (e.g. "anthropic/claude-…" β†’ "claude-…") for
+ // the chip text; keep the full routing string in the tooltip.
+ chip = {
+ kind: "openhands",
+ text: formatNativeModelName(llmModel) ?? llmModel,
+ tooltip: llmModel,
+ };
}
}
diff --git a/src/hooks/use-chat-input-model-state.ts b/src/hooks/use-chat-input-model-state.ts
index 7dc9688221..40dd59333d 100644
--- a/src/hooks/use-chat-input-model-state.ts
+++ b/src/hooks/use-chat-input-model-state.ts
@@ -49,8 +49,8 @@ export function useChatInputModelState(): ChatInputModelState {
let currentModelId: string | null = null;
if (isActiveAcpConversation) {
- // Cloud ACP conversations store llm_model=null (the model lives in the
- // running ACP subprocess, not in the conversation row). Fall back to the
+ // ACP conversations store llm_model as the acp_model (persisted at
+ // creation time). Use it directly if available; fall back to the
// settings-configured model or provider default so the chip stays visible.
currentModelId =
conversation?.llm_model ??
diff --git a/src/utils/format-model-name.ts b/src/utils/format-model-name.ts
new file mode 100644
index 0000000000..6563831a7a
--- /dev/null
+++ b/src/utils/format-model-name.ts
@@ -0,0 +1,21 @@
+/**
+ * Format a native (OpenHands-kind) routing model string for display, stripping
+ * the provider route prefix (e.g. ``"anthropic/claude-sonnet-4-5-20250929"`` β†’
+ * ``"claude-sonnet-4-5-20250929"``, ``"litellm_proxy/openai/gpt-4o"`` β†’
+ * ``"gpt-4o"``) so a conversation chip shows a meaningful model name rather than
+ * the full routing path.
+ *
+ * Returns ``null`` for an empty/nullish input, and falls back to the original
+ * string when stripping the prefix would leave nothing (e.g. a trailing slash)
+ * β€” never an empty string, which would collapse the chip text.
+ *
+ * Display-only: unlike {@link deriveProfileNameFromModel} this does not sanitize
+ * to an identifier, so it keeps the real model id intact for the chip.
+ */
+export function formatNativeModelName(
+ model: string | null | undefined,
+): string | null {
+ if (!model) return null;
+ const lastSegment = model.split("/").pop();
+ return lastSegment || model;
+}