-
Notifications
You must be signed in to change notification settings - Fork 803
Description
Description
When using Oh-My-OpenCode with OAuth providers (e.g., Google Antigravity) or custom model configurations, the system frequently reverts to hardcoded Anthropic models instead of preserving the user's selected model across agent handoffs and background task continuations.
This happens particularly when:
- Specialized agents (Planner/Sisyphus, Librarian, Oracle) are invoked
- Background agents complete and "kick" work back to the main session
- Agent continuation/handoff occurs
Steps to Reproduce
- Configure Oh-My-OpenCode with a non-Anthropic model provider (e.g., Google OAuth with
google/claude-opus-4-5-thinking) - Start a session using your configured model
- Trigger a specialized agent (e.g., run a planning task that uses Planner-Sisyphus)
- Observe the model being used in the agent's response
- Notice that subsequent messages revert to
anthropic/claude-opus-4-5oranthropic/claude-sonnet-4-5
Expected Behavior
The system should preserve the user's selected model across:
- Agent handoffs
- Background task completions
- Session continuations
- Specialized agent invocations
If a user is authenticated via Google OAuth and usinggoogle/claude-opus-4-5-thinking, all agents and continuations should respect this choice unless explicitly overridden.
Actual Behavior
The system reverts to hardcoded models:
- Sisyphus (Planner):
anthropic/claude-opus-4-5 - Librarian:
anthropic/claude-sonnet-4-5 - Oracle:
openai/gpt-5.2 - Background agent continuations lose model context entirely
Root Cause Analysis
After investigating the codebase, I identified three primary issues:
1. Hardcoded Agent Models
Files affected:
src/agents/sisyphus.ts(line ~12)src/agents/librarian.ts(line ~10)src/agents/oracle.ts(line ~8)
Each specialized agent has a hardcodedDEFAULT_MODELconstant that overrides user configuration:
// sisyphus.ts
const DEFAULT_MODEL = "anthropic/claude-opus-4-5"
// librarian.ts
const DEFAULT_MODEL = "anthropic/claude-sonnet-4-5"2. Background Agent Manager Missing Model Context
File: src/features/background-agent/manager.ts (around line 370)
When background tasks notify the parent session after completion:
const prevMessage = messageDir ? findNearestMessageWithFields(messageDir) : null
await this.client.session.prompt({
path: { id: task.parentSessionID },
body: {
agent: prevMessage?.agent, // Preserves agent
// MISSING: model field is not preserved!
parts: [{ type: "text", text: message }],
},
})The model field is not carried forward, causing fallback to default models.
3. Incomplete Model Context Propagation
While src/features/hook-message-injector/injector.ts contains logic to find model context via findNearestMessageWithFields(), it can only work if the model information is actually passed through agent handoffs (which it currently isn't).
Proposed Solutions
Solution 1: Fix Background Agent Manager (Critical)
Update src/features/background-agent/manager.ts to preserve model context:
const prevMessage = messageDir ? findNearestMessageWithFields(messageDir) : null
await this.client.session.prompt({
path: { id: task.parentSessionID },
body: {
agent: prevMessage?.agent,
model: prevMessage?.model // ADD THIS
? {
providerID: prevMessage.model.providerID,
modelID: prevMessage.model.modelID,
}
: undefined,
parts: [{ type: "text", text: message }],
},
})Solution 2: Make Agent Models Configurable
Instead of hardcoded defaults, allow agents to respect user configuration:
// Example for sisyphus.ts
const getDefaultModel = (userConfig) => {
// Priority: OAuth provider > User preference > Fallback default
if (userConfig.oauthModel?.provider) {
return `${userConfig.oauthModel.provider}/${userConfig.oauthModel.modelId}`
}
return userConfig.preferredModel || "anthropic/claude-opus-4-5"
}Solution 3: Add Configuration Option
Add a user preference in config:
{
"modelPersistence": {
"preserveAcrossAgents": true,
"respectAgentDefaults": false
}
}Environment
- Oh-My-OpenCode Version: latest from main branch
- Node Version: v22.x
- OS: Linux
- OAuth Provider: Google Antigravity
- Configured Model:
google/claude-opus-4-5-thinkingorgoogle/claude-sonnet-4-5
Impact
This issue affects:
- Users with OAuth providers (Google, custom providers)
- Users with non-Anthropic model preferences
- Multi-agent workflows where model consistency is critical
- Background task continuations
Additional Context
This bug makes it difficult to use Oh-My-OpenCode with alternative model providers, as the system constantly reverts to Anthropic models regardless of user configuration. This is particularly problematic for:
- Users who don't have Anthropic API access
- Users leveraging OAuth authentication with other providers
- Teams standardizing on specific models for consistency
Workarounds
Temporary workarounds while waiting for a fix:
- Avoid using specialized agents (Planner, Librarian, Oracle)
- Manually re-select model after each agent handoff (if CLI supports it)
- Fork the repo and apply the proposed fixes locally
Would you like me to submit a PR?
I'm happy to contribute a fix if the maintainers are open to it. The changes are relatively straightforward and focused on:
- Preserving model context in background agent manager
- Making agent model defaults configurable
- Respecting user OAuth provider settings