Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions packages/agent-chat/src/ranch-shell/AgentOwnerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ function resolvePricingModelId(
detail: MyAgentSummary,
supported: string[] = [],
): string {
// Saved listing wins unless it is a leftover OpenRouter shelf id.
const listed = (detail.token_pricing?.model_id || "").trim();
// Heartbeat default wins. Stale listing must not impersonate the machine.
const runtime = (detail.runtime_model_id || "").trim();
if (listed && !listingIsStaleOpenRouter(listed, runtime, supported)) return listed;
if (runtime) return runtime;
const listed = (detail.token_pricing?.model_id || "").trim();
if (listed && !listingIsStaleOpenRouter(listed, runtime, supported)) return listed;
const preferred = (detail.preferred_model_id || "").trim();
if (preferred) return preferred;
return FALLBACK_MODEL_ID;
Expand Down Expand Up @@ -1554,11 +1554,15 @@ export function AgentOwnerSettings({
return row;
})
.catch((err: unknown) => {
const code = err instanceof ChatGatewayError ? err.code : "";
const msg =
err instanceof ChatGatewayError && err.message.trim()
? err.message.trim()
: t.myAgentsPricingFailed;
code === "agent_unreachable"
? t.myAgentsPricingNoAck
: err instanceof ChatGatewayError && err.message.trim()
? err.message.trim()
: t.myAgentsPricingFailed;
setPricingError(msg);
setModelIdDraft(resolvePricingModelId(detail, supportedModels));
return null;
})
.finally(() => setSavingPricing(false));
Expand Down Expand Up @@ -2677,7 +2681,7 @@ export function AgentOwnerSettings({
disabled={!canSaveAny}
onClick={saveAll}
>
{saving ? t.loading : t.save}
{savingPricing ? t.myAgentsPricingSyncing : saving ? t.loading : t.save}
</button>
) : null}
<button
Expand Down
6 changes: 6 additions & 0 deletions packages/agent-chat/src/ranch-shell/RanchChatShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ function pickComposerModelForPath(args: {
(sameModelId(args.wanted, args.listed) ? args.listed : null)
);
}
if (args.runtime && modelFitsComposerPath(args.runtime, path)) {
return (
args.fallback.find((item) => sameModelId(item, args.runtime)) ||
args.runtime
);
}
if (
args.listed &&
!listingIsStaleOpenRouter(args.listed, args.runtime, args.fallback) &&
Expand Down
6 changes: 6 additions & 0 deletions packages/agent-chat/src/ranch-shell/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ export type RanchMessages = {
myAgentsSavePricing: string;
myAgentsPricingSaved: string;
myAgentsPricingFailed: string;
myAgentsPricingSyncing: string;
myAgentsPricingNoAck: string;
myAgentsNameHint: string;
myAgentsDescHint: string;
myAgentsDescClearHint: string;
Expand Down Expand Up @@ -955,6 +957,8 @@ const en: RanchMessages = {
myAgentsSavePricing: "Save default model & markup",
myAgentsPricingSaved: "Pricing saved",
myAgentsPricingFailed: "Couldn’t save pricing.",
myAgentsPricingSyncing: "Syncing to the agent…",
myAgentsPricingNoAck: "The agent did not confirm the new default. Nothing was saved.",
myAgentsNameHint: "2–100 characters, at least one letter",
myAgentsDescHint: "10–500 characters",
myAgentsDescClearHint: "Description can’t be cleared here — leave as-is or write 10+ characters.",
Expand Down Expand Up @@ -1526,6 +1530,8 @@ const zh: RanchMessages = {
myAgentsSavePricing: "保存默认模型与上浮",
myAgentsPricingSaved: "定价已保存",
myAgentsPricingFailed: "保存定价失败。",
myAgentsPricingSyncing: "正在同步到机上…",
myAgentsPricingNoAck: "机上没有回执,未保存。",
myAgentsNameHint: "2–100 字,至少含一个字母",
myAgentsDescHint: "10–500 字",
myAgentsDescClearHint: "此处无法清空描述——保持原样,或填写 10 字以上。",
Expand Down
Loading