Conversation
…ousResearch#24617) OpenCode Go is a gateway that implements `cache_control` at its own level, not per model. The same envelope-layout marker injection that makes Qwen on opencode-go pay the cached-read rate also works for DeepSeek models on the same gateway — the model switcher reports `$0.01/M cache read` pricing for `deepseek-v4-pro` on opencode-go, confirming gateway-side cache support. Without markers Hermes serves 0% cache hits and re-bills the full prompt on every turn (~75% cost overhead on 300K+ token conversations). Extend the alibaba-family branch in `_anthropic_prompt_cache_policy` to accept DeepSeek models alongside Qwen on the four opencode/opencode-zen/opencode-go/alibaba providers. The wire format (OpenAI chat completions) and marker layout (envelope, not native) are identical to the existing Qwen path; this is purely an expansion of the model whitelist. Tests cover deepseek-v4-pro on opencode-go (the reported case), deepseek-v3.5 on opencode-zen, and confirm DeepSeek via OpenRouter still falls through to its own caching arrangement. Fixes NousResearch#24617
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for isolating the cache-policy gap. Current main still falls through to (False, False) for DeepSeek because agent/agent_runtime_helpers.py:1629-1639 only recognizes Qwen, and agent/conversation_loop.py:889-894 shows that a true policy result is what injects the request cache markers.
Problems
- The changed predicate at
run_agent.py:3582also enables DeepSeek for directalibaba. The linked issue supports OpenCode Zen/Go, but current main's Alibaba catalog contains Qwen, Kimi, GLM, and MiniMax entries—not DeepSeek (hermes_cli/models.py:491-502). Keep the direct-Alibaba allowance specific to Qwen unless DeepSeek support there is independently verified. - The target function has moved:
run_agent.py:1358-1368now forwards toagent/agent_runtime_helpers.pyafter c42fa94.
Suggested changes
- Salvage the policy change into
agent/agent_runtime_helpers.py, separating the Qwen four-provider condition from a DeepSeek OpenCode-only condition. - Add a negative direct-Alibaba DeepSeek policy test alongside the OpenCode positives.
Automated hermes-sweeper review.
| "opencode", "opencode-zen", "opencode-go", "alibaba", | ||
| } | ||
| if provider_is_alibaba_family and model_is_qwen: | ||
| if provider_is_alibaba_family and (model_is_qwen or model_is_deepseek): |
Collaborator
There was a problem hiding this comment.
This combines DeepSeek with Qwen across direct alibaba, although the linked report establishes OpenCode Zen/Go only and main's curated Alibaba catalog has no DeepSeek entry (hermes_cli/models.py:491-502). Keep Qwen on all four providers, but scope DeepSeek to the OpenCode provider IDs and add a negative direct-Alibaba test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenCode Go is a gateway that implements
cache_controlat its own level, not per model — the same envelope-layout marker injection that makes Qwen onopencode-gopay the cached-read rate also works for DeepSeek models on the same gateway. The model switcher reports\$0.01/M cache readpricing fordeepseek-v4-proonopencode-go, confirming gateway-side cache support. Without markers Hermes serves 0% cache hits and re-bills the full prompt on every turn.Fix
Extend the alibaba-family branch in
_anthropic_prompt_cache_policy(run_agent.py:3570) to accept DeepSeek models alongside Qwen on the fouropencode/opencode-zen/opencode-go/alibabaproviders. The wire format (OpenAI chat completions) and marker layout (envelope, not native) are identical to the existing Qwen path — this is purely an expansion of the model whitelist.Test plan
test_deepseek_on_opencode_go_caches_with_envelope_layout— the reported case (deepseek-v4-proonopencode-go) returns(True, False).test_deepseek_on_opencode_zen_caches— same marker layout onopencode-zen.test_deepseek_on_openrouter_not_affected— DeepSeek via OpenRouter still falls through to its own caching arrangement (no regression for non-alibaba-family providers).tests/run_agent/test_anthropic_prompt_cache_policy.pystill pass.Risk
Zero. If the gateway doesn't honor cache for a specific DeepSeek model, the markers are silently ignored. Non-DeepSeek/non-Qwen models on opencode-go (GLM, Kimi) keep falling through to
(False, False)as before — verified by the existingtest_non_qwen_on_opencode_go_does_not_cacheandtest_kimi_on_opencode_go_does_not_cache.Fixes #24617