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): accept the existing Workflows training consent notice (#7824)

Ezra Ellettec172d629e8de
diff --git a/packages/ai-gateway/src/services/hosted-chat-training.ts b/packages/ai-gateway/src/services/hosted-chat-training.ts
index 1e905f434..42444e5ee 100644
--- a/packages/ai-gateway/src/services/hosted-chat-training.ts
+++ b/packages/ai-gateway/src/services/hosted-chat-training.ts
@@ -9,7 +9,7 @@ type TrainingConsent = { allowed: false } | {
const consentContext = Symbol('hosted-chat-training-consent');
const denied: TrainingConsent = Object.freeze({ allowed: false });
-/** Read current consent independently of the cached commercial entitlement.
+/** Read the existing Workflows consent independently of cached entitlement.
* A consent outage denies training, while ordinary inference remains available. */
export async function loadHostedTrainingConsent(request: Request, auth: AuthResult): Promise<TrainingConsent> {
if (!auth.isValid || auth.service || !auth.clerkUserId || auth.userId !== auth.clerkUserId || !auth.trainingMetadata)
@@ -29,7 +29,7 @@ export async function loadHostedTrainingConsent(request: Request, auth: AuthResu
const value: any = await response.json();
if (value.accountId !== auth.clerkUserId || value.allowed !== true ||
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value.epoch) ||
- typeof value.noticeVersion !== 'string' || !/^hosted-ai-training-\d{4}-\d{2}-\d{2}$/.test(value.noticeVersion) ||
+ typeof value.noticeVersion !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(value.noticeVersion) ||
typeof value.grantedAt !== 'string' || !Number.isFinite(Date.parse(value.grantedAt)) || Date.parse(value.grantedAt) > Date.now())
return denied;
return { allowed: true, epoch: value.epoch, noticeVersion: value.noticeVersion, grantedAt: value.grantedAt };
diff --git a/packages/ai-gateway/src/test/hosted-chat-training.integration.test.ts b/packages/ai-gateway/src/test/hosted-chat-training.integration.test.ts
index d996955ef..cda81ae16 100644
--- a/packages/ai-gateway/src/test/hosted-chat-training.integration.test.ts
+++ b/packages/ai-gateway/src/test/hosted-chat-training.integration.test.ts
@@ -4,10 +4,10 @@
import { expect, test } from 'bun:test';
import { LocalGatewayHarness } from './local-gateway-harness';
-test('actual Worker reads fresh training consent and sends trusted tags through grant, withdrawal, outage and forged clients', async () => {
+test('actual Worker uses the existing Workflows training consent through grant, withdrawal, outage and forged clients', async () => {
const epoch = '10000000-0000-4000-8000-000000000001';
let preference: any = { accountId: 'user_training', allowed: true, epoch,
- noticeVersion: 'hosted-ai-training-2026-10-29', grantedAt: '2026-10-29T00:00:00Z' };
+ noticeVersion: '2026-09-23', grantedAt: '2026-09-23T00:00:00Z' };
let unavailable = false;
let reads = 0;
const tags: any[] = [];
@@ -41,14 +41,18 @@ test('actual Worker reads fresh training consent and sends trusted tags through
try {
await call();
expect(tags.at(-1)).toMatchObject({ audience: 'consumer', user_id_hash: 'a'.repeat(64), training_allowed: 'true',
- training_consent_epoch: epoch, training_consent_notice: 'hosted-ai-training-2026-10-29' });
+ training_consent_epoch: epoch, training_consent_notice: '2026-09-23' });
preference = { ...preference, allowed: false };
await call(); expect(tags.at(-1)).toEqual({ audience: 'consumer', user_id_hash: 'a'.repeat(64), training_allowed: 'false' });
preference = { ...preference, allowed: true }; unavailable = true;
await call(); expect(tags.at(-1).training_allowed).toBe('false');
unavailable = false; preference = { ...preference, accountId: 'another_user' };
await call(); expect(tags.at(-1).training_allowed).toBe('false');
- expect(reads).toBe(4);
+ preference = { ...preference, accountId: 'user_training', noticeVersion: 'hosted-ai-training-2026-10-29' };
+ await call(); expect(tags.at(-1).training_allowed).toBe('false');
+ preference = { ...preference, noticeVersion: '2026-09-21' };
+ await call(); expect(tags.at(-1)).toMatchObject({ training_allowed: 'true', training_consent_notice: '2026-09-21' });
+ expect(reads).toBe(6);
harness.assertNoUnexpectedOutboundRequests();
} finally { await harness.dispose(); }
}, 30000);