MCPcopy
hub / github.com/claude-code-best/claude-code / sideQuery

Function sideQuery

src/utils/sideQuery.ts:182–391  ·  view source on GitHub ↗
(opts: SideQueryOptions)

Source from the content-addressed store, hash-verified

180 * await sideQuery({ querySource: 'model_validation', model, max_tokens: 1, messages: [{ role: 'user', content: 'Hi' }] })
181 */
182export 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({

Callers 8

agenticSessionSearchFunction · 0.85
classifyYoloActionXmlFunction · 0.85
classifyYoloActionFunction · 0.85
validateModelFunction · 0.85
createChromeContextFunction · 0.85
autoModeCritiqueHandlerFunction · 0.85
selectRelevantMemoriesFunction · 0.85

Calls 15

getAPIProviderFunction · 0.85
sideQueryViaGeminiFunction · 0.85
getAnthropicClientFunction · 0.85
computeFingerprintFunction · 0.85
getAttributionHeaderFunction · 0.85
getCLISyspromptPrefixFunction · 0.85
createChildSpanFunction · 0.85
getSessionIdFunction · 0.85

Tested by

no test coverage detected