Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions docs/SUPPORT_CHECKER_UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,33 @@ retaining the complete user envelope as data. The verdict schema remains named
The host's [checker adapter](../worker/src/support-independent-checks-model.ts)
delegates this contract and the route-policy hash to the SDK.

The SDK's explicit provider-group mode is opt-in. This host retains its existing
endpoint-qualified route configuration and model allowlists; this dependency
adoption does not enable provider-group selection or add a price policy. Any
future opt-in requires separate current route, pricing, privacy and tokenizer
qualification. Customer AI remains off.
The normal paid bootstrap also permits one explicit learning/engineering
checker-only tuple:
`openai/gpt-5.4` / `Azure` / `azure` / `max_completion_tokens` with
`providerSelectionScope:'provider_group'`. Route, static checker allowlist and
current Admin approval must independently select that scope. The route must
include a hash-bound `providerMaxPrice` with finite prompt/completion prices in
USD per million tokens and `request:0`; the SDK checks its worst-case token cost
against configured and current total-cost caps. Any change requires current
approval of the new policy hash, not an inferred approval from recomputing it.
The group requires separate current privacy, evaluation and tokenizer evidence;
an earlier exact-region approval does not qualify it or guarantee a region.

GPT-5.4 checks use the static `gpt-tokenizer@4.1.2` `model/gpt-5.4` entry with
request-derived merge caching disabled and special-looking text counted as
ordinary input. Its implementation is loaded only when the profile selects
GPT-5.4; absent, malformed, unknown-model and legacy-mini selections do not
initialize it. This does not establish bundle size or deployed CPU acceptance.
Qualification model/version, framing and evidence dates remain
operator evidence, checked by the SDK. Unknown models refuse before key access
or a provider request. The legacy GPT-4.1-mini checker selection, generation,
customer-answer and release-follow-up generator allowlists remain unchanged.
All host checker consumers receive the shared checker tuple/counter; the
published SDK separately refuses provider groups for release-follow-up checks.
That purpose remains held for a group route rather than inheriting a learning
or engineering approval. No
route, price, approval, credential or feature flag is installed or enabled by
this code change. Customer AI remains off.

Legacy endpoint routing sends `provider.only=[endpointTag]`,
`allow_fallbacks:false`, `zdr:true`, `data_collection:'deny'` and
Expand Down
23 changes: 23 additions & 0 deletions worker/src/support-independent-checks-token-counter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { countTokens, setMergeCacheSize } from "gpt-tokenizer/model/gpt-5.4";
import type { IndependentCheckCounter } from "./support-independent-checks-model";

// Keep encoding tables, never request-derived merge results across invocations.
setMergeCacheSize(0);
const ordinaryText = { disallowedSpecial: new Set<string>() };

/** Optional GPT-5.4 implementation, imported only for that checker selection.
* Qualification dates/versions stay operator evidence; this grants no approval. */
export function createSupportIndependentCheckTokenCounter(
qualification: IndependentCheckCounter["qualification"],
): IndependentCheckCounter {
if (qualification.model !== "openai/gpt-5.4")
throw new TypeError("Unsupported checker tokenizer implementation");
return Object.freeze({
qualification: Object.freeze({ ...qualification }),
count(text: string) {
if (typeof text !== "string" || text.length > 262_144)
throw new TypeError("Invalid checker token input.");
return countTokens(text, ordinaryText);
},
});
}
29 changes: 26 additions & 3 deletions worker/src/support-paid-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ const allowed = Object.freeze([
outputTokenParameter: 'max_tokens' as const,
},
]);
// Static capability only: route and current Admin approval must independently
// opt in to the group and bind its finite price/privacy/qualification evidence.
// All generation and customer answers keep their existing lists. The SDK also
// retains its separate release-follow-up checker purpose/approval restrictions.
const checkerAllowed = Object.freeze([
...allowed,
{
model: 'openai/gpt-5.4',
provider: 'Azure',
endpointTag: 'azure',
outputTokenParameter: 'max_completion_tokens' as const,
providerSelectionScope: 'provider_group' as const,
},
]);
function live(value: { verifiedAt?: string; validUntil: string }, clock: Clock) {
const now = Date.parse(clock.now());
return (
Expand Down Expand Up @@ -153,6 +167,14 @@ function counter<Q extends { readonly model: string }>(qualification: Q) {
count: (text: string) => implementation.count(text),
});
}
async function checkerCounter(qualification: SupportPaidProfile['checks']['qualification']) {
if (qualification.model === 'openai/gpt-4.1-mini') return counter(qualification);
if (qualification.model !== 'openai/gpt-5.4')
throw new TypeError('Unsupported checker tokenizer implementation');
const { createSupportIndependentCheckTokenCounter } =
await import('./support-independent-checks-token-counter');
return createSupportIndependentCheckTokenCounter(qualification);
}
function targets(
profile: NonNullable<SupportPaidProfile['learning']>,
product: { productId: string; version: string; buildId: string },
Expand Down Expand Up @@ -261,7 +283,8 @@ export async function createSupportPaidBootstrap(
try {
const version = profile.revision + ':' + (await knowledgeDigest(profile));
if (!current()) return undefined;
const checkCounter = counter(profile.checks.qualification);
const checkCounter = await checkerCounter(profile.checks.qualification);
if (!current()) return undefined;
const readApiKey = (reference: string) =>
current() && reference === SUPPORT_ASSISTANT_CREDENTIAL_REF
? currentEnv().SUPPORT_ASSISTANT_OPENROUTER_API_KEY
Expand All @@ -270,7 +293,7 @@ export async function createSupportPaidBootstrap(
clock,
enabled: current,
readRoute: () => (current() ? profile.checks.route : undefined),
allowlist: allowed,
allowlist: checkerAllowed,
counter: checkCounter,
});
const reviewPolicy: LearningCheckPolicyPort = {
Expand Down Expand Up @@ -366,7 +389,7 @@ export async function createSupportPaidBootstrap(
enabled: paid,
authority: checkerAuthority.learning.serviceAccess,
readRoute: () => (current() ? profile.checks.route : undefined),
allowlist: allowed,
allowlist: checkerAllowed,
counter: checkCounter,
readApiKey,
fetch: options.fetch,
Expand Down
Loading
Loading