GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Server API ignores agent's configured model when only agent parameter is passed · Issue #7099 · anomalyco/opencode

Server API ignores agent's configured model when only agent parameter is passed #7099

New issue
Copy link
New issue
Copy link
Closed
Closed
Server API ignores agent's configured model when only agent parameter is passed#7099
Copy link
Assignees
rekram1-node

Description

@cyhhao
cyhhao
opened on Jan 6, 2026
Issue body actions

Description

When using the OpenCode Server HTTP API to send a message with only the agent parameter (without explicitly passing model), the server does not use the agent's configured default model from opencode.json. Instead, it falls back to the global default model.

Configuration in ~/.config/opencode/opencode.json:

{
  "model": "anthropic/claude-opus-4-5",
  "agent": {
    "build": {
      "model": "anthropic/claude-opus-4-5"
    },
    "plan": {
      "model": "openai/gpt-5.2",
      "reasoningEffort": "xhigh"
    }
  }
}

API Request:

curl -X POST "http://localhost:4096/session/{session_id}/message" \
  -H "x-opencode-directory: /path/to/project" \
  -H "Content-Type: application/json" \
  -d '{"agent": "plan", "parts": [{"type": "text", "text": "Hello"}]}'

Expected behavior:
The server should use openai/gpt-5.2 (the model configured for the plan agent).

Actual behavior:
The server uses google/gemini-3-pro-preview (or another fallback model), ignoring the agent's configured model.

Evidence from API response:

{
  "info": {
    "modelID": "gemini-3-pro-preview",
    "providerID": "google",
    "agent": "plan"
  }
}

Additional context:

  • The /agent API endpoint returns native agents (build, plan) without their configured model field, even though the model is specified in opencode.json
  • The /config API only returns custom agents (like code-reviewer) with their model configuration, not native agents
  • According to the documentation, agent-specific models should override the global default

This issue affects users who want to use different models for different agents via the Server API, which is a common use case for building integrations and plugins.

Plugins

[email protected]

OpenCode version

1.1.3

Steps to reproduce

  1. Configure agent-specific models in ~/.config/opencode/opencode.json:

    {
      "agent": {
        "plan": {
          "model": "openai/gpt-5.2"
        }
      }
    }
  2. Start the OpenCode server: opencode serve

  3. Create a session via API:

    curl -X POST "http://localhost:4096/session" \
      -H "x-opencode-directory: /path/to/project" \
      -H "Content-Type: application/json" \
      -d '{}'
  4. Send a message with only the agent parameter:

    curl -X POST "http://localhost:4096/session/{session_id}/message" \
      -H "x-opencode-directory: /path/to/project" \
      -H "Content-Type: application/json" \
      -d '{"agent": "plan", "parts": [{"type": "text", "text": "What model are you?"}]}'
  5. Observe that the response uses a different model than configured for the plan agent

Screenshot and/or share link

No response

Operating System

macOS 15.5

Terminal

No response

Reacted by Steffen and Sam Nydahl

