Files
aiturk-hermes-ide/apps/desktop/assets/codex-bridge/test_internet.py
T
yilsemandClaude Opus 5.5 c8993d58cc feat(codex-bridge): web search for added models, forgiving spoken model names
Added models had no web search: Codex's built-in one runs on OpenAI's side and
the bridge drops it from their tool list. Measured in a voice session on
11 Oct 2026: a model looked for a search tool ten times and ended the turn
with no answer. The bridge now tells added models two ready commands (ara.py:
search and read a page, standard library only, no key). Codex's own models
never see the note: their requests do not reach the bridge.

Spoken model names: a half-spoken word matches the start of a name part
("think" -> thinking, "obli" -> obliterated), and when one candidate is the
others minus extra words, the one without the unsaid suffix is picked
("Qwen 3.8 Obliterated" -> not the ":thinking" one).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 07:25:30 +03:00

68 lines
3.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
import tempfile
import unittest
import ara
import internet
SAYFA = '''
<div class="result results_links results_links_deep web-result ">
<h2 class="result__title"><a rel="nofollow" class="result__a" href="//duckduckgo.com/l/?uddg=https%3A%2F%2Fornek.com%2Fbir%3Fa%3D1&amp;rut=x">Bir <b>başlık</b></a></h2>
<a class="result__snippet" href="//x">Kısa &amp; öz <b>özet</b></a>
</div>
<div class="result results_links web-result ">
<a class="result__a" href="https://duckduckgo.com/y.js?ad=1">Reklam</a>
</div>
<div class="result results_links web-result ">
<a class="result__a" href="https://ornek.org/iki">İkinci</a>
</div>
'''
class AraTest(unittest.TestCase):
def test_results_are_parsed_and_ads_skipped(self):
self.assertEqual(ara.sonuclari_coz(SAYFA), [("Bir başlık", "https://ornek.com/bir?a=1", "Kısa & öz özet"),
("İkinci", "https://ornek.org/iki", "")])
self.assertEqual(len(ara.sonuclari_coz(SAYFA, adet=1)), 1)
def test_search_output_and_empty_result(self):
metin = ara.ara("x", indirici=lambda adres: (SAYFA, "text/html"))
self.assertIn("1. Bir başlık\n https://ornek.com/bir?a=1", metin)
self.assertIn("Sonuç bulunamadı", ara.ara("x", indirici=lambda adres: ("<html></html>", "text/html")))
def test_page_is_turned_into_text_and_cut(self):
sayfa = "<html><head><style>a{}</style><script>x()</script></head><body><nav>menü</nav><p>Bir &amp; iki</p><div>üç</div></body></html>"
self.assertEqual(ara.oku("ornek.com", indirici=lambda adres: (sayfa, "text/html")), "Bir & iki\nüç")
uzun = ara.oku("https://ornek.com", en_cok=10, indirici=lambda adres: ("<p>" + "a" * 50 + "</p>", "text/html"))
self.assertTrue(uzun.startswith("a" * 10 + "\n[... kesildi: 50"))
def test_main_reports_errors_without_raising(self):
self.assertEqual(ara.main(["oku", "http://127.0.0.1:9/yok"]), 1)
class InternetTest(unittest.TestCase):
def test_note_names_both_commands_and_is_added_once(self):
with tempfile.TemporaryDirectory() as d:
betik = os.path.join(d, "ara.py")
open(betik, "w").close()
metin = internet.talimat(None, betik, python="py.exe")
self.assertIn(f'"py.exe" "{betik}" ara "sorgu"', metin)
self.assertIn(f'"py.exe" "{betik}" oku <adres>', metin)
req = {"input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "araştır"}]}]}
self.assertTrue(internet.ekle(req, metin))
self.assertFalse(internet.ekle(req, metin))
self.assertEqual(req["input"][0]["role"], "developer")
self.assertEqual(len(req["input"]), 2)
self.assertIsNone(internet.talimat({"enabled": False}, betik))
self.assertIsNone(internet.talimat(None, os.path.join(d, "ara.py"))) # betik yoksa not eklenmez
def test_windowless_python_is_swapped_for_the_console_one(self):
with tempfile.TemporaryDirectory() as d:
open(os.path.join(d, "python.exe"), "w").close()
self.assertEqual(internet.python_yolu(os.path.join(d, "pythonw.exe")), os.path.join(d, "python.exe"))
self.assertEqual(internet.python_yolu(os.path.join("yok", "pythonw.exe")), os.path.join("yok", "pythonw.exe"))
if __name__ == "__main__":
unittest.main()