(opts: SideQueryOptions)
| 180 | * await sideQuery({ querySource: 'model_validation', model, max_tokens: 1, messages: [{ role: 'user', content: 'Hi' }] }) |
| 181 | */ |
| 182 | export async function sideQuery(opts: SideQueryOptions): Promise<BetaMessage> { |
| 183 | const { |
| 184 | model, |
| 185 | system, |
| 186 | messages, |
| 187 | tools, |
| 188 | tool_choice, |
| 189 | output_format, |
| 190 | max_tokens = 1024, |
| 191 | maxRetries = 2, |
| 192 | signal, |
| 193 | skipSystemPromptPrefix, |
| 194 | temperature, |
| 195 | thinking, |
| 196 | stop_sequences, |
| 197 | } = opts |
| 198 | |
| 199 | const provider = getAPIProvider() |
| 200 | if (provider === 'openai' || provider === 'grok') { |
| 201 | return sideQueryViaOpenAICompatible(opts) |
| 202 | } |
| 203 | if (provider === 'gemini') { |
| 204 | return sideQueryViaGemini(opts) |
| 205 | } |
| 206 | |
| 207 | const client = await getAnthropicClient({ |
| 208 | maxRetries, |
| 209 | model, |
| 210 | source: 'side_query', |
| 211 | }) |
| 212 | const betas = [...getModelBetas(model)] |
| 213 | // Add structured-outputs beta if using output_format and provider supports it |
| 214 | if ( |
| 215 | output_format && |
| 216 | modelSupportsStructuredOutputs(model) && |
| 217 | !betas.includes(STRUCTURED_OUTPUTS_BETA_HEADER) |
| 218 | ) { |
| 219 | betas.push(STRUCTURED_OUTPUTS_BETA_HEADER) |
| 220 | } |
| 221 | |
| 222 | // Extract first user message text for fingerprint |
| 223 | const messageText = extractFirstUserMessageText(messages) |
| 224 | |
| 225 | // Compute fingerprint for OAuth attribution |
| 226 | const fingerprint = computeFingerprint(messageText, MACRO.VERSION) |
| 227 | const attributionHeader = getAttributionHeader(fingerprint) |
| 228 | |
| 229 | // Build system as array to keep attribution header in its own block |
| 230 | // (prevents server-side parsing from including system content in cc_entrypoint) |
| 231 | const systemBlocks: TextBlockParam[] = [ |
| 232 | attributionHeader ? { type: 'text', text: attributionHeader } : null, |
| 233 | // Skip CLI system prompt prefix for internal classifiers that provide their own prompt |
| 234 | ...(skipSystemPromptPrefix |
| 235 | ? [] |
| 236 | : [ |
| 237 | { |
| 238 | type: 'text' as const, |
| 239 | text: getCLISyspromptPrefix({ |
no test coverage detected