[PR #12967] fix(config): prevent agent frontmatter fields from leaking into LLM API requests #14456

Open
opened 2026-02-16 18:19:14 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12967

State: open
Merged: No


Summary

Unknown YAML frontmatter fields in custom agent .md files (e.g. tts, permissions, voice) are collected into agent.options and merged into LLM API request bodies via mergeDeep in llm.ts. Strict providers (OpenAI, Vertex AI, OpenRouter) reject extra fields, causing agents to silently fail.

This PR stores unknown fields in a separate metadata property instead, so only explicitly declared options: fields reach the API.

Fixes #12964
Related: #4282, #12950

What Changed

One file: packages/opencode/src/config/config.ts

  • Unknown frontmatter fields now go into metadata instead of options
  • Explicitly declared options: in frontmatter still works as before
  • metadata is available on the agent object for hooks/plugins that need it

Testing

Verified with 6 agent types across 3 LLM providers (Kimi K2.5, MiniMax M2.1, GLM 4.7 via Zen). All agents that previously failed with empty responses now work correctly.

The @opencode-ai/desktop#typecheck failure in CI is pre-existing (missing @tauri-apps/plugin-clipboard-manager dependency) and unrelated to this change.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12967 **State:** open **Merged:** No --- ## Summary Unknown YAML frontmatter fields in custom agent `.md` files (e.g. `tts`, `permissions`, `voice`) are collected into `agent.options` and merged into LLM API request bodies via `mergeDeep` in `llm.ts`. Strict providers (OpenAI, Vertex AI, OpenRouter) reject extra fields, causing agents to silently fail. This PR stores unknown fields in a separate `metadata` property instead, so only explicitly declared `options:` fields reach the API. Fixes #12964 Related: #4282, #12950 ## What Changed **One file:** `packages/opencode/src/config/config.ts` - Unknown frontmatter fields now go into `metadata` instead of `options` - Explicitly declared `options:` in frontmatter still works as before - `metadata` is available on the agent object for hooks/plugins that need it ## Testing Verified with 6 agent types across 3 LLM providers (Kimi K2.5, MiniMax M2.1, GLM 4.7 via Zen). All agents that previously failed with empty responses now work correctly. The `@opencode-ai/desktop#typecheck` failure in CI is pre-existing (missing `@tauri-apps/plugin-clipboard-manager` dependency) and unrelated to this change.
yindo added the pull-request label 2026-02-16 18:19:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14456