返回 ViMax
test_crash_regressions.py
根目录 / tests / test_crash_regressions.py
1 """Regression tests for small crash bugs in helper stringification paths."""
2
3 import unittest
4
5 from agent_runtime.context_compactor import ContextCompactor
6 from interfaces.shot_description import ShotBriefDescription
7
8
9 class TestContextCompactorToolCallPreview(unittest.TestCase):
10 def test_fallback_summary_handles_tool_call_messages(self):
11 compactor = ContextCompactor(None, token_threshold=200, buffer_tokens=0, preserve_last_n=2, summary_max_chars=2000)
12 messages = [
13 {"role": "user", "content": "list the files"},
14 {"role": "assistant", "content": "", "tool_calls": [{"id": "c1", "function": {"name": "list_files", "arguments": "{}"}}]},
15 ]
16 summary = compactor._fallback_summary(messages, [], "", "test")
17 self.assertIn("[tool calls]", summary)
18 self.assertIn("list_files", summary)
19
20
21 class TestShotBriefDescriptionStr(unittest.TestCase):
22 def test_str_uses_existing_fields(self):
23 shot = ShotBriefDescription(
24 idx=0,
25 is_last=False,
26 cam_idx=1,
27 visual_desc="<Alice> waves at the camera.",
28 audio_desc="[Speaker] Alice (Happy): Hello!",
29 )
30 text = str(shot)
31 self.assertIn("Shot 0", text)
32 self.assertIn("Camera Index: 1", text)
33 self.assertIn("<Alice> waves at the camera.", text)
34 self.assertIn("[Speaker] Alice (Happy): Hello!", text)
35
36
37 if __name__ == "__main__":
38 unittest.main()
39
39 lines PYTHON