-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: agent model override precedence and conditional Google auth loading (#472, #525) #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Filter OpenCode's config.agent to exclude builtinAgents - Ensures user config in pluginConfig.agents takes precedence - Add tests for agent model override precedence
- Add hasGeminiModelAgents() to check if agents use Gemini models - Add willHaveGeminiAgents() to predict Gemini usage from config - Add comprehensive tests for both functions
…u#525) - Conditionally load Google auth plugin based on active Gemini agents - Prevents unnecessary auth prompts when Gemini agents aren't used - Add debug logging for troubleshooting
- Add stack trace logging in loader function - Clarify when network calls actually occur - Helps diagnose unnecessary API calls
|
All contributors have signed the CLA. Thank you! ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR successfully addresses two related configuration issues with clean, well-tested implementations.
Issue #472: Agent Model Override Precedence
- Filters OpenCode's
config.agentto exclude agents already defined inbuiltinAgents - Ensures user overrides in
pluginConfig.agentstake precedence over OpenCode's defaults - Correctly handles both Sisyphus-enabled and disabled configurations
- Test coverage validates precedence in various scenarios including custom agents
Issue #525: Conditional Google Auth Loading
- Introduces
willHaveGeminiAgents()utility that predicts if Gemini agents will be active without building all agents - Only loads Google auth plugin when: (1)
google_auth !== falseAND (2) at least one Gemini agent is active - Prevents unnecessary OAuth prompts when users disable/override all Gemini agents
- Comprehensive edge case handling: disabled agents, model overrides, and non-default Gemini usage
Code Quality
- All changes follow TDD principles with tests written first (RED-GREEN-REFACTOR)
- 16 new test cases provide thorough coverage of edge cases
- Enhanced debug logging aids troubleshooting without functional changes
- Clean integration across multiple files with proper exports and imports
Confidence Score: 5/5
- This PR is safe to merge with high confidence - well-tested bug fixes with no breaking changes
- Perfect score based on: (1) No logic errors found after exhaustive analysis, (2) Comprehensive test coverage with 16 test cases covering edge cases, (3) Clean implementation following project's TDD guidelines, (4) Changes are backwards-compatible and defensive, (5) Clear documentation and debug improvements
- No files require special attention - all changes are well-implemented
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/agents/utils.ts | 5/5 | Added hasGeminiModelAgents and willHaveGeminiAgents utilities for conditional Google auth loading. Logic is sound with proper edge case handling. |
| src/agents/utils.test.ts | 5/5 | Comprehensive test coverage for new Gemini detection utilities with 12 test cases covering edge cases and integration scenarios. |
| src/plugin-handlers/config-handler.ts | 5/5 | Filters OpenCode's config.agent to exclude builtinAgents, ensuring oh-my-opencode overrides take precedence. Applied correctly in both Sisyphus-enabled and disabled branches. |
| src/plugin-handlers/config-handler.test.ts | 5/5 | New test file with 4 test cases validating agent model override precedence. Tests cover default overrides, custom agents, and Sisyphus disabled scenarios. |
| src/index.ts | 5/5 | Conditionally loads Google auth plugin only when Gemini agents are active using willHaveGeminiAgents. Prevents unnecessary auth prompts. |
Sequence Diagram
sequenceDiagram
participant Plugin as oh-my-opencode Plugin
participant Utils as agents/utils
participant ConfigHandler as config-handler
participant Index as index.ts
participant AuthPlugin as antigravity/plugin
Note over Plugin,AuthPlugin: Plugin Initialization
Plugin->>Utils: willHaveGeminiAgents(disabledAgents, agentOverrides)
Utils->>Utils: Check GEMINI_AGENTS against config
Utils->>Utils: Check if any default Gemini agents active
Utils->>Utils: Check if any agent overridden to Gemini
Utils-->>Plugin: hasActiveGeminiAgents = true/false
alt hasActiveGeminiAgents && google_auth !== false
Plugin->>AuthPlugin: createGoogleAntigravityAuthPlugin(ctx)
AuthPlugin-->>Plugin: googleAuthHooks
Note over Plugin: Google auth available
else
Note over Plugin: Skip Google auth (no Gemini agents)
end
Note over Plugin,ConfigHandler: Config Processing
Plugin->>ConfigHandler: configHandler(openCodeConfig)
ConfigHandler->>Utils: createBuiltinAgents(disabled, overrides, ...)
Utils-->>ConfigHandler: builtinAgents
ConfigHandler->>ConfigHandler: Filter openCodeConfig.agent<br/>to exclude builtinAgent keys
ConfigHandler->>ConfigHandler: Merge: builtinAgents → userAgents →<br/>pluginAgents → filteredOpenCodeAgents
Note over ConfigHandler: oh-my-opencode agents<br/>take precedence over<br/>OpenCode defaults
ConfigHandler-->>Plugin: Updated config with correct precedence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 8 files
Confidence score: 3/5
- Gemini agents defined outside
pluginConfigbypass the new Google auth gating insrc/index.ts, so unauthorized Gemini usage is likely and should be resolved before merging. keywordDetectorDisablednow defaulting toundefinedinsrc/index.tsmeans users who opted out of the keyword detector get it re-enabled, which is a regression in user configuration behavior.- Pay close attention to
src/index.tsandsrc/agents/utils.test.ts– the former has gating/config regressions and the latter has an incorrect comment that can mislead future maintenance.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/agents/utils.test.ts">
<violation number="1" location="src/agents/utils.test.ts:210">
P2: Misleading comment contradicts the test code. The `#given` comment says "only multimodal-looker disabled" but the code actually disables `frontend-ui-ux-engineer` and `document-writer`, leaving `multimodal-looker` enabled.</violation>
</file>
<file name="src/index.ts">
<violation number="1" location="src/index.ts:263">
P1: Google auth gating only looks at pluginConfig overrides even though config-handler later merges user/project/plugin agents that may use Gemini models, so Gemini agents defined outside pluginConfig run without the required auth plugin and cannot authenticate.</violation>
<violation number="2" location="src/index.ts:273">
P2: Unintentional removal of `keywordDetectorDisabled` breaks user config. When users disable the `keyword-detector` hook, keyword detection in `claudeCodeHooks` will still run because this option now defaults to `undefined` (falsy), causing `!config.keywordDetectorDisabled` to be `true` in the claude-code-hooks implementation.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…ngyu#525 Previously, Google auth plugin gating only checked pluginConfig.agents for Gemini models, missing agents defined in: - User agents (~/.claude/agents/*.md) - Project agents (.claude/agents/*.md) - Plugin agents (~/.claude/plugins/*/agents/*.md) This caused Gemini agents defined outside pluginConfig to run without the required Google auth plugin, leading to authentication failures. Changes: - Extract model field from agent frontmatter in loaders - Add hasExternalGeminiAgents() to check loaded agent configs - Update auth decision to check all agent sources synchronously - Add comprehensive tests for external Gemini detection Fixes: code-yeongyu#525
Respect disabled_hooks config for keyword-detector in both standalone hook and embedded detection within claudeCodeHooks. Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Summary
Fixes two related issues with agent configuration and Google auth loading:
Changes
Issue #472: Agent Model Override
Issue #525: Conditional Google Auth Loading
Testing
bun run typecheck
bun test
Summary by cubic
Fixes agent model override precedence and gates Google auth on actual Gemini agent usage across builtin and external agents, so user config wins and unnecessary auth prompts or failures are avoided.
Bug Fixes
New Features
Written for commit 43bd65b. Summary will update on new commits.