-
Notifications
You must be signed in to change notification settings - Fork 611
feat(steering): allow steering on AfterModelCallEvents #1429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(steering): allow steering on AfterModelCallEvents #1429
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
We are failing with "Potential API changes detected (review if actually breaking)" this is true, but we are in experimental so this should not strictly be a blocker. |
🎯 Review - Steering on AfterModelCallEventsThis is an excellent feature that addresses a key limitation in the steering system! The ability to steer after model responses opens up many valuable use cases like quality checks, required tool enforcement, and conversation flow control. What I Really Like ✅
Addressing the CI Failure
|
82ff105 to
aa67698
Compare
Description
Expands the steering system to support model response steering via
AfterModelCallEvent, addressing a key limitation where steering could only influence tool selection and execution.Previously, steering handlers could only intercept tool calls via
steer()(nowsteer_before_tool()). This meant there was no way to:This PR adds
steer_after_model()which is called after each model response, enabling handlers to:A practical example from the issue: ensuring an agent sends a required confirmation message or uses a mandatory tool before completing a workflow. The new
steer_after_model()hook interceptsend_turnresponses and can force retries with guidance until requirements are met.API Changes
New method on
SteeringHandler:New type aliases for type safety:
ToolSteeringAction = Proceed | Guide | Interrupt- forsteer_before_tool()ModelSteeringAction = Proceed | Guide- forsteer_after_model()Renamed with deprecation:
steer()→steer_before_tool()(old method emitsDeprecationWarning)Example: Enforcing Tool Usage
Related Issues
This PR move the needle for #1386.
Type of Change
New feature
Testing
Reorganized
test_tool_steering.pyfor existing tool steering testsUpdated unit tests in
test_handler.pyfor new method signaturesI ran
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.