fix: route native status to active agent

This commit is contained in:
Peter Steinberger
2026-01-20 19:04:25 +00:00
parent 5c4079f66c
commit 243a8b019e
4 changed files with 61 additions and 12 deletions

View File

@@ -242,4 +242,44 @@ describe("trigger handling", () => {
);
});
});
it("uses the target agent model for native /status", async () => {
await withTempHome(async (home) => {
const cfg = {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: join(home, "clawd"),
},
list: [{ id: "coding", model: "minimax/MiniMax-M2.1" }],
},
channels: {
telegram: {
allowFrom: ["*"],
},
},
session: { store: join(home, "sessions.json") },
};
const res = await getReplyFromConfig(
{
Body: "/status",
From: "telegram:111",
To: "telegram:111",
ChatType: "group",
Provider: "telegram",
Surface: "telegram",
SessionKey: "telegram:slash:111",
CommandSource: "native",
CommandTargetSessionKey: "agent:coding:telegram:group:123",
CommandAuthorized: true,
},
{},
cfg,
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("minimax/MiniMax-M2.1");
});
});
});

View File

@@ -29,8 +29,11 @@ export async function getReplyFromConfig(
configOverride?: ClawdbotConfig,
): Promise<ReplyPayload | ReplyPayload[] | undefined> {
const cfg = configOverride ?? loadConfig();
const targetSessionKey =
ctx.CommandSource === "native" ? ctx.CommandTargetSessionKey?.trim() : undefined;
const agentSessionKey = targetSessionKey || ctx.SessionKey;
const agentId = resolveSessionAgentId({
sessionKey: ctx.SessionKey,
sessionKey: agentSessionKey,
config: cfg,
});
const agentCfg = cfg.agents?.defaults;