perf: added event polling instead of looping #564
Merged
+364
−33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request introduces a robust event-driven notification and timeout system for handling human approvals and clarifications in the orchestration workflow. The changes replace previous polling mechanisms with asyncio events, add timeout handling and user notifications via WebSocket, and ensure proper resource cleanup and error handling throughout the approval and clarification processes.
Event-driven approval and clarification system:
settings.py
, including methods to set pending states, wait for results with timeouts, and clean up resources. These changes replace prior polling approaches and improve reliability and scalability.router.py
to use the new event-driven methods for setting approval and clarification results, ensuring consistent state management. [1] [2]Timeout notification and error handling:
TimeoutNotification
dataclass and corresponding WebSocket message type for notifying users when approval or clarification requests time out. This ensures users are informed of delays and can retry actions as needed. [1] [2]proxy_agent.py
andhuman_approval_manager.py
to use event-driven waiting with timeout, cancellation, and error handling. On timeout, users receive a notification and resources are cleaned up to prevent leaks. [1] [2]Logging and diagnostics:
These improvements make the approval and clarification flows more reliable, responsive, and user-friendly, and lay a foundation for future scalability and maintainability.
Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information