Conversation
…tion
Adapta web API has no native function calling. Serialize OpenAI tools[] into system prompt instructions (webTools.ts), parse <tool>{...}</tool> blocks from response text back into OpenAI tool_calls.
Pattern: same as deepseek-web (diegosouzapw#2820), qwen-web (diegosouzapw#3252), ddg-web (diegosouzapw#3253), blackbox-web (diegosouzapw#3254). Injects tool prompt into buildAdaptaMessages system instruction chain.
There was a problem hiding this comment.
Code Review
This pull request introduces tool-calling support for the Adapta executor in open-sse/executors/adapta-web.ts by serializing requested tools into a system prompt and parsing tool calls from the response text. The reviewer feedback highlights three key areas for improvement: first, streaming mode must be disabled when tools are requested to prevent raw tool blocks from breaking client functionality; second, the usage field should be added to the tool-call response to maintain consistency and avoid client parsing errors; and third, corresponding unit tests must be added to comply with the repository style guide's requirement for testing production code changes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const messages = (Array.isArray(bodyObj.messages) ? bodyObj.messages : []) as OpenAIMessage[]; | ||
|
|
||
| const requestedTools = bodyObj.tools; | ||
| const hasTools = Array.isArray(requestedTools) && requestedTools.length > 0; |
There was a problem hiding this comment.
When hasTools is true, the executor should force non-streaming mode (i.e., stream = false) because transformStream does not support parsing tool calls from the stream. If streaming is kept active, the client will receive raw <tool>...</tool> text blocks instead of proper tool_calls structures, which will break tool-calling functionality.
To fix this, you can reassign stream = false when hasTools is true, or introduce an effectiveStream variable and use it in place of stream at line 454.
| @@ -1,4 +1,5 @@ | |||
| import { BaseExecutor, type ExecuteInput } from "./base.ts"; | |||
| import { serializeToolsToPrompt, parseToolCallsFromText } from "../translator/webTools.ts"; | |||
There was a problem hiding this comment.
According to the Repository Style Guide (Rule 9), you must always include tests when changing production code under open-sse/. Please add or update the corresponding unit tests (e.g., in tests/) to cover the new tool-call translation logic for the Adapta executor.
References
- Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)
| response: new Response( | ||
| JSON.stringify({ | ||
| id: `chatcmpl-adp-${Date.now()}`, object: "chat.completion", | ||
| created: Math.floor(Date.now() / 1000), model, | ||
| choices: [{ index: 0, message: { role: "assistant", content: null, tool_calls: toolCalls }, finish_reason: "tool_calls" }], | ||
| }), | ||
| { status: 200, headers: { "Content-Type": "application/json" } } | ||
| ), |
There was a problem hiding this comment.
The returned chat completion response for tool calls is missing the usage field. Some clients/SDKs expect this field to be present and may fail to parse the response if it is missing. Please add the usage field to maintain consistency with the other completion responses in this executor.
response: new Response(
JSON.stringify({
id: `chatcmpl-adp-${Date.now()}`,
object: "chat.completion",
created: Math.floor(Date.now() / 1000),
model,
choices: [
{
index: 0,
message: { role: "assistant", content: null, tool_calls: toolCalls },
finish_reason: "tool_calls"
}
],
usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }
}),
{ status: 200, headers: { "Content-Type": "application/json" } }
),|
Superseded by #3259 (consolidated PR with shared helpers) |
Description
Adapta web API has no native function calling support. This PR adds tool-call translation using the same pattern as deepseek-web (#2820), qwen-web (#3252), ddg-web (#3253), and blackbox-web (#3254).
How it works
Request side: Serialize OpenAI
tools[]into a system prompt instruction viaserializeToolsToPrompt(). Injects into thebuildAdaptaMessagessystem instruction chain.Response side: Parse
<tool>{...}</tool>blocks from model text response viaparseToolCallsFromText(). Returns proper OpenAItool_callsformat.Files Changed
open-sse/executors/adapta-web.ts— +40 linesTests
All 5 existing tests pass.