MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / runSideQuestion

Function runSideQuestion

source code/utils/sideQuestion.ts:55–104  ·  view source on GitHub ↗
({
  question,
  cacheSafeParams,
}: {
  question: string
  cacheSafeParams: CacheSafeParams
})

Source from the content-addressed store, hash-verified

53 * All tools are blocked and we cap at 1 turn.
54 */
55export async function runSideQuestion({
56 question,
57 cacheSafeParams,
58}: {
59 question: string
60 cacheSafeParams: CacheSafeParams
61}): Promise<SideQuestionResult> {
62 // Wrap the question with instructions to answer without tools
63 const wrappedQuestion = `<system-reminder>This is a side question from the user. You must answer this question directly in a single response.
64
65IMPORTANT CONTEXT:
66- You are a separate, lightweight agent spawned to answer this one question
67- The main agent is NOT interrupted - it continues working independently in the background
68- You share the conversation context but are a completely separate instance
69- Do NOT reference being interrupted or what you were "previously doing" - that framing is incorrect
70
71CRITICAL CONSTRAINTS:
72- You have NO tools available - you cannot read files, run commands, search, or take any actions
73- This is a one-off response - there will be no follow-up turns
74- You can ONLY provide information based on what you already know from the conversation context
75- NEVER say things like "Let me try...", "I'll now...", "Let me check...", or promise to take any action
76- If you don't know the answer, say so - do not offer to look it up or investigate
77
78Simply answer the question with the information you have.</system-reminder>
79
80${question}`
81
82 const agentResult = await runForkedAgent({
83 promptMessages: [createUserMessage({ content: wrappedQuestion })],
84 // Do NOT override thinkingConfig — thinking is part of the API cache key,
85 // and diverging from the main thread's config busts the prompt cache.
86 // Adaptive thinking on a quick Q&A has negligible overhead.
87 cacheSafeParams,
88 canUseTool: async () => ({
89 behavior: 'deny' as const,
90 message: 'Side questions cannot use tools',
91 decisionReason: { type: 'other' as const, reason: 'side_question' },
92 }),
93 querySource: 'side_question',
94 forkLabel: 'side_question',
95 maxTurns: 1, // Single turn only - no tool use loops
96 // No future request shares this suffix; skip writing cache entries.
97 skipCacheWrite: true,
98 })
99
100 return {
101 response: extractSideQuestionResponse(agentResult.messages),
102 usage: agentResult.totalUsage,
103 }
104}
105
106/**
107 * Extract a display string from forked agent messages.

Callers 2

fetchResponseFunction · 0.85
runHeadlessStreamingFunction · 0.85

Calls 3

runForkedAgentFunction · 0.85
createUserMessageFunction · 0.85

Tested by

no test coverage detected