MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / getCachedClassification

Function getCachedClassification

services/auto-routing/src/decision-cache.ts:92–110  ·  view source on GitHub ↗
(
  env: DecisionCacheEnv,
  conversationKey: string,
  contentHash: string,
  classifierModel: string
)

Source from the content-addressed store, hash-verified

90 model: z.string().min(1),
91 // Taxonomy route the model was decided on, for route-change telemetry.
92 // Nullable/defaulted so entries written before the field existed parse.
93 routeKey: z.string().min(1).nullish().default(null),
94 // Exact catalog variant the model was decided with. Null for legacy
95 // model-only sticky records and for candidates without a variant.
96 variant: z.string().min(1).nullish().default(null),
97});
98export type StickyDecision = z.infer<typeof StickyDecisionSchema>;
99
100export async function getCachedClassification(
101 env: DecisionCacheEnv,
102 conversationKey: string,
103 contentHash: string,
104 classifierModel: string
105): Promise<ClassifierOutput | null> {
106 try {
107 const value = await cacheStub(env, conversationKey).getEntry(
108 entryKey(contentHash, classifierModel)
109 );
110 if (!value) return null;
111 // Entries may have been written by an older worker version; validate
112 // before serving.
113 const parsed = ClassifierOutputSchema.safeParse(value);

Callers 1

decideHandlerFunction · 0.90

Calls 3

cacheStubFunction · 0.85
entryKeyFunction · 0.85
getEntryMethod · 0.80

Tested by

no test coverage detected