Skip to content

Agent prompt field is not sent as system message to Ollama-compatible local models #24239

@corneliustd

Description

@corneliustd

Description

Bug Description

When configuring a custom agent with a prompt field in opencode.json, the prompt is not injected as the system message when the agent uses a local model via an OpenAI-compatible provider (e.g. Ollama). The model receives no system prompt at all, so any instructions in the agent prompt are silently ignored.

Plugins

No response

OpenCode version

1.14.24

Steps to reproduce

Steps to Reproduce

  1. Configure a custom agent in opencode.json with a prompt field:
"gentleman-local": {
  "mode": "primary",
  "model": "ollama/qwen2.5:7b",
  "prompt": "Your working directory is /Users/me/project. Always use absolute paths when calling file tools."
}
2. Start a session with this agent
3. Ask it to read a file: read pom.xml
4. The model calls read with a placeholder path like /path/to/pom.xml instead of /Users/me/project/pom.xml
Expected Behavior
The prompt field should be sent as the system message in the chat completion request, exactly as it works for cloud models (e.g. Claude, GPT).
Actual Behavior
The model receives no system prompt. Verified by:
- Checking opencode logs: the prompt content never appears
- Testing the same model directly via curl with the prompt as system message → model behaves correctly
- Testing with inline prompt string in opencode.json (not {file:...}) → same result, prompt is ignored


### Screenshot and/or share link

Evidence
Direct curl with system prompt works correctly:
curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen2.5:7b",
    "messages": [
      {"role": "system", "content": "Working directory: /Users/me/project. Always prepend it to file paths."},
      {"role": "user", "content": "read pom.xml"}
    ],
    "tools": [...]
  }'
# → calls read with /Users/me/project/pom.xml ✅
Same model via opencode agent with prompt set:
# → calls read with /path/to/pom.xml ❌ (prompt was not sent)
Environment
- opencode version: 1.14.24
- OS: macOS (Apple M4, darwin)
- Provider: Ollama 0.21.1 via @ai-sdk/openai-compatible
- Model tested: qwen2.5:7b, qwen2.5-coder:7b
- Cloud agents (Claude Sonnet) work correctly with the same prompt field

### Operating System

26.3.1

### Terminal

iTerm2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions