summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKnut Zuidema <[email protected]>2026-03-30 05:48:17 +0200
committerGitHub <[email protected]>2026-03-29 22:48:17 -0500
commit196a03caff570d98a116c5c29e9fddda03b7c824 (patch)
tree5f5b2a110933b8f36309117ca10dcf9e145a7474
parentb2343700807e8ab33549a5a2fbd8652d9e1626f2 (diff)
downloadopencode-196a03caff570d98a116c5c29e9fddda03b7c824.tar.gz
opencode-196a03caff570d98a116c5c29e9fddda03b7c824.zip
fix: discourage _noop tool call during LiteLLM compaction (#18539)
-rw-r--r--packages/opencode/src/session/compaction.ts1
-rw-r--r--packages/opencode/src/session/llm.ts14
2 files changed, 12 insertions, 3 deletions
diff --git a/packages/opencode/src/session/compaction.ts b/packages/opencode/src/session/compaction.ts
index 223e71639..69759c0d9 100644
--- a/packages/opencode/src/session/compaction.ts
+++ b/packages/opencode/src/session/compaction.ts
@@ -176,6 +176,7 @@ export namespace SessionCompaction {
const defaultPrompt = `Provide a detailed prompt for continuing our conversation above.
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.
The summary that you construct will be used so that another agent can read it and continue the work.
+Do not call any tools. Respond only with the summary text.
When constructing the summary, try to stick to this template:
---
diff --git a/packages/opencode/src/session/llm.ts b/packages/opencode/src/session/llm.ts
index 02b72f70a..c63fb180e 100644
--- a/packages/opencode/src/session/llm.ts
+++ b/packages/opencode/src/session/llm.ts
@@ -199,11 +199,19 @@ export namespace LLM {
input.model.providerID.toLowerCase().includes("litellm") ||
input.model.api.id.toLowerCase().includes("litellm")
+ // LiteLLM/Bedrock rejects requests where the message history contains tool
+ // calls but no tools param is present. When there are no active tools (e.g.
+ // during compaction), inject a stub tool to satisfy the validation requirement.
+ // The stub description explicitly tells the model not to call it.
if (isLiteLLMProxy && Object.keys(tools).length === 0 && hasToolCalls(input.messages)) {
tools["_noop"] = tool({
- description:
- "Placeholder for LiteLLM/Anthropic proxy compatibility - required when message history contains tool calls but no active tools are needed",
- inputSchema: jsonSchema({ type: "object", properties: {} }),
+ description: "Do not call this tool. It exists only for API compatibility and must never be invoked.",
+ inputSchema: jsonSchema({
+ type: "object",
+ properties: {
+ reason: { type: "string", description: "Unused" },
+ },
+ }),
execute: async () => ({ output: "", title: "", metadata: {} }),
})
}