fix(codex-bridge): preserve plaintext peer tasks and fail invalid transfers without retries
Server CI and Windows package / verify (push) Successful in 6m11s
Server CI and Windows package / windows-package (push) Successful in 17m49s

This commit is contained in:
yilsem committed 2026-10-20 07:35:41 +03:00
1 parent 212015e7c9
commit 1aa033a751
8 files changed
+143 -10

No files matched your search

@@ -281,6 +281,42 @@ class PreparationService(unittest.TestCase):
class SocketMigration(fixtures.Ayirici):
def test_opaque_peer_transfer_fails_as_http_400_before_sse_or_upstream(self):
req = {"model": "ide/agy-gemini-3.8-flash-high", "prompt_cache_key": "opaque-peer",
"input": [{"type": "agent_message", "author": "/root", "recipient": "/root/peer",
"content": [{"type": "input_text", "text": "Message Type: NEW_TASK\nPayload:\n"},
{"type": "encrypted_content", "encrypted_content": "gAAAA_synthetic_opaque"}]}]}
original = copy.deepcopy(req)
raw = json.dumps(req).encode()
# Identical retries must receive the same permanent error without a
# preparation request, a stream heartbeat, or provider inference.
for _ in range(2):
status, body, headers = self.iste("POST", "/backend-api/codex/responses", raw)
self.assertEqual(status, 400)
self.assertEqual(headers["Content-Type"].split(";")[0], "application/json")
self.assertNotIn("Transfer-Encoding", headers)
error = json.loads(body)["error"]
self.assertEqual(error["code"], "aiturk_transfer_failed")
self.assertEqual(error["type"], "invalid_request_error")
self.assertFalse(error["retryable"])
self.assertIn("görev eksik gönderilmedi", error["message"])
self.assertNotIn(b"response.failed", body)
self.assertEqual(req, original)
self.assertEqual(self.ozgun.gelen, [])
self.assertEqual(self.kopru.gelen, [])
self.assertEqual(bridge.TRANSFERS, {})
def test_native_opaque_peer_history_remains_byte_identical_on_owner_route(self):
req = {"model": "gpt-6-astra", "input": [{"type": "agent_message", "author": "/root",
"recipient": "/root/peer", "content": [{"type": "encrypted_content",
"encrypted_content": "gAAAA_synthetic_native_owner"}]}]}
raw = zstd(json.dumps(req).encode())
status, _, _ = self.iste("POST", "/backend-api/codex/responses", raw,
{"Content-Encoding": "zstd"})
self.assertEqual(status, 200)
self.assertEqual(self.ozgun.gelen[-1]["govde"], raw)
self.assertEqual(self.kopru.gelen, [])
def test_completed_return_ends_preparation_for_following_native_turns(self):
self.ozgun.cevap = duz(200, b'data: {"type":"response.completed"}\n\n', 'text/event-stream')
req = {"model": "ide/test", "prompt_cache_key": "return-once", "input": []}