feat(omp-rpc): added error handling and history bounds to RPC client
- Added error handling callbacks (on_protocol_error, on_listener_error) and error history tracking (protocol_errors, listener_errors properties) for RPC failures. - Added max_event_history and max_stderr_chunks parameters to bound retained history in long-lived hosts, preventing unbounded memory growth. - Added assistant_text_with_thinking() and message_text_with_thinking() helper functions for backward compatibility with thinking block inclusion. - Improved error correlation for id-less parse/unknown-command failures to waiting requests and changed prompt scheduling failures to raise instead of timing out. - Refactored event dispatch to _dispatch_listeners() with exception handling and error recording for robust listener failure management.
This commit is contained in:
@@ -8,6 +8,7 @@ from omp_rpc import (
|
||||
SessionState,
|
||||
TodoReminderEvent,
|
||||
assistant_text,
|
||||
assistant_text_with_thinking,
|
||||
parse_notification,
|
||||
parse_session_state,
|
||||
)
|
||||
@@ -157,6 +158,18 @@ class ProtocolParsingTests(unittest.TestCase):
|
||||
self.assertEqual(notification.todos[0].content, "Map tools")
|
||||
self.assertEqual(notification.todos[0].status, "pending")
|
||||
|
||||
def test_assistant_text_excludes_thinking_by_default(self) -> None:
|
||||
message = {
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{"type": "thinking", "thinking": "internal"},
|
||||
{"type": "text", "text": "visible"},
|
||||
],
|
||||
}
|
||||
|
||||
self.assertEqual(assistant_text(message), "visible")
|
||||
self.assertEqual(assistant_text_with_thinking(message), "internalvisible")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user