MCPcopy Create free account
hub / github.com/bcefghj/miniClaudeCode / TestConversationContext

Class TestConversationContext

tests/test_agent_loop.py:44–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43
44class TestConversationContext(unittest.TestCase):
45 def test_add_messages(self):
46 config = Config(max_context_messages=10)
47 ctx = ConversationContext(config=config)
48 ctx.add_user_message("hello")
49 ctx.add_assistant_message("hi")
50 msgs = ctx.get_api_messages()
51 self.assertEqual(len(msgs), 2)
52 self.assertEqual(msgs[0]["role"], "user")
53 self.assertEqual(msgs[1]["role"], "assistant")
54
55 def test_truncation(self):
56 config = Config(max_context_messages=5)
57 ctx = ConversationContext(config=config)
58 for i in range(10):
59 ctx.add_user_message(f"msg {i}")
60 msgs = ctx.get_api_messages()
61 self.assertLessEqual(len(msgs), 5)
62 # First message should be preserved
63 self.assertEqual(msgs[0]["content"], "msg 0")
64
65 def test_system_prompt(self):
66 ctx = ConversationContext(config=Config())
67 ctx.set_system_prompt("You are helpful.")
68 self.assertEqual(ctx.system_prompt, "You are helpful.")
69
70
71class TestSystemPrompt(unittest.TestCase):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected