mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(antigravity): retry transient upstream failures
Retry short-lived 5xx/capacity errors (500/502/503/504 + message patterns) with bounded backoff capped at 15s; honor Retry-After/reset hints and skip when wait is too long. Keep 400 non-retryable. Enable the retry hook for 500 alongside existing 429/503. Deduplicate sanitized Antigravity tool names before emitting the single functionDeclarations group to avoid upstream "Tool names must be unique" rejections. Add Headroom size diagnostics and phantom-savings warning when reported token delta does not shrink the outbound payload. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
2deacf69b1
commit
639f1204d0
@@ -32,8 +32,38 @@ describe("antigravity computeRetryDelay hook (D3)", () => {
|
||||
expect(await ag.computeRetryDelay(res(429), 3)).toBe(Math.min(1000 * 2 ** 3, MAX));
|
||||
});
|
||||
|
||||
it("503 without retry info → veto (no auto backoff)", async () => {
|
||||
expect(await ag.computeRetryDelay(res(503), 1)).toBe(false);
|
||||
it("503 without retry info → transient backoff", async () => {
|
||||
expect(await ag.computeRetryDelay(res(503), 1)).toBe(2000);
|
||||
});
|
||||
|
||||
it("retries Antigravity agent terminated body even when status is not 429", async () => {
|
||||
const r = res(500, {}, { error: { message: "Agent execution terminated due to error" } });
|
||||
expect(await ag.computeRetryDelay(r, 1)).toBe(2000);
|
||||
});
|
||||
|
||||
it("retries high traffic body", async () => {
|
||||
const r = res(500, {}, { error: { message: "Our servers are experiencing high traffic" } });
|
||||
expect(await ag.computeRetryDelay(r, 2)).toBe(4000);
|
||||
});
|
||||
|
||||
it("does not retry non-transient 400 errors", async () => {
|
||||
const r = res(400, {}, { error: { message: "Invalid request" } });
|
||||
expect(await ag.computeRetryDelay(r, 1)).toBe(false);
|
||||
});
|
||||
|
||||
it("deduplicates sanitized tool names", () => {
|
||||
const out = ag.transformRequest("claude-opus-4-6-thinking", {
|
||||
request: {
|
||||
contents: [{ role: "user", parts: [{ text: "hi" }] }],
|
||||
tools: [{ functionDeclarations: [
|
||||
{ name: "read/file", parameters: { type: "object", properties: {} } },
|
||||
{ name: "read file", parameters: { type: "object", properties: {} } },
|
||||
{ name: "read/file", parameters: { type: "object", properties: {} } },
|
||||
] }],
|
||||
},
|
||||
}, true, { projectId: "project-1", connectionId: "conn-1" });
|
||||
|
||||
expect(out.request.tools[0].functionDeclarations.map(fn => fn.name)).toEqual(["read_file"]);
|
||||
});
|
||||
|
||||
it("buildHeaders includes cached session id after transformRequest", () => {
|
||||
|
||||
Reference in New Issue
Block a user