Skip to content

Conversation

@Yjason-K
Copy link

@Yjason-K Yjason-K commented Jan 8, 2026

Summary

Fixes two related issues with agent configuration and Google auth loading:

Changes

Issue #472: Agent Model Override

  • Filter OpenCode's config.agent to exclude builtinAgents
  • Ensures user config in pluginConfig.agents takes precedence
  • Add tests for agent model override precedence

Issue #525: Conditional Google Auth Loading

  • Add Gemini agent detection utilities (hasGeminiModelAgents, willHaveGeminiAgents)
  • Conditionally load Google auth plugin only when Gemini agents are active
  • Improve debug logging for troubleshooting

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.

Written for commit 43bd65b. Summary will update on new commits.

- 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
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@Yjason-K
Copy link
Author

Yjason-K commented Jan 8, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jan 8, 2026
Copy link

@greptile-apps greptile-apps bot left a 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.agent to exclude agents already defined in builtinAgents
  • Ensures user overrides in pluginConfig.agents take 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 !== false AND (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
Loading

Copy link

@cubic-dev-ai cubic-dev-ai bot left a 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 pluginConfig bypass the new Google auth gating in src/index.ts, so unauthorized Gemini usage is likely and should be resolved before merging.
  • keywordDetectorDisabled now defaulting to undefined in src/index.ts means 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.ts and src/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.

Yjason-K and others added 2 commits January 8, 2026 16:34
…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>
kdcokenny pushed a commit that referenced this pull request Jan 13, 2026
@kdcokenny
Copy link
Collaborator

@Yjason-K Native google auth support was removed in favor of external plugins in #750

I will be closing this issue do to that, but if there are parts of this PR which you think would be useful nonetheless, feel free to open a new PR with those and tag me.

@kdcokenny kdcokenny closed this Jan 13, 2026
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