Skip to content

feat(opencode): hardcode agent to 'build' and remove selection#778

Merged
aaight merged 2 commits intodevfrom
feature/remove-opencode-agent-selection
Mar 13, 2026
Merged

feat(opencode): hardcode agent to 'build' and remove selection#778
aaight merged 2 commits intodevfrom
feature/remove-opencode-agent-selection

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 13, 2026

Summary

  • Hardcoded OpenCode agent to "build" — Removed auto/build/plan selector, always uses build agent
  • Removed agent field from OpenCode schema, settings resolver, and catalog definition
  • Updated UI — OpenCode settings now only show "Web Search" toggle, agent selection removed
  • No DB migration needed — Existing stored settings with agent key are safely stripped by Zod's strip mode

Changes Made

Step 1: Removed agent from OpenCodeSettingsSchema

  • File: src/config/engineSettings.ts
  • Removed the agent: z.enum(['auto', 'build', 'plan']).optional() property from the schema

Step 2: Updated ResolvedOpenCodeSettings interface and resolver

  • File: src/backends/opencode/settings.ts
  • Removed agent from the ResolvedOpenCodeSettings interface (now only requires webSearch)
  • Updated resolveOpenCodeSettings() to return only { webSearch } instead of { agent, webSearch }

Step 3: Removed resolveOpenCodeAgent function and hardcoded 'build'

  • File: src/backends/opencode/index.ts
  • Deleted the resolveOpenCodeAgent() function entirely
  • In execute() method: replaced dynamic agent resolution with hardcoded const agent = 'build' as const

Step 4: Removed agent field from engine catalog

  • File: src/backends/catalog.ts
  • Removed the entire agent select field from OPENCODE_ENGINE_DEFINITION.settings.fields
  • Updated description to remove reference to agent selection

Step 5: Updated unit tests

  • File: tests/unit/backends/opencode.test.ts
  • Removed resolveOpenCodeAgent import and its entire test suite
  • Updated resolveOpenCodeSettings tests to expect only { webSearch }

Testing

✅ All 4,573 unit tests passing
✅ Typecheck: zero errors
✅ Linting: zero errors

Impact

  • Behavior change: OpenCode always uses the "build" agent (previously could be auto/build/plan)
  • Dashboard UI: OpenCode settings panel now only shows "Web Search" toggle
  • Backward compatibility: Existing DB records with agent field will be safely ignored (Zod strip mode)
  • No API changes: Settings are internal to OpenCode engine configuration

https://trello.com/c/eqoHGk2R/296-remove-agent-selection-in-opencode-and-hardcode-to-build

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Clean, well-scoped removal of the OpenCode agent selector. The change is correct and complete across the main code paths — schema, settings resolver, engine execution, catalog, and primary tests are all updated consistently. One stale test reference was missed.

Should Fix

  • tests/unit/config/schema.test.ts:117-135 — The test "accepts opencode engine settings on project config" still sets agent: 'plan' in the input (line 126) and asserts result.engineSettings?.opencode?.agent equals 'plan' (line 133). This passes at runtime because EngineSettingsSchema's transform preserves raw key-value pairs via normalizeEngineSettings, but it's testing behavior for a removed field. This test should be updated to remove the agent references and only assert on webSearch, matching the cleanup done everywhere else in this PR.

Notes

  • buildConfig still configures both build and plan agent blocks in the OpenCode server config (lines 115-123 of index.ts). This is correct — it's the server's config format, not agent selection.
  • The logOpenCodeStart function still accepts agent: 'build' | 'plan'; the hardcoded 'build' as const satisfies this type.
  • Backward compatibility claim is correct: Zod's default strip mode in OpenCodeSettingsSchema.parse() silently drops the unknown agent key from existing DB records.

Remove `agent` field from the two opencode engine settings test cases
in schema.test.ts, matching the cleanup done in the rest of this PR.
The tests now only assert on `webSearch`, which is the only remaining
field in OpenCodeSettingsSchema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

LGTM — Clean, complete removal of the OpenCode agent selection feature. The hardcoded 'build' agent is correctly applied, all schema/settings/catalog/test references are consistently updated, and backward compatibility with existing DB records is preserved via Zod's strip mode.

Minor observation (not blocking): buildConfig still configures a plan agent block in the OpenCode server config, and a few internal function signatures still accept 'build' | 'plan'. These are harmless dead paths — fine to clean up in a follow-up if desired.

@aaight aaight merged commit 31bc464 into dev Mar 13, 2026
6 checks passed
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.

2 participants