mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 18:50:24 +00:00
fix: fall back to resolved agent dir for btw command
This commit is contained in:
@@ -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?" } },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user