-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
I am trying to use a Bedrock model behind a LiteLLM proxy. This configuration works well for the built-in plan and build agents in opencode, but when I try to create a custom agent, I can't make any calls using that agent without getting the following error.
AI_APICallError: litellm.BadRequestError: BedrockException - {"message":"The model returned the following errors: name: Extra inputs are not permitted"}. Received Model Group=anthropic.claude-sonnet-4 ┃
┃ Available Model Group Fallbacks=None
I asked opencode to analyze the opencode codebase for this problem (full disclosure) And it's claiming the following:
Perfect! Here's the custom agent parsing flow:
Custom Agent Config Reading and Parsing
Location: /home/wreed/Documents/opencode/packages/opencode/src/config/config.ts:46-80
Step-by-step process:
-
File Discovery (
config.ts:46-49):const markdownAgents = [ ...(await Filesystem.globUp("agent/**/*.md", Global.Path.config, Global.Path.config)), ...(await Filesystem.globUp(".opencode/agent/**/*.md", app.path.cwd, app.path.root)), ]
Searches for
*.mdfiles inagent/and.opencode/agent/directories -
YAML Frontmatter Parsing (
config.ts:51-53):const content = await Bun.file(item).text() const md = matter(content) // This parses YAML frontmatter if (!md.data) continue
Uses the
matterlibrary to extract YAML frontmatter from markdown files -
Agent Name Extraction (
config.ts:55-68):
Derives agent name from file path and handles nested folders -
Config Object Creation (
config.ts:70-74):const config = { name: agentName, // ← This adds the "name" field! ...md.data, // ← Your YAML frontmatter (including reasoningEffort) prompt: md.content.trim(), }
-
Processing in Agent Module (
agent.ts:103-107):const { model, prompt, tools, description, temperature, top_p, mode, permission, ...extra } = value item.options = { ...item.options, ...extra, // Both "name" and "reasoningEffort" end up here! }
The Issue
The config parsing adds a name field (config.ts:71) that gets included in the ...extra spread along with your reasoningEffort field. Both of these end up in agent.options and get passed to the AI SDK, which LiteLLM then forwards to Bedrock, causing the "Extra inputs not permitted" error.
Built-in agents don't go through this YAML parsing, so they don't have these extra fields.
Namely, it's seeing that we're adding a "name" field to the config which later ends up getting passed to agent.options.
Can someone with some more experience in this codebase vet this diagnosis?