Skip to content

Commit bbc7b1e

Browse files
committed
Add test: request limit returns error, not crash
Verify the full CodeMode pipeline returns a proper ToolCallResult with isError: true when the request limit is exceeded, rather than throwing an unhandled exception.
1 parent 84c46d2 commit bbc7b1e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/codemode.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,26 @@ describe("Hono integration", () => {
373373
});
374374

375375
describe("request counter resets per execution", () => {
376+
it("returns error (not crash) when request limit exceeded", async () => {
377+
const cm = new CodeMode({
378+
spec: testSpec,
379+
request: testHandler,
380+
maxRequests: 1,
381+
executor: new TestExecutor(),
382+
});
383+
384+
const result = await cm.execute(`
385+
async () => {
386+
await api.request({ method: "GET", path: "/v1/clusters" });
387+
await api.request({ method: "GET", path: "/v1/products" });
388+
return "should not reach here";
389+
}
390+
`);
391+
392+
expect(result.isError).toBe(true);
393+
expect(result.content[0]!.text).toContain("Request limit exceeded");
394+
});
395+
376396
it("allows maxRequests per execute() call, not per instance", async () => {
377397
const cm = new CodeMode({
378398
spec: testSpec,

0 commit comments

Comments
 (0)