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.
This pull request includes significant refactoring and improvements to the event handling system in the
controlflow
package. The changes aim to simplify the event model, improve consistency, and enhance the functionality of event handlers.A primary, tangible benefit of this PR is enhanced PrintHandler output by using the new public event hooks, e.g.:
printhandler.mp4
The following settings/env vars are respected:
Refactoring and Simplification:
ToolCallEvent
andToolResultEvent
classes, replacing them withAgentToolCall
andToolResult
respectively insrc/controlflow/events/events.py
. [1] [2] [3] [4] [5]all_related_events
method inAgentMessage
andAgentMessageDelta
classes. [1] [2] [3]Enhancements to Event Handling:
CallbackHandler
andAsyncCallbackHandler
classes to handle events by calling a callback function.QueueHandler
andAsyncQueueHandler
classes to queue events, with optional filtering capabilities.Code Consistency:
__repr__
method in theEvent
class for better readability.Additional Changes:
AgentMessage
andAgentMessageDelta
to convert messages to tool calls and content events, enhancing the modularity of event handling. [1] [2]message_compiler
to use the new event classes and methods.These changes collectively improve the maintainability and functionality of the event handling system in the
controlflow
package.