fix (agents): return timeout reply on empty timed-out runs

This commit is contained in:
Vignesh Natarajan
2026-02-14 20:32:45 -08:00
parent b373461032
commit 17588f51f0
2 changed files with 41 additions and 0 deletions

View File

@@ -354,6 +354,22 @@ describe("overflow compaction in run loop", () => {
expect(log.warn).not.toHaveBeenCalledWith(expect.stringContaining("source=assistantError"));
});
it("returns an explicit timeout payload when the run times out before producing any reply", async () => {
mockedRunEmbeddedAttempt.mockResolvedValue(
makeAttemptResult({
aborted: true,
timedOut: true,
timedOutDuringCompaction: false,
assistantTexts: [],
}),
);
const result = await runEmbeddedPiAgent(baseParams);
expect(result.payloads?.[0]?.isError).toBe(true);
expect(result.payloads?.[0]?.text).toContain("timed out");
});
it("sets promptTokens from the latest model call usage, not accumulated attempt usage", async () => {
mockedRunEmbeddedAttempt.mockResolvedValue(
makeAttemptResult({