fix: fall back to resolved agent dir for btw command

This commit is contained in:
Peter Steinberger
2026-04-05 08:21:40 +01:00
parent 2aafa8fb7d
commit 9238b98a7a
2 changed files with 29 additions and 2 deletions

View File

@@ -128,4 +128,27 @@ describe("handleBtwCommand", () => {
reply: { text: "nothing important", btw: { question: "what changed?" } },
});
});
it("falls back to the resolved agent dir when the caller omits it", async () => {
const params = buildParams("/btw what changed?");
params.agentId = "worker-1";
params.agentDir = undefined;
params.sessionEntry = {
sessionId: "session-1",
updatedAt: Date.now(),
};
runBtwSideQuestionMock.mockResolvedValue({ text: "resolved fallback" });
const result = await handleBtwCommand(params, true);
expect(runBtwSideQuestionMock).toHaveBeenCalledWith(
expect.objectContaining({
agentDir: expect.stringContaining("/agents/worker-1/agent"),
}),
);
expect(result).toEqual({
shouldContinue: false,
reply: { text: "resolved fallback", btw: { question: "what changed?" } },
});
});
});

View File

@@ -1,3 +1,4 @@
import { resolveAgentDir } from "../../agents/agent-scope.js";
import { runBtwSideQuestion } from "../../agents/btw.js";
import { extractBtwQuestion } from "./btw-command.js";
import { rejectUnauthorizedCommand } from "./command-gates.js";
@@ -32,7 +33,10 @@ export const handleBtwCommand: CommandHandler = async (params, allowTextCommands
};
}
if (!params.agentDir) {
const agentDir =
params.agentDir ?? (params.agentId ? resolveAgentDir(params.cfg, params.agentId) : undefined);
if (!agentDir) {
return {
shouldContinue: false,
reply: {
@@ -45,7 +49,7 @@ export const handleBtwCommand: CommandHandler = async (params, allowTextCommands
await params.typing?.startTypingLoop();
const reply = await runBtwSideQuestion({
cfg: params.cfg,
agentDir: params.agentDir,
agentDir,
provider: params.provider,
model: params.model,
question,