fix: add nested agent log context

This commit is contained in:
Peter Steinberger
2026-01-17 18:59:52 +00:00
parent 0e49dca53c
commit 96df70fccf
3 changed files with 69 additions and 1 deletions

View File

@@ -219,4 +219,43 @@ describe("deliverAgentCommandResult", () => {
expect.objectContaining({ channel: "telegram", to: "123" }),
);
});
it("prefixes nested agent outputs with context", async () => {
const cfg = {} as ClawdbotConfig;
const deps = {} as CliDeps;
const runtime = {
log: vi.fn(),
error: vi.fn(),
} as unknown as RuntimeEnv;
const result = {
payloads: [{ text: "ANNOUNCE_SKIP" }],
meta: {},
};
const { deliverAgentCommandResult } = await import("./agent/delivery.js");
await deliverAgentCommandResult({
cfg,
deps,
runtime,
opts: {
message: "hello",
deliver: false,
lane: "nested",
sessionKey: "agent:main:main",
runId: "run-announce",
messageChannel: "webchat",
},
sessionEntry: undefined,
result,
payloads: result.payloads,
});
expect(runtime.log).toHaveBeenCalledTimes(1);
const line = String(runtime.log.mock.calls[0]?.[0]);
expect(line).toContain("[agent:nested]");
expect(line).toContain("session=agent:main:main");
expect(line).toContain("run=run-announce");
expect(line).toContain("channel=webchat");
expect(line).toContain("ANNOUNCE_SKIP");
});
});