feat(opencode): hardcode agent to 'build' and remove selection#778
feat(opencode): hardcode agent to 'build' and remove selection#778
Conversation
nhopeatall
left a comment
There was a problem hiding this comment.
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 assertsresult.engineSettings?.opencode?.agentequals'plan'(line 133). This passes at runtime becauseEngineSettingsSchema's transform preserves raw key-value pairs vianormalizeEngineSettings, but it's testing behavior for a removed field. This test should be updated to remove theagentreferences and only assert onwebSearch, matching the cleanup done everywhere else in this PR.
Notes
buildConfigstill configures bothbuildandplanagent blocks in the OpenCode server config (lines 115-123 ofindex.ts). This is correct — it's the server's config format, not agent selection.- The
logOpenCodeStartfunction still acceptsagent: 'build' | 'plan'; the hardcoded'build' as constsatisfies this type. - Backward compatibility claim is correct: Zod's default strip mode in
OpenCodeSettingsSchema.parse()silently drops the unknownagentkey 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>
nhopeatall
left a comment
There was a problem hiding this comment.
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.
Summary
auto/build/planselector, always usesbuildagentagentfield from OpenCode schema, settings resolver, and catalog definitionagentkey are safely stripped by Zod's strip modeChanges Made
Step 1: Removed
agentfrom OpenCodeSettingsSchemasrc/config/engineSettings.tsagent: z.enum(['auto', 'build', 'plan']).optional()property from the schemaStep 2: Updated ResolvedOpenCodeSettings interface and resolver
src/backends/opencode/settings.tsagentfrom theResolvedOpenCodeSettingsinterface (now only requireswebSearch)resolveOpenCodeSettings()to return only{ webSearch }instead of{ agent, webSearch }Step 3: Removed resolveOpenCodeAgent function and hardcoded 'build'
src/backends/opencode/index.tsresolveOpenCodeAgent()function entirelyexecute()method: replaced dynamic agent resolution with hardcodedconst agent = 'build' as constStep 4: Removed agent field from engine catalog
src/backends/catalog.tsagentselect field fromOPENCODE_ENGINE_DEFINITION.settings.fieldsdescriptionto remove reference to agent selectionStep 5: Updated unit tests
tests/unit/backends/opencode.test.tsresolveOpenCodeAgentimport and its entire test suiteresolveOpenCodeSettingstests to expect only{ webSearch }Testing
✅ All 4,573 unit tests passing
✅ Typecheck: zero errors
✅ Linting: zero errors
Impact
agentfield will be safely ignored (Zod strip mode)https://trello.com/c/eqoHGk2R/296-remove-agent-selection-in-opencode-and-hardcode-to-build