Description
When using a custom OpenAI-compatible baseURL, prompt cache accounting stays at zero for subagent sessions.
I tested both provider configurations:
npm: "@ai-sdk/openai" with a custom baseURL
npm: "@ai-sdk/openai-compatible" with a custom baseURL
In both cases, after running a subagent task and exporting the subagent session with opencode export <sessionID>, the exported subagent session reports:
"tokens": {
"cache": {
"read": 0,
"write": 0
}
}
Each assistant message in the exported subagent session also reports tokens.cache.read = 0 and tokens.cache.write = 0.
The same custom endpoint does report prompt cache normally in the main conversation. The zero cache accounting appears specific to subagent sessions.
This looks related to, but not identical to:
The difference here is that the issue reproduces with both @ai-sdk/openai and @ai-sdk/openai-compatible, while the main conversation cache works normally. The observed symptom is specifically exported subagent sessions reporting zero cache read/write tokens.
Plugins
None
OpenCode version
1.15.13
Steps to reproduce
- Configure a custom provider with a custom OpenAI-compatible
baseURL using @ai-sdk/openai.
- Run a normal main conversation and confirm prompt cache accounting is non-zero.
- Run a simple subagent task, for example an
explore subagent that reads a few repository files.
- Export the subagent session:
opencode export <subagent-session-id>
- Observe that the exported subagent session has
tokens.cache.read = 0 and tokens.cache.write = 0.
- Repeat with the same custom
baseURL configured through @ai-sdk/openai-compatible.
- Observe the same zero cache accounting in the exported subagent session.
Expected behavior: if prompt caching is enabled and reported for the custom endpoint in the main conversation, subagent sessions should report cache read/write token counts consistently as well.
Actual behavior: both provider paths report zero cache read/write tokens for exported subagent sessions, while the main conversation cache works normally.
Operating System
Windows / win32
Terminal
PowerShell / Windows terminal environment
Description
When using a custom OpenAI-compatible
baseURL, prompt cache accounting stays at zero for subagent sessions.I tested both provider configurations:
npm: "@ai-sdk/openai"with a custombaseURLnpm: "@ai-sdk/openai-compatible"with a custombaseURLIn both cases, after running a subagent task and exporting the subagent session with
opencode export <sessionID>, the exported subagent session reports:Each assistant message in the exported subagent session also reports
tokens.cache.read = 0andtokens.cache.write = 0.The same custom endpoint does report prompt cache normally in the main conversation. The zero cache accounting appears specific to subagent sessions.
This looks related to, but not identical to:
@ai-sdk/openai-compatiblesending the wrong caching shape for some custom/proxy backends.@ai-sdk/openai-compatible.The difference here is that the issue reproduces with both
@ai-sdk/openaiand@ai-sdk/openai-compatible, while the main conversation cache works normally. The observed symptom is specifically exported subagent sessions reporting zero cache read/write tokens.Plugins
None
OpenCode version
1.15.13
Steps to reproduce
baseURLusing@ai-sdk/openai.exploresubagent that reads a few repository files.tokens.cache.read = 0andtokens.cache.write = 0.baseURLconfigured through@ai-sdk/openai-compatible.Expected behavior: if prompt caching is enabled and reported for the custom endpoint in the main conversation, subagent sessions should report cache read/write token counts consistently as well.
Actual behavior: both provider paths report zero cache read/write tokens for exported subagent sessions, while the main conversation cache works normally.
Operating System
Windows / win32
Terminal
PowerShell / Windows terminal environment