(self)
| 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(): |
nothing calls this directly
no test coverage detected