MCPcopy
hub / github.com/Aider-AI/aider / test_token_limit_error_handling

Method test_token_limit_error_handling

tests/basic/test_coder.py:1172–1193  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1170 self.assertEqual(coder.cur_messages[-1]["role"], "assistant")
1171
1172 def test_token_limit_error_handling(self):
1173 with GitTemporaryDirectory():
1174 io = InputOutput(yes=True)
1175 coder = Coder.create(self.GPT35, "diff", io=io)
1176
1177 # Simulate token limit error
1178 def mock_send(*args, **kwargs):
1179 coder.partial_response_content = "Partial response"
1180 coder.partial_response_function_call = dict()
1181 raise FinishReasonLength()
1182
1183 coder.send = mock_send
1184
1185 # Initial valid state
1186 sanity_check_messages(coder.cur_messages)
1187
1188 # Process message that hits token limit
1189 list(coder.send_message("Long message"))
1190
1191 # Verify messages are still in valid state
1192 sanity_check_messages(coder.cur_messages)
1193 self.assertEqual(coder.cur_messages[-1]["role"], "assistant")
1194
1195 def test_message_sanity_after_partial_response(self):
1196 with GitTemporaryDirectory():

Callers

nothing calls this directly

Calls 5

InputOutputClass · 0.90
sanity_check_messagesFunction · 0.90
createMethod · 0.80
send_messageMethod · 0.80

Tested by

no test coverage detected