fix(codex-link): summarize with a subscription model, reject tiny summaries, describe added models

Model switch lost the conversation: on 10 Oct a 1 MB thread was compacted by the
newly selected small model into 2201 characters. The compaction summary for a bridge
model is now written by a subscription model (ozet_kopru.ozet_modeli, default
gpt-6.1-sol); if that request is refused before it starts, the target model is used
as before. A summary far shorter than the conversation warrants is not accepted:
Codex gets response.failed and keeps the history.

The line under each added model no longer repeats its name. Teams show their
members, fallback chains their order, single models their provider and the traits
readable from the name; the text fits one phone row (30 characters).

Also normalizes tool call ids in the streamed response so Codex persists ids the
subscription backend accepts (fc_ -> ctc_), and bumps the bridge protocol to 6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yilsemandClaude Opus 5.5 committed 2026-10-10 15:31:53 +03:00
1 parent ce49d6d1cc
commit adf73eeedd
7 files changed
+248 -13

No files matched your search

+32 -1
View File
@@ -45,6 +45,20 @@ OKUNAMADI_NOTU = ("(Kopru notu: Bu noktadan onceki konusma, onceki modelin sifre
"aktarilamadi. Onceki kararlari bilmiyorsan uydurma; kullaniciya sor.)")
KISA_MESAJI = ("AstraBridge: Sohbet ozeti cok kisa cikti (%d karakter, en az %d bekleniyordu) ve gecmisin yerine "
"konmadi; mesajlariniz sohbette duruyor. Tekrar deneyin ya da daha guclu bir model secin.")
def en_az_karakter(girdi_bayt, ayar=None):
"""Bu buyuklukteki bir konusmanin ozeti en az kac karakter olmali.
Olcu: 10 Ekim 2026'da 1.018.151 baytlik sohbet 2201 karaktere indi ve hafiza kayboldu.
Kucuk sohbetlerde esik kuculur ki kisa ama dogru ozetler reddedilmesin."""
ayar = ayar or {}
tavan = int(ayar.get("en_az_tavan", 4000))
oran = max(1, int(ayar.get("en_az_oran", 250))) # her 250 bayt girdi icin 1 karakter
return max(0, min(tavan, int(girdi_bayt) // oran))
def tetik_mi(req):
"""Istek bir sikistirma istegi mi (girdinin son ogesi compaction_trigger)?"""
ogeler = req.get("input")
@@ -129,9 +143,11 @@ class OzetAkisi:
"""Ozet isteginin SSE yanitini Codex'in bekledigi tek 'compaction' ogesine cevirir.
ic: once calisan cevirici (SseRewriter). Metin gelmezse compaction ogesi uretmez (Codex hatayi gosterir)."""
def __init__(self, ic=None, tohum=""):
def __init__(self, ic=None, tohum="", en_az=0):
self.ic = ic
self.tohum = tohum
self.en_az = en_az # bundan kisa ozet kabul edilmez (bkz. en_az_karakter)
self.kisa = False
self.buf = b""
self.parcalar = {} # item_id -> delta metni
self.bitenler = [] # tamamlanan mesaj metinleri
@@ -171,6 +187,13 @@ class OzetAkisi:
self.bitti = True
if not self.metin:
return _olay(d) # ozet yok: Codex "0 compaction ogesi" hatasini gosterir
if len(self.metin) < self.en_az:
# Anormal kisa ozet gecmisin yerine konmaz: Codex hatayi gosterir, sohbet oldugu gibi kalir.
self.kisa = True
yanit = dict(d.get("response") or {})
yanit["status"] = "failed"; yanit["output"] = []
yanit["error"] = {"code": "astrabridge_ozet_kisa", "message": KISA_MESAJI % (len(self.metin), self.en_az)}
return _olay({"type": "response.failed", "response": yanit})
oge = ozet_ogesi(self.metin, self.tohum)
yanit = dict(d.get("response") or {})
yanit["output"] = [oge]
@@ -180,6 +203,14 @@ class OzetAkisi:
return _olay(d)
return b""
def sonuc_notu(self):
"""Gunluk satiri icin sonuc (icerik yazilmaz)."""
if not self.metin:
return "ozet URETILEMEDI"
if self.kisa:
return f"ozet REDDEDILDI: {len(self.metin)} karakter, en az {self.en_az} bekleniyordu; gecmis korunuyor"
return f"ozet uretildi, {len(self.metin)} karakter"
def feed(self, chunk):
if self.ic:
chunk = self.ic.feed(chunk)