Activity

  1. github-actions
    assigned
    thdxr
    on Jan 6, 2026
  2. github-actions commented on Jan 6, 2026

    @github-actions
    github-actionsBot
    on Jan 6, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • Bug: SDK Messages cause switch back to default model #4901: SDK Messages cause switch back to default model - Similar issue where API/SDK interactions ignore the user's manually selected model and revert to the agent's default model
    • Plugins using noReply seem to cause model to switch to agent default  #4475: Plugins using noReply seem to cause model to switch to agent default - Plugins/API calls causing model configuration to be ignored and revert to agent defaults
    • Custom subagents with explicit model config throw ProviderModelNotFoundError #5623: Custom subagents with explicit model config throw ProviderModelNotFoundError - Issues with custom agents not respecting configured models
    • Subagent with specific model results in model change in build and plan mode #6636: Subagent with specific model results in model change in build and plan mode - Model configuration not being respected for subagents
    • Subtask commands do not inherit model #6928: Subtask commands do not inherit model - Commands not inheriting the agent's configured or selected model

    All of these appear to be related to the same underlying issue: the Server API and other interfaces not properly respecting agent-specific model configurations from opencode.json when only the agent parameter is passed without an explicit model.

    Feel free to ignore if your specific case differs from these.

  3. rekram1-node
    assigned
    rekram1-node
    and unassigned
    thdxr
    on Jan 6, 2026
  4. rekram1-node commented on Jan 6, 2026

    @rekram1-node
    rekram1-node
    on Jan 6, 2026
    Member
    More actions

    /oc if this is a bug, find it and fix it

  5. opencode-agent commented on Jan 6, 2026

    @opencode-agent
    opencode-agentBot
    on Jan 6, 2026 – with OpenCode Agent
    Contributor
    More actions

    Summary of Analysis:

    After extensive code analysis, I investigated the reported issue where the Server API allegedly ignores an agent's configured model when only the agent parameter is passed.

    Key files examined:

    • packages/opencode/src/session/prompt.ts - Model resolution logic at line 806
    • packages/opencode/src/agent/agent.ts - Agent state initialization and model configuration at line 184
    • packages/opencode/src/config/config.ts - Configuration loading and merging
    • packages/opencode/src/server/server.ts - API endpoint handlers
    • packages/opencode/test/agent/agent.test.ts - Existing tests that confirm functionality

    Findings:

    1. The model resolution logic at prompt.ts:806 is correct: model: input.model ?? agent.model ?? (await lastModel(input.sessionID))
    2. The agent configuration loading at agent.ts:184 correctly applies models: if (value.model) item.model = Provider.parseModel(value.model)
    3. Tests at test/agent/agent.test.ts confirm that agent model configuration works correctly (see test "custom agent config overrides native agent properties" at line 136)
    4. The configuration loading from global (~/.config/opencode/) and project directories works correctly

    Possible explanations for the reported issue:

    1. Config file location - The config might not be at the expected path (~/.config/opencode/opencode.json)
    2. State caching - If the server was started before the config was created/modified, the cached state wouldn't include the updated config (restart required)
    3. Environment-specific issue - XDG paths might differ on certain systems

    Conclusion:
    I could not identify a specific bug in the codebase that would cause this behavior. The code logic appears correct and tests pass. The issue is likely environmental or related to state caching behavior. If this is a recurring issue for users, it might be worth adding better diagnostics or documentation about config loading and caching.

    New%20session%20-%202026-01-06T19%3A10%3A22.999Z
    opencode session  |  github run

  6. rekram1-node commented on Jan 6, 2026

    @rekram1-node
    rekram1-node
    on Jan 6, 2026
    Member
    More actions

    This seems to be a bug w/ ur plugin, works fine without it

  7. cyhhao commented on Jan 7, 2026

    @cyhhao
    cyhhao
    on Jan 7, 2026
    ContributorAuthor
    More actions

    Additional Finding: Anthropic Model Routing Bug

    I discovered a separate but related issue. When explicitly passing model parameters to the API, the API reports using the requested model, but the actual model responding is different.

    Test Results

    Requested Model API reports modelID Model self-identifies as
    claude-opus-4-5 claude-opus-4-5 claude-sonnet-4-20250514
    claude-sonnet-4-5 claude-sonnet-4-5 claude-sonnet-4-20250514
    claude-haiku-4-5 claude-haiku-4-5 claude-sonnet-4-20250514
    gpt-4o (OpenAI) gpt-4o ✅ Works correctly

    Reproduction

    # Request claude-opus-4-5
    curl -s -X POST 'http://127.0.0.1:4096/session/{session_id}/message' \
      -H 'Content-Type: application/json' \
      -H 'x-opencode-directory: /tmp/test' \
      -d '{"parts": [{"type": "text", "text": "Respond with ONLY your model name/version, nothing else."}], "model": {"providerID": "anthropic", "modelID": "claude-opus-4-5"}}'
    
    # Response shows modelID: claude-opus-4-5
    # But the text response is: "claude-sonnet-4-20250514"

    Hypothesis

    The [email protected] plugin may be routing all Anthropic requests to claude-sonnet-4 regardless of which model is requested. This could be:

    1. An OAuth tier/permission limitation
    2. A bug in the plugin's model routing logic

    This is a different issue from the agent-config-model problem described in the original issue. Should I open a separate issue for this?

  8. altendky
    added a commit that references this issue on Jan 9, 2026

    fix(tui): wait for model store before auto-submitting --prompt

    b445965
  9. Steffen025 commented on Feb 3, 2026

    @Steffen025
    Steffen025
    on Feb 3, 2026
    More actions

    Confirming this issue WITHOUT any plugins

    I'm experiencing the exact same behavior in a fresh setup without the antigravity plugin.

    My Setup

    • OpenCode 1.1.40
    • Custom agents in .opencode/agents/ with explicit model config
    • No plugins installed

    Agent Definition (.opencode/agents/PerplexityResearcher.md)

    ---
    name: PerplexityResearcher
    model: perplexity/sonar
    ---

    Reproduction

    Task({
      subagent_type: "PerplexityResearcher",
      prompt: "Research X"
    })

    Expected

    Agent uses perplexity/sonar as configured.

    Actual

    Agent runs on session default (Claude), ignoring the agent's model field entirely.

    Evidence

    The code at task.ts:102-105 should respect agent.model:

    const model = agent.model ?? fallback

    But the agent lookup by subagent_type string doesn't seem to load the custom agent definition from .opencode/agents/.

    This is a real bug affecting custom multi-provider agent setups, not just plugin-related.

  10. github-actions commented on Apr 5, 2026

    @github-actions
    github-actionsBot
    on Apr 5, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  11. github-actions
    closed this as completedon Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.