Bug: Unknown agent frontmatter fields leak into LLM API request body via options #8973

Open
opened 2026-02-16 18:11:18 -05:00 by yindo · 3 comments
Owner

Originally created by @Steffen025 on GitHub (Feb 10, 2026).

Originally assigned to: @thdxr on GitHub.

Description

Unknown YAML frontmatter fields in custom agent .md files (e.g. tts, permissions, voice, tags, metadata) are silently collected into agent.options by the .catchall(z.any()).transform() in config.ts. These then get merged into the LLM API request body via mergeDeep(input.agent.options) in llm.ts:111.

Strict API providers (OpenAI, Vertex AI, OpenRouter/Zen) reject the request with errors like Extra inputs are not permitted, causing agents to silently return empty responses.

Root Cause

In packages/opencode/src/config/config.ts (~line 728-732):

const options: Record<string, unknown> = { ...agent.options }
for (const [key, value] of Object.entries(agent)) {
  if (!knownKeys.has(key)) options[key] = value  // ← unknown fields go into options
}

Then in llm.ts:111, mergeDeep(input.agent.options) sends them to the API.

Steps to Reproduce

  1. Create a custom agent .md file with any non-standard frontmatter field:
    ---
    name: my-agent
    model: openai/gpt-4o
    tts: true
    custom_field: "hello"
    ---
    
  2. Spawn this agent via Task tool
  3. The API request body will contain tts: true and custom_field: "hello"
  4. Strict providers reject the request; the agent returns empty/broken output

Expected Behavior

Only fields explicitly declared under options: in frontmatter should be sent to the LLM API. Unknown fields should be preserved on the agent object (for hooks/plugins) but not merged into API requests.

Related Issues

  • #4282 — Vertex AI Extra inputs are not permitted (same root cause)
  • #12950 — Agents giving raw <tool_call> responses (likely same root cause)

Environment

  • OpenCode: dev branch (commit 83853cc)
  • Providers affected: Any strict API (OpenAI, Vertex AI, OpenRouter, Zen)
Originally created by @Steffen025 on GitHub (Feb 10, 2026). Originally assigned to: @thdxr on GitHub. ## Description Unknown YAML frontmatter fields in custom agent `.md` files (e.g. `tts`, `permissions`, `voice`, `tags`, `metadata`) are silently collected into `agent.options` by the `.catchall(z.any()).transform()` in `config.ts`. These then get merged into the LLM API request body via `mergeDeep(input.agent.options)` in `llm.ts:111`. Strict API providers (OpenAI, Vertex AI, OpenRouter/Zen) reject the request with errors like `Extra inputs are not permitted`, causing agents to silently return empty responses. ## Root Cause In `packages/opencode/src/config/config.ts` (~line 728-732): ```typescript const options: Record<string, unknown> = { ...agent.options } for (const [key, value] of Object.entries(agent)) { if (!knownKeys.has(key)) options[key] = value // ← unknown fields go into options } ``` Then in `llm.ts:111`, `mergeDeep(input.agent.options)` sends them to the API. ## Steps to Reproduce 1. Create a custom agent `.md` file with any non-standard frontmatter field: ```yaml --- name: my-agent model: openai/gpt-4o tts: true custom_field: "hello" --- ``` 2. Spawn this agent via Task tool 3. The API request body will contain `tts: true` and `custom_field: "hello"` 4. Strict providers reject the request; the agent returns empty/broken output ## Expected Behavior Only fields explicitly declared under `options:` in frontmatter should be sent to the LLM API. Unknown fields should be preserved on the agent object (for hooks/plugins) but not merged into API requests. ## Related Issues - #4282 — Vertex AI `Extra inputs are not permitted` (same root cause) - #12950 — Agents giving raw `<tool_call>` responses (likely same root cause) ## Environment - OpenCode: dev branch (commit 83853cc) - Providers affected: Any strict API (OpenAI, Vertex AI, OpenRouter, Zen)
Author
Owner

@github-actions[bot] commented on GitHub (Feb 10, 2026):

This issue has been validated and appears to be a root cause analysis for the following related issues. If this is confirmed as the fix, those issues should be marked as duplicates:

  • #4282: Vertex AI 'Extra inputs are not permitted' error (same API validation error)
  • #12950: Agents giving raw <tool_call> responses (likely the same root cause)

The detailed root cause analysis and reproduction steps provided here are well-documented and will be helpful for implementing a fix.

@github-actions[bot] commented on GitHub (Feb 10, 2026): This issue has been validated and appears to be a root cause analysis for the following related issues. If this is confirmed as the fix, those issues should be marked as duplicates: - #4282: Vertex AI 'Extra inputs are not permitted' error (same API validation error) - #12950: Agents giving raw `<tool_call>` responses (likely the same root cause) The detailed root cause analysis and reproduction steps provided here are well-documented and will be helpful for implementing a fix.
Author
Owner

@Steffen025 commented on GitHub (Feb 10, 2026):

Fix submitted in #12967

@Steffen025 commented on GitHub (Feb 10, 2026): Fix submitted in #12967
Author
Owner

@rekram1-node commented on GitHub (Feb 16, 2026):

This is intentional behavior, what purpose do those fields serve for u?

This is also documented:
https://opencode.ai/docs/agents/#additional

@rekram1-node commented on GitHub (Feb 16, 2026): This is intentional behavior, what purpose do those fields serve for u? This is also documented: https://opencode.ai/docs/agents/#additional
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8973