Skip to content

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

Closed

Description

@Steffen025

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

Environment

  • OpenCode: dev branch (commit 83853cc)
  • Providers affected: Any strict API (OpenAI, Vertex AI, OpenRouter, Zen)

Activity

  1. github-actions commented on Feb 10, 2026

    @github-actions
    Contributor

    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:

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

  2. added a commit that references this issue on Feb 10, 2026
    6710bdf
  3. Steffen025 commented on Feb 10, 2026

    @Steffen025
    Author

    Fix submitted in #12967

  4. rekram1-node commented on Feb 16, 2026

    @rekram1-node
    Contributor

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

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

  5. github-actions commented on Apr 18, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions