fix(codex-bridge): estimate Claude requests more strictly; report an unexplained 400 on a near-full request
A 607 KB Codex request was estimated at 189776 tokens (window 200000), sent untrimmed and rejected by Claude; the gateway only said "upstream 400", so Codex saw a dropped stream. Claude targets now use 2.6 bytes/token, and that bare 400 on a request filling most of the window becomes context_length_exceeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
959f5f1459
commit
d9a7661281
3 files changed
+46
-7
No files matched your search
@@ -225,5 +225,20 @@ class Images(unittest.TestCase):
|
||||
self.assertEqual(resim_context.resimleri_sadelestir(big, tut_bayt=500, gorsel=True)[0], 2) # over budget
|
||||
|
||||
|
||||
|
||||
class ClaudeOrani(unittest.TestCase):
|
||||
def test_claude_targets_are_estimated_more_strictly_than_others(self):
|
||||
import pencere as p
|
||||
req = {"input": [{"type": "function_call_output", "call_id": "c", "output": "x" * 600_000},
|
||||
{"type": "message", "role": "user", "content": "son"}]}
|
||||
self.assertEqual(p.oran_sec("9router-cc-claude-opus-5-5"), p.CLAUDE_BAYT_BOLU_TOKEN)
|
||||
self.assertEqual(p.oran_sec("9router-ag-gemini-3.8-flash-low"), p.BAYT_BOLU_TOKEN)
|
||||
self.assertEqual(p.sigdir({"input": [dict(i) for i in req["input"]]}, 200_000)[0], 0) # 187500: fits
|
||||
trimmed, fits, estimate = p.sigdir(req, 200_000, p.oran_sec("cc-claude-opus")) # 230769: trimmed
|
||||
self.assertEqual((trimmed, fits), (1, True))
|
||||
self.assertLess(estimate, 194_000)
|
||||
self.assertTrue(p.kapali_hata_mi("upstream 400"))
|
||||
self.assertFalse(p.kapali_hata_mi("upstream 400: invalid tool schema"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user