Repository navigation
Description
It seems OpenCode sends two times the system prompt at the beginning of the conversation. The second time includes the <env> information, and the first is just the provider system prompt. I have only been able to test this with Azure OpenAI models, but from the code, I would suspect to happen for everything.
This is how I found out:
- Set up
mitmproxywithuv tool install mitmproxy. - Start it by running
mitmweb. - Trust the certificate
- Run
opencodelike so:HTTP_PROXY=http://127.0.0.1:8080 HTTPS_PROXY=http://127.0.0.1:8080 NODE_EXTRA_CA_CERTS="$HOME/.mitmproxy/mitmproxy-ca-cert.pem" opencode
After the first message, you can see in the browser the requests intercepted by opencode. When I look at them, they look like this (trimming irrelevant stuff):
{
"model": "gpt-4.1",
"max_tokens": 32000,
"temperature": 0,
"messages": [
{
"role": "system",
"content": "You are opencode..."
},
{
"role": "system",
"content": "You are opencode..."
},
{
"role": "user",
"content": "Just tell me hello"
}
],
"tools": ....
}Checking the diffs, between these two system messages, the only difference is:
Here is some useful information about the environment you are running in:
<env>
Working directory: /Users/bernat/.config/opencode
Is directory a git repo: no
Platform: darwin
Today's date: Fri Jul 25 2025
</env>
<project>
</project>
This, as expected, is repeated for every subsequent request of the conversation
$ opencode --version
0.3.67Suspicion
I do not know enough about the caching mechanisms, so uncertain about opening a PR. But it looks to me like this line is duplicating the functionality immediately above. After removing it, I can see how there is two system messages: the first contains whatever the system prompt is, and the second the env info. I'd assume this to be correct?
Activity
thdxr commentedon Jul 25, 2025
yep i introduced this error - pushed a fix will release soon
feat(app): OpenWork Cloud team skills catalog on Skills page (anomaly…