Skip to content

fix(cli): strip internal agent metadata from provider request options - #11767

Merged
chrarnoldus merged 5 commits into
mainfrom
fix/strip-agent-internal-options
Jun 30, 2026
Merged

fix(cli): strip internal agent metadata from provider request options#11767
chrarnoldus merged 5 commits into
mainfrom
fix/strip-agent-internal-options

Conversation

@chrarnoldus

@chrarnoldus chrarnoldus commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #11754. Non-default agents (Ask, Plan, org-provided modes, marketplace agents like Code-Reviewer, and Scout/reference agents) failed with a 400 Unsupported parameter(s) error on strict providers (e.g. NVIDIA NIM, GLM-5.1, MiniMax M3).

Root cause

agent.options is forwarded verbatim into providerOptions (session/llm/request.ts), relying on the upstream invariant that it only holds genuine provider options. Kilo broke that invariant by storing internal/UI-only metadata there:

  • displayName — human-readable name (org/marketplace agents)
  • source — origin marker (organization)
  • id — mode identifier, promoted into options by the upstream "unknown frontmatter key" normalization and read in session/prompt.ts
  • reference / resolved — configured reference descriptors for Scout/reference agents (agent/agent.ts)

The default Code agent has empty options, which is why only non-default agents were affected. The Kilo gateway masks the symptom because kiloProviderOptions whitelists fields instead of forwarding the raw blob.

Fix

An allowlist is impossible — arbitrary options keys are legitimately provider options (that's how reasoningEffort etc. are configured via frontmatter). So stripInternalOptions (in the Kilo-owned src/kilocode/agent/options.ts) drops only the known internal keys (id, displayName, source, reference, resolved) from agent.options just before they are merged into providerOptions, behind a single kilocode_change marker in the shared upstream request.ts. Genuine provider options pass through untouched, and agent.options itself is not mutated.

Related

#11773 (merged) is the complementary refactor that carries displayName/source as typed agent fields so they no longer enter options at the source. This PR is the runtime safety net and additionally covers id, reference, and resolved.

Notes

Local bun test / typecheck could not be run in this environment (missing @opentui/solid preload and a broken @babel/traverse in the dep cache). The added helper is dependency-free; logic is covered by test/kilocode/agent-options-strip.test.ts.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@chrarnoldus chrarnoldus self-assigned this Jun 29, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/kilocode/agent/options.ts
  • packages/opencode/test/kilocode/agent-options-strip.test.ts
Previous Review Summaries (3 snapshots, latest commit be7e978)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit be7e978)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilocode/agent/options.ts 15 stripInternalOptions only removes id, displayName, and source, but configured Scout agents also store reference and resolved in agent.options, so strict providers can still reject those requests with unsupported-parameter 400s.
Files Reviewed (4 files)
  • .changeset/strip-agent-internal-options.md
  • packages/opencode/src/kilocode/agent/options.ts - 1 issue
  • packages/opencode/src/session/llm/request.ts
  • packages/opencode/test/kilocode/agent-options-strip.test.ts

Previous review (commit d275dce)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/config/agent.ts 54 source is validated as an arbitrary string even though downstream logic treats it as a fixed origin enum, so malformed values can bypass the organization-agent removal guard.
Files Reviewed (6 files)
  • packages/opencode/src/agent/agent.ts
  • packages/opencode/src/config/agent.ts - 1 issue
  • packages/opencode/src/kilocode/agent/index.ts
  • packages/opencode/src/kilocode/modes-migrator.ts
  • packages/opencode/test/kilocode/agent-options-strip.test.ts
  • packages/opencode/test/kilocode/modes-migrator.test.ts

Previous review (commit c94a097)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .changeset/strip-agent-internal-options.md
  • packages/opencode/src/kilocode/agent/options.ts
  • packages/opencode/src/session/llm/request.ts
  • packages/opencode/test/kilocode/agent-options-strip.test.ts

Reviewed by gpt-5.4-20260305 · Input: 56.7K · Output: 5K · Cached: 221.7K

Review guidance: REVIEW.md from base branch main

Comment thread packages/opencode/src/config/agent.ts
chrarnoldus and others added 3 commits June 29, 2026 16:19
…nal-options

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Comment thread packages/opencode/src/kilocode/agent/options.ts Outdated
…vider options

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@chrarnoldus
chrarnoldus merged commit ac987f5 into main Jun 30, 2026
27 checks passed
@chrarnoldus
chrarnoldus deleted the fix/strip-agent-internal-options branch June 30, 2026 12:23
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…nal-options

fix(cli): strip internal agent metadata from provider request options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Non-Coding Agents (Ask, Plan, Code-Reviewer) Fail with "Unsupported parameter(s): displayName, id" on Multiple Models/Providers

2 participants