(opts: SideQueryOptions)
| 105 | * await sideQuery({ querySource: 'model_validation', model, max_tokens: 1, messages: [{ role: 'user', content: 'Hi' }] }) |
| 106 | */ |
| 107 | export async function sideQuery(opts: SideQueryOptions): Promise<BetaMessage> { |
| 108 | const { |
| 109 | model, |
| 110 | system, |
| 111 | messages, |
| 112 | tools, |
| 113 | tool_choice, |
| 114 | output_format, |
| 115 | max_tokens = 1024, |
| 116 | maxRetries = 2, |
| 117 | signal, |
| 118 | skipSystemPromptPrefix, |
| 119 | temperature, |
| 120 | thinking, |
| 121 | stop_sequences, |
| 122 | } = opts |
| 123 | |
| 124 | const client = await getAnthropicClient({ |
| 125 | maxRetries, |
| 126 | model, |
| 127 | source: 'side_query', |
| 128 | }) |
| 129 | const betas = [...getModelBetas(model)] |
| 130 | // Add structured-outputs beta if using output_format and provider supports it |
| 131 | if ( |
| 132 | output_format && |
| 133 | modelSupportsStructuredOutputs(model) && |
| 134 | !betas.includes(STRUCTURED_OUTPUTS_BETA_HEADER) |
| 135 | ) { |
| 136 | betas.push(STRUCTURED_OUTPUTS_BETA_HEADER) |
| 137 | } |
| 138 | |
| 139 | // Extract first user message text for fingerprint |
| 140 | const messageText = extractFirstUserMessageText(messages) |
| 141 | |
| 142 | // Compute fingerprint for OAuth attribution |
| 143 | const fingerprint = computeFingerprint(messageText, MACRO.VERSION) |
| 144 | const attributionHeader = getAttributionHeader(fingerprint) |
| 145 | |
| 146 | // Build system as array to keep attribution header in its own block |
| 147 | // (prevents server-side parsing from including system content in cc_entrypoint) |
| 148 | const systemBlocks: TextBlockParam[] = [ |
| 149 | attributionHeader ? { type: 'text', text: attributionHeader } : null, |
| 150 | // Skip CLI system prompt prefix for internal classifiers that provide their own prompt |
| 151 | ...(skipSystemPromptPrefix |
| 152 | ? [] |
| 153 | : [ |
| 154 | { |
| 155 | type: 'text' as const, |
| 156 | text: getCLISyspromptPrefix({ |
| 157 | isNonInteractive: false, |
| 158 | hasAppendSystemPrompt: false, |
| 159 | }), |
| 160 | }, |
| 161 | ]), |
| 162 | ...(Array.isArray(system) |
| 163 | ? system |
| 164 | : system |
no test coverage detected