fix: include embedded agent error cause in reply
This commit is contained in:
@@ -131,6 +131,30 @@ describe("trigger handling", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("includes the error cause when the embedded agent throws", async () => {
|
||||||
|
await withTempHome(async (home) => {
|
||||||
|
vi.mocked(runEmbeddedPiAgent).mockRejectedValue(
|
||||||
|
new Error("sandbox is not defined"),
|
||||||
|
);
|
||||||
|
|
||||||
|
const res = await getReplyFromConfig(
|
||||||
|
{
|
||||||
|
Body: "hello",
|
||||||
|
From: "+1002",
|
||||||
|
To: "+2000",
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
makeCfg(home),
|
||||||
|
);
|
||||||
|
|
||||||
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
|
expect(text).toBe(
|
||||||
|
"⚠️ Agent failed before reply: sandbox is not defined. Check gateway logs for details.",
|
||||||
|
);
|
||||||
|
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("uses heartbeat model override for heartbeat runs", async () => {
|
it("uses heartbeat model override for heartbeat runs", async () => {
|
||||||
await withTempHome(async (home) => {
|
await withTempHome(async (home) => {
|
||||||
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
|
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
|
||||||
|
|||||||
@@ -2291,7 +2291,7 @@ export async function getReplyFromConfig(
|
|||||||
return finalizeWithFollowup({
|
return finalizeWithFollowup({
|
||||||
text: isContextOverflow
|
text: isContextOverflow
|
||||||
? "⚠️ Context overflow - conversation too long. Starting fresh might help!"
|
? "⚠️ Context overflow - conversation too long. Starting fresh might help!"
|
||||||
: "⚠️ Agent failed. Check gateway logs.",
|
: `⚠️ Agent failed before reply: ${message}. Check gateway logs for details.`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user