Revert tool-choice forcing — the Codex regression was strict:null
The GPT-account (Codex) path supports tool calls and worked before; my forced tool_choice broke it and was the wrong fix. The real regression was strict:null in the rebuild's tool definitions, which made the endpoint drop the tool list so the model had nothing to call — a "Done" run that hired no one. Forcing then turned that silent failure into a red one. Restore the original "auto" loop (no forced tool_choice, no finish tool) and keep only the one-line strict:null omission. Codex now receives valid tools on the working "auto" choice, as in the version that worked. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
74422da4f8
commit
97242ae684
13 files changed
+57
-160
No files matched your search
@@ -1,11 +1,11 @@
|
||||
/** AWS Bedrock Converse API encoding/decoding (ported from Pi's bedrock handler). */
|
||||
import { isRecord, type JsonRecord } from "../provider-http";
|
||||
import type { AgentTurnMessage, ToolCall, ToolChoice, ToolDefinition } from "../provider-tool-turn";
|
||||
import type { AgentTurnMessage, ToolCall, ToolDefinition } from "../provider-tool-turn";
|
||||
|
||||
export function bedrockToolConfig(tools: ToolDefinition[], toolChoice?: ToolChoice): JsonRecord {
|
||||
export function bedrockToolConfig(tools: ToolDefinition[]): JsonRecord {
|
||||
return {
|
||||
tools: tools.map((tool) => ({ toolSpec: { name: tool.name, description: tool.description, inputSchema: { json: tool.parameters } } })),
|
||||
toolChoice: toolChoice === "required" ? { any: {} } : { auto: {} },
|
||||
toolChoice: { auto: {} },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Antigravity request wrapper in google-gemini-cli.
|
||||
*/
|
||||
import { isRecord, type JsonRecord, type ProviderEventStreamMessage } from "../provider-http";
|
||||
import { type AgentTurnMessage, type AgentTurnResult, type ToolCall, type ToolChoice, type ToolDefinition } from "../provider-tool-turn";
|
||||
import { type AgentTurnMessage, type AgentTurnResult, type ToolCall, type ToolDefinition } from "../provider-tool-turn";
|
||||
|
||||
const ANTIGRAVITY_SYSTEM_INSTRUCTION =
|
||||
"You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding." +
|
||||
@@ -64,7 +64,6 @@ export function antigravityRequestBody(input: {
|
||||
instructions: string | null;
|
||||
messages: AgentTurnMessage[];
|
||||
tools: ToolDefinition[];
|
||||
toolChoice?: ToolChoice;
|
||||
requestId: string;
|
||||
}): JsonRecord {
|
||||
const request: JsonRecord = {
|
||||
@@ -80,7 +79,7 @@ export function antigravityRequestBody(input: {
|
||||
};
|
||||
if (input.tools.length > 0) {
|
||||
request.tools = geminiToolDefs(input.model, input.tools);
|
||||
request.toolConfig = { functionCallingConfig: { mode: input.toolChoice === "required" ? "ANY" : "AUTO" } };
|
||||
request.toolConfig = { functionCallingConfig: { mode: "AUTO" } };
|
||||
}
|
||||
return { project: input.projectId, model: input.model, request, requestType: "agent", userAgent: "antigravity", requestId: input.requestId };
|
||||
}
|
||||
@@ -91,13 +90,12 @@ export function vertexRequestBody(input: {
|
||||
instructions: string | null;
|
||||
messages: AgentTurnMessage[];
|
||||
tools: ToolDefinition[];
|
||||
toolChoice?: ToolChoice;
|
||||
}): JsonRecord {
|
||||
const body: JsonRecord = { contents: toGeminiContents(input.model, input.messages) };
|
||||
if (input.instructions) body.systemInstruction = { parts: [{ text: input.instructions }] };
|
||||
if (input.tools.length > 0) {
|
||||
body.tools = geminiToolDefs(input.model, input.tools);
|
||||
body.toolConfig = { functionCallingConfig: { mode: input.toolChoice === "required" ? "ANY" : "AUTO" } };
|
||||
body.toolConfig = { functionCallingConfig: { mode: "AUTO" } };
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function runOpenAiResponsesTurn(input: ProviderToolTurnInput): Prom
|
||||
model: input.model,
|
||||
input: toResponsesInput(input.messages),
|
||||
tools: responsesToolDefs(input.tools),
|
||||
tool_choice: input.toolChoice ?? "auto",
|
||||
tool_choice: "auto",
|
||||
store: false,
|
||||
...(input.instructions ? { instructions: input.instructions } : {}),
|
||||
};
|
||||
@@ -58,7 +58,7 @@ export function makeChatCompletionsTurn(endpoint: string, label: string): (input
|
||||
model: input.model,
|
||||
messages: toChatMessages(input.instructions, input.messages),
|
||||
tools: chatToolDefs(input.tools),
|
||||
tool_choice: input.toolChoice ?? "auto",
|
||||
tool_choice: "auto",
|
||||
stream: false,
|
||||
};
|
||||
const response = await postJson(endpoint, { authorization: `Bearer ${requireApiKey(input.credential, label)}` }, body);
|
||||
@@ -74,7 +74,6 @@ export async function runAnthropicTurn(input: ProviderToolTurnInput): Promise<Ag
|
||||
model: input.model,
|
||||
max_tokens: 4096,
|
||||
tools: anthropicToolDefs(input.tools),
|
||||
...(input.toolChoice === "required" ? { tool_choice: { type: "any" } } : {}),
|
||||
messages: toAnthropicMessages(input.messages),
|
||||
...(input.instructions ? { system: input.instructions } : {}),
|
||||
};
|
||||
@@ -94,7 +93,6 @@ export async function runClaudeProTurn(input: ProviderToolTurnInput): Promise<Ag
|
||||
model: input.model,
|
||||
max_tokens: 4096,
|
||||
tools: anthropicToolDefs(input.tools),
|
||||
...(input.toolChoice === "required" ? { tool_choice: { type: "any" } } : {}),
|
||||
messages: toAnthropicMessages(input.messages),
|
||||
system,
|
||||
};
|
||||
@@ -123,7 +121,7 @@ export async function runCodexTurn(input: ProviderToolTurnInput): Promise<AgentT
|
||||
input: toResponsesInput(input.messages),
|
||||
text: { verbosity: "medium" },
|
||||
include: ["reasoning.encrypted_content"],
|
||||
tool_choice: input.toolChoice ?? "auto",
|
||||
tool_choice: "auto",
|
||||
parallel_tool_calls: true,
|
||||
tools: responsesToolDefs(input.tools, null),
|
||||
};
|
||||
@@ -146,7 +144,7 @@ export async function runCopilotTurn(input: ProviderToolTurnInput): Promise<Agen
|
||||
model: input.model,
|
||||
input: toResponsesInput(input.messages),
|
||||
tools: responsesToolDefs(input.tools),
|
||||
tool_choice: input.toolChoice ?? "auto",
|
||||
tool_choice: "auto",
|
||||
store: false,
|
||||
};
|
||||
const response = await postJson(`${baseUrl}/responses`, {
|
||||
@@ -167,7 +165,7 @@ export async function runCustomOpenAiTurn(input: ProviderToolTurnInput): Promise
|
||||
model: input.model,
|
||||
messages: toChatMessages(input.instructions, input.messages),
|
||||
tools: chatToolDefs(input.tools),
|
||||
tool_choice: input.toolChoice ?? "auto",
|
||||
tool_choice: "auto",
|
||||
stream: false,
|
||||
};
|
||||
const response = await postJson(`${input.credential.baseUrl}/chat/completions`, { authorization: `Bearer ${requireApiKey(input.credential, "Custom OpenAI-compatible provider")}` }, body);
|
||||
@@ -183,7 +181,6 @@ export async function runCustomAnthropicTurn(input: ProviderToolTurnInput): Prom
|
||||
model: input.model,
|
||||
max_tokens: 4096,
|
||||
tools: anthropicToolDefs(input.tools),
|
||||
...(input.toolChoice === "required" ? { tool_choice: { type: "any" } } : {}),
|
||||
messages: toAnthropicMessages(input.messages),
|
||||
...(input.instructions ? { system: input.instructions } : {}),
|
||||
};
|
||||
@@ -204,7 +201,6 @@ export async function runAntigravityTurn(input: ProviderToolTurnInput): Promise<
|
||||
instructions: input.instructions,
|
||||
messages: input.messages,
|
||||
tools: input.tools,
|
||||
toolChoice: input.toolChoice,
|
||||
requestId,
|
||||
});
|
||||
const response = await postEventStream(`${ANTIGRAVITY_ENDPOINT}/v1internal:streamGenerateContent?alt=sse`, {
|
||||
@@ -224,7 +220,7 @@ export async function runAzureTurn(input: ProviderToolTurnInput): Promise<AgentT
|
||||
model: input.credential.deployment,
|
||||
messages: toChatMessages(input.instructions, input.messages),
|
||||
tools: chatToolDefs(input.tools),
|
||||
tool_choice: input.toolChoice ?? "auto",
|
||||
tool_choice: "auto",
|
||||
stream: false,
|
||||
};
|
||||
const url = `${input.credential.baseUrl}/openai/deployments/${input.credential.deployment}/chat/completions?api-version=2024-10-21`;
|
||||
@@ -241,7 +237,7 @@ export async function runBedrockTurn(input: ProviderToolTurnInput): Promise<Agen
|
||||
const converse: JsonRecord = {
|
||||
messages: toBedrockMessages(input.messages),
|
||||
inferenceConfig: { maxTokens: 4096 },
|
||||
toolConfig: bedrockToolConfig(input.tools, input.toolChoice),
|
||||
toolConfig: bedrockToolConfig(input.tools),
|
||||
...(input.instructions ? { system: [{ text: input.instructions }] } : {}),
|
||||
};
|
||||
const bodyString = JSON.stringify(converse);
|
||||
@@ -263,7 +259,7 @@ export async function runVertexTurn(input: ProviderToolTurnInput): Promise<Agent
|
||||
const { projectId, region, serviceAccountJson } = input.credential;
|
||||
if (!projectId || !region || !serviceAccountJson) throw new Error("Vertex AI credential is incomplete.");
|
||||
const token = await getGcpAccessToken(serviceAccountJson);
|
||||
const body = vertexRequestBody({ model: input.model, instructions: input.instructions, messages: input.messages, tools: input.tools, toolChoice: input.toolChoice });
|
||||
const body = vertexRequestBody({ model: input.model, instructions: input.instructions, messages: input.messages, tools: input.tools });
|
||||
const url = `https://${region}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/${region}/publishers/google/models/${input.model}:generateContent`;
|
||||
const response = await postJson(url, { authorization: `Bearer ${token}` }, body);
|
||||
const parsed = parseGeminiResponse(response.data);
|
||||
|
||||
Reference in new issue
Block a user