Skip to content

The agent that grows with you

fix(agent): recover opencode zen encrypted replay

KoNit-K7d03ea3adf12
diff --git a/agent/error_classifier.py b/agent/error_classifier.py
index d0277efe69b..b90a39daac4 100644
--- a/agent/error_classifier.py
+++ b/agent/error_classifier.py
@@ -792,6 +792,9 @@ def _classify_400(c: _Ctx) -> Verdict:
) or "could not decrypt the provided encrypted_content" in msg or (
# Custom Responses endpoints wrap a replay rejection in a generic bad_request (#95834).
"encrypted content could not be decrypted or parsed" in msg
+ ) or (
+ # OpenCode Zen wraps this OpenAI replay rejection in ``invalid_request_error`` (#111309).
+ "encrypted_content" in msg and "was not issued to this caller" in msg
) or (
# Azure Foundry (gpt-6-astra) rejects replayed reasoning from several prior responses this way (#105369).
"conflicting authenticated continuation identities" in msg
diff --git a/tests/agent/test_error_classifier.py b/tests/agent/test_error_classifier.py
index 3cdf06e948d..69b45e27321 100644
--- a/tests/agent/test_error_classifier.py
+++ b/tests/agent/test_error_classifier.py
@@ -819,6 +819,18 @@ class TestClassifyApiError:
assert result.retryable is True
assert result.should_fallback is False
+ def test_opencode_zen_wrapped_replay_rejection_reaches_replay_strip(self):
+ """OpenCode Zen wraps the rejected encrypted replay in a generic 400."""
+ e = MockAPIError(
+ "HTTP 400: Error from provider (Console): Upstream request failed: "
+ "[invalid_request_error] reasoning `encrypted_content` was not issued to this caller",
+ status_code=400,
+ )
+ result = classify_api_error(e, provider="opencode-zen", model="muse-spark-1.3-contributor-free")
+ assert result.reason == FailoverReason.invalid_encrypted_content
+ assert result.retryable is True
+ assert result.should_fallback is False
+
# ── Codex masked encrypted-reasoning replay rejection (#92353) ──
_CODEX_MASKED = {"message": "Request blocked.", "type": "invalid_request_error", "param": None, "code": "invalid_prompt"}