feat(codex-bridge): ship the local Codex bridge with the IDE
Adds the IDE's models and combos to Codex's model list and keeps conversation summaries readable across providers, so switching models in Codex no longer drops the conversation. Standard-library Python, run on the agent venv. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRDGW1LiKcDUZYUdKBoWYW
This commit is contained in:
1 parent
df63432c92
commit
1ce5ab82cf
13 files changed
+2071
No files matched your search
@@ -0,0 +1,71 @@
|
||||
"""py -3 -m unittest test_resim_context (astra-bridge klasöründe)"""
|
||||
import unittest
|
||||
|
||||
from resim_context import resimleri_sadelestir
|
||||
|
||||
|
||||
def resim(bayt):
|
||||
return {'type': 'input_image', 'image_url': 'data:image/png;base64,' + 'A' * bayt}
|
||||
|
||||
|
||||
class Resim(unittest.TestCase):
|
||||
def test_generated_image_in_tool_output_is_replaced(self):
|
||||
req = {'input': [
|
||||
{'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': 'foto'}, resim(150_000)]},
|
||||
{'type': 'custom_tool_call_output', 'call_id': 'x',
|
||||
'output': [{'type': 'input_text', 'text': 'tamam'}, resim(3_000_000)]},
|
||||
]}
|
||||
sayi, kazanc = resimleri_sadelestir(req)
|
||||
self.assertEqual(sayi, 1) # son user mesajındaki küçük foto korunur, araç çıktısındaki resim çıkar
|
||||
self.assertGreater(kazanc, 3_000_000)
|
||||
self.assertEqual(req['input'][1]['output'][1]['type'], 'input_text')
|
||||
|
||||
def test_latest_user_photos_kept_when_small(self):
|
||||
req = {'input': [
|
||||
{'type': 'message', 'role': 'user', 'content': [resim(10_000)]},
|
||||
{'type': 'message', 'role': 'assistant', 'content': [{'type': 'output_text', 'text': 'ok'}]},
|
||||
{'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': 'yeni'}, resim(200_000)]},
|
||||
]}
|
||||
sayi, _ = resimleri_sadelestir(req)
|
||||
self.assertEqual(sayi, 1) # yalnız eski mesajdaki resim
|
||||
self.assertEqual(req['input'][2]['content'][1]['type'], 'input_image')
|
||||
self.assertEqual(req['input'][0]['content'][0]['type'], 'input_text')
|
||||
|
||||
def test_latest_user_photos_dropped_when_too_big(self):
|
||||
req = {'input': [{'type': 'message', 'role': 'user', 'content': [resim(1_200_000)]}]}
|
||||
self.assertEqual(resimleri_sadelestir(req)[0], 1)
|
||||
|
||||
def test_pdf_audio_video_in_old_messages_and_tool_output_are_replaced(self):
|
||||
pdf = {'type': 'input_file', 'filename': 'rapor.pdf', 'file_data': 'data:application/pdf;base64,' + 'P' * 500_000}
|
||||
ses = {'type': 'input_audio', 'input_audio': {'data': 'S' * 400_000, 'format': 'wav'}}
|
||||
video = {'type': 'input_video', 'video_url': 'data:video/mp4;base64,' + 'V' * 300_000}
|
||||
req = {'input': [
|
||||
{'type': 'message', 'role': 'user', 'content': [pdf, ses]},
|
||||
{'type': 'function_call_output', 'call_id': 'y', 'output': [video]},
|
||||
{'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': 'devam'}]},
|
||||
]}
|
||||
sayi, _ = resimleri_sadelestir(req)
|
||||
self.assertEqual(sayi, 3)
|
||||
self.assertIn('rapor.pdf', req['input'][0]['content'][0]['text'])
|
||||
self.assertIn('ses', req['input'][0]['content'][1]['text'])
|
||||
self.assertIn('video', req['input'][1]['output'][0]['text'])
|
||||
|
||||
def test_huge_text_tool_output_is_shortened(self):
|
||||
req = {'input': [{'type': 'function_call_output', 'call_id': 'z', 'output': 'x' * 3_000_000}]}
|
||||
sayi, kazanc = resimleri_sadelestir(req)
|
||||
self.assertEqual(sayi, 1)
|
||||
self.assertLess(len(req['input'][0]['output']), 600_000)
|
||||
self.assertIn('çıkarıldı', req['input'][0]['output'])
|
||||
|
||||
def test_unknown_huge_part_is_replaced(self):
|
||||
req = {'input': [{'type': 'custom_tool_call_output', 'call_id': 'q',
|
||||
'output': [{'type': 'yeni_bir_tur', 'veri': 'Z' * 1_500_000}]}]}
|
||||
self.assertEqual(resimleri_sadelestir(req)[0], 1)
|
||||
|
||||
def test_request_without_images_untouched(self):
|
||||
req = {'input': [{'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': 'x'}]}]}
|
||||
self.assertEqual(resimleri_sadelestir(req), (0, 0))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user