Skip to content

Commit bf93d5a

Browse files
committed
fix(agents): publish resolved model identity in agents_list output
agents_list exposed the raw configured primary (routing alias) as the model field while agentRuntime was derived from the resolved model, giving agents two contradictory identities. Publish the resolved provider/model from resolveDefaultModelForAgent instead, matching the gateway agents.list fix (#122907).
1 parent 7eaf2fc commit bf93d5a

2 files changed

Lines changed: 49 additions & 8 deletions

File tree

‎src/agents/tools/agents-list-tool.test.ts‎

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,49 @@ describe("agents_list tool", () => {
8383
});
8484
});
8585

86+
it("resolves configured model aliases to the canonical model identity", async () => {
87+
// Routing aliases are transport-level names; the tool must publish the
88+
// resolved model that will actually run so spawn decisions see one identity.
89+
loadConfigMock.mockReturnValue({
90+
agents: {
91+
defaults: {
92+
model: {
93+
primary: "clawrouter/openai/gpt-5.6",
94+
fallbacks: ["openai/gpt-5.6-luna"],
95+
},
96+
models: {
97+
"openai/gpt-5.6-sol": {
98+
alias: "clawrouter/openai/gpt-5.6",
99+
agentRuntime: { id: "codex" },
100+
},
101+
},
102+
subagents: { allowAgents: ["main"] },
103+
},
104+
list: [{ id: "main", default: true }],
105+
},
106+
} as unknown as OpenClawConfig);
107+
108+
const result = await createAgentsListTool({ agentSessionKey: "agent:main:main" }).execute(
109+
"call",
110+
{},
111+
);
112+
const details = result.details as AgentListDetails;
113+
114+
expect(details).toStrictEqual({
115+
requester: "main",
116+
allowAny: false,
117+
agents: [
118+
{
119+
id: "main",
120+
name: undefined,
121+
configured: true,
122+
model: "openai/gpt-5.6-sol",
123+
agentRuntime: { id: "codex", source: "model" },
124+
},
125+
],
126+
});
127+
});
128+
86129
it("does not advertise stale allowlist-only targets as spawnable agents", async () => {
87130
// Allowlist entries are permissions, not agent definitions; stale ids should
88131
// not be presented as runnable subagents.
@@ -132,7 +175,7 @@ describe("agents_list tool", () => {
132175
id: "main",
133176
name: undefined,
134177
configured: true,
135-
model: undefined,
178+
model: "openai/gpt-5.6-sol",
136179
agentRuntime: { id: "codex", source: "implicit" },
137180
},
138181
],
@@ -201,7 +244,7 @@ describe("agents_list tool", () => {
201244
id: "strict",
202245
name: undefined,
203246
configured: true,
204-
model: undefined,
247+
model: "openai/gpt-5.6-sol",
205248
agentRuntime: { id: "codex", source: "implicit" },
206249
},
207250
],

‎src/agents/tools/agents-list-tool.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import { getRuntimeConfig } from "../../config/config.js";
88
import { normalizeAgentId } from "../../routing/session-key.js";
99
import { resolveModelAgentRuntimeMetadata } from "../agent-runtime-metadata.js";
1010
import { listAgentEntries, listAgentIds } from "../agent-scope-config.js";
11-
import {
12-
resolveAgentConfig,
13-
resolveAgentEffectiveModelPrimary,
14-
resolveSessionAgentIds,
15-
} from "../agent-scope.js";
11+
import { resolveAgentConfig, resolveSessionAgentIds } from "../agent-scope.js";
1612
import { resolveDefaultModelForAgent } from "../model-selection.js";
1713
import { resolveSubagentAllowedTargetIds } from "../subagents/spawn/subagent-target-policy.js";
1814
import type { AnyAgentTool } from "./common.js";
@@ -132,8 +128,10 @@ export function createAgentsListTool(opts?: {
132128
.toSorted((a, b) => a.localeCompare(b));
133129
const ordered = all.includes(requesterAgentId) ? [requesterAgentId, ...rest] : rest;
134130
const agents: AgentListEntry[] = ordered.map((id) => {
135-
const model = resolveAgentEffectiveModelPrimary(cfg, id);
136131
const resolvedModel = resolveDefaultModelForAgent({ cfg, agentId: id });
132+
// Publish the resolved identity (aliases are routing-only) so the model
133+
// field matches the agentRuntime derived from the same resolvedModel.
134+
const model = `${resolvedModel.provider}/${resolvedModel.model}`;
137135
const agentRuntime = resolveModelAgentRuntimeMetadata({
138136
cfg,
139137
agentId: id,

0 commit comments

Comments
 (0)