Skip to content

Commit 196a03c

Browse files
authored
fix: discourage _noop tool call during LiteLLM compaction (anomalyco#18539)
1 parent b234370 commit 196a03c

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

packages/opencode/src/session/compaction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export namespace SessionCompaction {
176176
const defaultPrompt = `Provide a detailed prompt for continuing our conversation above.
177177
Focus on information that would be helpful for continuing the conversation, including what we did, what we're doing, which files we're working on, and what we're going to do next.
178178
The summary that you construct will be used so that another agent can read it and continue the work.
179+
Do not call any tools. Respond only with the summary text.
179180
180181
When constructing the summary, try to stick to this template:
181182
---

packages/opencode/src/session/llm.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,19 @@ export namespace LLM {
199199
input.model.providerID.toLowerCase().includes("litellm") ||
200200
input.model.api.id.toLowerCase().includes("litellm")
201201

202+
// LiteLLM/Bedrock rejects requests where the message history contains tool
203+
// calls but no tools param is present. When there are no active tools (e.g.
204+
// during compaction), inject a stub tool to satisfy the validation requirement.
205+
// The stub description explicitly tells the model not to call it.
202206
if (isLiteLLMProxy && Object.keys(tools).length === 0 && hasToolCalls(input.messages)) {
203207
tools["_noop"] = tool({
204-
description:
205-
"Placeholder for LiteLLM/Anthropic proxy compatibility - required when message history contains tool calls but no active tools are needed",
206-
inputSchema: jsonSchema({ type: "object", properties: {} }),
208+
description: "Do not call this tool. It exists only for API compatibility and must never be invoked.",
209+
inputSchema: jsonSchema({
210+
type: "object",
211+
properties: {
212+
reason: { type: "string", description: "Unused" },
213+
},
214+
}),
207215
execute: async () => ({ output: "", title: "", metadata: {} }),
208216
})
209217
}

0 commit comments

Comments
 (0)