fix: harden responses streaming and tool-call fallback

Ensure /v1/responses streams always terminate with response.completed and normalize Lingma tool_code fallbacks into structured tool calls, including single-argument forms.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
mmc
2026-04-20 19:24:02 +08:00
parent 866a212573
commit d0df089282
6 changed files with 927 additions and 18 deletions

View File

@@ -187,6 +187,17 @@ class ConfigParsingTests(unittest.TestCase):
settings_without_accounts = load_settings()
self.assertEqual(settings_without_accounts.instance_count, 1)
def test_load_settings_parses_tool_allowlist_csv(self) -> None:
with patch.dict(os.environ, {"TOOL_ALLOWLIST": " lookup , write_file ,,search_docs "}, clear=True):
settings = load_settings()
self.assertEqual(settings.tool_allowlist, ["lookup", "write_file", "search_docs"])
def test_load_settings_empty_tool_allowlist(self) -> None:
with patch.dict(os.environ, {"TOOL_ALLOWLIST": " , , "}, clear=True):
settings = load_settings()
self.assertEqual(settings.tool_allowlist, [])
if __name__ == "__main__":