Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(ai-gateway): defer response handling to gateway policy (#6253)

Ezra Ellettefc1974f73534
diff --git a/packages/ai-gateway/src/services/cloudflare-ai-gateway.ts b/packages/ai-gateway/src/services/cloudflare-ai-gateway.ts
index 0008e0c12..41d5b5c54 100644
--- a/packages/ai-gateway/src/services/cloudflare-ai-gateway.ts
+++ b/packages/ai-gateway/src/services/cloudflare-ai-gateway.ts
@@ -181,7 +181,6 @@ export async function getHostedChatGatewayConnection(
const defaultHeaders: Record<string, string | null> = {
'cf-aig-metadata': JSON.stringify(context),
- 'cf-aig-skip-cache': 'true',
'cf-aig-collect-log-payload': 'false',
'cf-aig-max-attempts': '1',
'cf-aig-byok-alias': 'default',
diff --git a/packages/ai-gateway/src/test/cloudflare-ai-gateway.unit.test.ts b/packages/ai-gateway/src/test/cloudflare-ai-gateway.unit.test.ts
index 43f5cc7a3..7b4929413 100644
--- a/packages/ai-gateway/src/test/cloudflare-ai-gateway.unit.test.ts
+++ b/packages/ai-gateway/src/test/cloudflare-ai-gateway.unit.test.ts
@@ -85,7 +85,7 @@ describe('Cloudflare hosted-chat metadata', () => {
});
describe('Cloudflare provider-native connection', () => {
- it('uses the Workers binding, BYOK, metadata-only logs, and disables Gateway retries/cache', async () => {
+ it('uses the Workers binding, BYOK, metadata-only logs, and disables Gateway retries', async () => {
const calls: string[] = [];
const env = {
HOSTED_CHAT_GATEWAY_MODE: 'cloudflare',
@@ -109,7 +109,7 @@ describe('Cloudflare provider-native connection', () => {
expect(connection.defaultHeaders.Authorization).toBeNull();
expect(connection.defaultHeaders['cf-aig-byok-alias']).toBe('default');
expect(connection.defaultHeaders['cf-aig-authorization']).toBe('Bearer local-oauth-token');
- expect(connection.defaultHeaders['cf-aig-skip-cache']).toBe('true');
+ expect(connection.defaultHeaders).not.toHaveProperty('cf-aig-skip-cache');
expect(connection.defaultHeaders['cf-aig-max-attempts']).toBe('1');
expect(connection.defaultHeaders['cf-aig-collect-log-payload']).toBe('false');
expect(JSON.parse(connection.defaultHeaders['cf-aig-metadata']!)).toEqual(context);