You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Agent prompt field is not sent as system message to Ollama-compatible local models #24239
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
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 agent3. Ask it to read a file: read pom.xml4. The model calls read with a placeholder path like /path/to/pom.xml instead of /Users/me/project/pom.xmlExpected BehaviorThe 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 BehaviorThe 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 linkEvidenceDirect 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 System26.3.1### TerminaliTerm2
Wrote an HTTP-mock test alongside the existing sends temperature, tokens, and reasoning options for openai-compatible models test in packages/opencode/test/session/llm.test.ts. It captures the request body sent to an @ai-sdk/openai-compatible provider when an agent has prompt: set:
constagent={name: "ollama-agent",mode: "primary",options: {},permission: [{permission: "*",pattern: "*",action: "allow"}],prompt: "ALWAYS_USE_ABSOLUTE_PATHS_FROM_/home/test",}satisfiesAgent.Info// ... drain via LLM.stream, capture body ...expect(messages[0].role).toBe("system")expect(messages[0].content).toContain("ALWAYS_USE_ABSOLUTE_PATHS_FROM_/home/test")
The test passes — body.messages[0] is a system message containing the agent prompt verbatim. So the prompt does reach the wire on the openai-compatible path.
The symptom you're seeing (Claude works, qwen2.5:7b doesn't is most likely a different mechanism: when agent.prompt is set, SystemPrompt.provider() (the default tool-use guidance, e.g. session/prompt/default.txt) is replaced rather than appended in session/llm.ts:103. Strong cloud models tolerate the missing guidance; smaller local models often don't.
Caveat: the replace behavior is load-bearing for built-in agents (title, summary, compaction, explore) which set their own focused prompt. So a scoped change would have to gate on agent.native. Happy to spin out a separate PR if append-for-non-native is the direction you want.
EOF
)
Activity
tiffanychum commentedon Apr 25, 2026
Tried to reproduce on
dev(27353df).Wrote an HTTP-mock test alongside the existing
sends temperature, tokens, and reasoning options for openai-compatible modelstest inpackages/opencode/test/session/llm.test.ts. It captures the request body sent to an@ai-sdk/openai-compatibleprovider when an agent hasprompt:set:The test passes —
body.messages[0]is asystemmessage containing the agent prompt verbatim. So the prompt does reach the wire on the openai-compatible path.The symptom you're seeing (Claude works, qwen2.5:7b doesn't is most likely a different mechanism: when
agent.promptis set,SystemPrompt.provider()(the default tool-use guidance, e.g.session/prompt/default.txt) is replaced rather than appended insession/llm.ts:103. Strong cloud models tolerate the missing guidance; smaller local models often don't.Caveat: the replace behavior is load-bearing for built-in agents (
title,summary,compaction,explore) which set their own focusedprompt. So a scoped change would have to gate onagent.native. Happy to spin out a separate PR if append-for-non-native is the direction you want.EOF
)
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.