@@ -55,7 +55,7 @@ export function AIToolInteraction() {
5555 </ p >
5656 </ div >
5757
58- < HighlightBox title = "术语对齐(非常重要)" icon = "🧭" variant = "yellow" >
58+ < HighlightBox title = "术语对齐(非常重要)" variant = "yellow" >
5959 < div className = "space-y-2 text-sm text-heading" >
6060 < p className = "m-0" >
6161 上游 Gemini CLI 主线使用 < code > tools: [{ functionDeclarations: FunctionDeclaration[] }]</ code > 声明工具,
@@ -67,11 +67,11 @@ export function AIToolInteraction() {
6767 </ div >
6868 </ HighlightBox >
6969
70- < Layer title = "端到端时序" icon = "🗺️" defaultOpen >
70+ < Layer title = "端到端时序" defaultOpen >
7171 < MermaidDiagram chart = { sequence } />
7272 </ Layer >
7373
74- < Layer title = "1) 工具声明(FunctionDeclaration)" icon = "📋" >
74+ < Layer title = "1) 工具声明(FunctionDeclaration)" >
7575 < p className = "text-body mb-4" >
7676 CLI 每次向模型发起请求时,会把当前可用工具的 < code > FunctionDeclaration</ code > 一并发送。上游实现来自:
7777 < code className = "ml-2 text-heading" > packages/core/src/tools/tool-registry.ts</ code > 与
@@ -120,15 +120,15 @@ getFunctionDeclarations(): FunctionDeclaration[] {
120120}` }
121121 />
122122
123- < HighlightBox title = "要点" icon = "💡" variant = "blue" >
123+ < HighlightBox title = "要点" variant = "blue" >
124124 < ul className = "pl-5 list-disc space-y-1 text-sm text-heading" >
125125 < li > < code > parametersJsonSchema</ code > 是上游的字段名(不是 < code > parameters</ code > )。</ li >
126126 < li > < code > read_file</ code > 参数名是 < code > file_path</ code > (不是 < code > absolute_path</ code > )。</ li >
127127 </ ul >
128128 </ HighlightBox >
129129 </ Layer >
130130
131- < Layer title = "2) 模型请求工具(functionCall / functionCalls)" icon = "🤖" >
131+ < Layer title = "2) 模型请求工具(functionCall / functionCalls)" >
132132 < p className = "text-body mb-4" >
133133 Gemini SDK 的响应 chunk 可以直接通过 < code > resp.functionCalls</ code > 读取工具请求(SDK 从候选内容 parts 中推导得到)。上游核心处理在 < code > Turn.run()</ code > :
134134 </ p >
@@ -158,14 +158,14 @@ for (const fnCall of functionCalls) {
158158}` }
159159 />
160160
161- < HighlightBox title = "args 是对象,不需要 JSON.parse" icon = "✅" variant = "green" >
161+ < HighlightBox title = "args 是对象,不需要 JSON.parse" variant = "green" >
162162 < p className = "m-0 text-sm text-heading" >
163163 上游主线里 < code > fnCall.args</ code > 已经是对象。只有在 OpenAI-compatible 兼容层里,才会遇到 < code > arguments</ code > 为 JSON 字符串需要解析的情况。
164164 </ p >
165165 </ HighlightBox >
166166 </ Layer >
167167
168- < Layer title = "3) 调度与执行(CoreToolScheduler → ToolInvocation)" icon = "⚙️" >
168+ < Layer title = "3) 调度与执行(CoreToolScheduler → ToolInvocation)" >
169169 < p className = "text-body mb-4" >
170170 < code > ToolCallRequest</ code > 事件到达后,CLI 把它交给 < code > CoreToolScheduler</ code > :负责队列、确认、执行、以及把结果转换为 < code > functionResponse</ code > parts。
171171 </ p >
@@ -184,15 +184,15 @@ const confirmation = await invocation.shouldConfirmExecute(signal);
184184` }
185185 />
186186
187- < HighlightBox title = "两个关键边界" icon = "⚠️" variant = "yellow" >
187+ < HighlightBox title = "两个关键边界" variant = "yellow" >
188188 < ul className = "pl-5 list-disc space-y-1 text-sm text-heading" >
189189 < li > < strong > 参数非法</ strong > :< code > tool.build(args)</ code > 会直接抛错或返回 INVALID_TOOL_PARAMS 类错误。</ li >
190190 < li > < strong > 需要确认</ strong > :< code > shouldConfirmExecute()</ code > 由 policy + messageBus 决策(ALLOW/DENY/ASK_USER)。</ li >
191191 </ ul >
192192 </ HighlightBox >
193193 </ Layer >
194194
195- < Layer title = "4) 回传 functionResponse 并继续(Continuation)" icon = "📤" >
195+ < Layer title = "4) 回传 functionResponse 并继续(Continuation)" >
196196 < p className = "text-body mb-4" >
197197 工具执行结果会被转换为 Gemini 的 < code > functionResponse</ code > part,并以 < code > role: 'user'</ code > 的消息写回历史,
198198 然后再发起一次 continuation 请求,让模型基于结果继续完成任务。
@@ -220,14 +220,14 @@ export function convertToFunctionResponse(
220220 />
221221 </ Layer >
222222
223- < Layer title = "5) 多工具调用与 finishReason" icon = "🧩" >
224- < HighlightBox title = "一次响应里可能有多个 functionCalls" icon = "📦" variant = "blue" >
223+ < Layer title = "5) 多工具调用与 finishReason" >
224+ < HighlightBox title = "一次响应里可能有多个 functionCalls" variant = "blue" >
225225 < p className = "m-0 text-sm text-heading" >
226226 < code > resp.functionCalls</ code > 是数组:模型可能一次请求多个工具调用。CLI 的 scheduler 会把它们排队执行,并逐个回传对应的 functionResponse。
227227 </ p >
228228 </ HighlightBox >
229229
230- < HighlightBox title = "finishReason 是状态信号" icon = "🔄" variant = "purple" >
230+ < HighlightBox title = "finishReason 是状态信号" variant = "purple" >
231231 < ul className = "pl-5 list-disc space-y-1 text-sm text-heading" >
232232 < li > < code > TOOL_USE</ code > :模型请求工具(本轮会出现 functionCalls)。</ li >
233233 < li > < code > STOP</ code > :模型认为本轮已经完成自然语言回复。</ li >
@@ -236,7 +236,7 @@ export function convertToFunctionResponse(
236236 </ HighlightBox >
237237 </ Layer >
238238
239- < Layer title = "6) 错误与停止执行(含 stop_execution)" icon = "🧨" >
239+ < Layer title = "6) 错误与停止执行(含 stop_execution)" >
240240 < p className = "text-body mb-4" >
241241 工具执行失败也必须返回给模型(让它理解发生了什么并决定下一步)。上游用 < code > ToolResult.error</ code > 携带机器可读的 < code > ToolErrorType</ code > 。
242242 </ p >
@@ -275,7 +275,7 @@ if (beforeOutput?.shouldStopExecution()) {
275275 />
276276 </ Layer >
277277
278- < Layer title = "Fork-only:OpenAI tool_calls 对照" icon = "🧷" >
278+ < Layer title = "Fork-only:OpenAI tool_calls 对照" >
279279 < div className = "space-y-3 text-body text-sm" >
280280 < p className = "m-0" >
281281 如果你的 fork 需要兼容 OpenAI 协议:< code > tool_calls[].function.arguments</ code > 通常是 JSON 字符串,需要 < code > JSON.parse</ code > 才能得到对象;
0 commit comments