-
Notifications
You must be signed in to change notification settings - Fork 593
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
base: main
Are you sure you want to change the base?
Changes from all commits
1ca3655
abd2881
d3d6226
aba9401
5b52895
43344b9
82ff105
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ repl_state | |
| .kiro | ||
| uv.lock | ||
| .audio_cache | ||
| CLAUDE.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,18 @@ | ||
| """SteeringAction types for steering evaluation results. | ||
|
|
||
| Defines structured outcomes from steering handlers that determine how tool calls | ||
| Defines structured outcomes from steering handlers that determine how agent actions | ||
| should be handled. SteeringActions enable modular prompting by providing just-in-time | ||
| feedback rather than front-loading all instructions in monolithic prompts. | ||
|
|
||
| Flow: | ||
| SteeringHandler.steer() → SteeringAction → BeforeToolCallEvent handling | ||
| ↓ ↓ ↓ | ||
| Evaluate context Action type Tool execution modified | ||
| SteeringHandler.steer_*() → SteeringAction → Event handling | ||
| ↓ ↓ ↓ | ||
| Evaluate context Action type Execution modified | ||
|
|
||
| SteeringAction types: | ||
| Proceed: Tool executes immediately (no intervention needed) | ||
| Guide: Tool cancelled, agent receives contextual feedback to explore alternatives | ||
| Interrupt: Tool execution paused for human input via interrupt system | ||
| Proceed: Allow execution to continue without intervention | ||
| Guide: Provide contextual guidance to redirect the agent | ||
| Interrupt: Pause execution for human input | ||
|
|
||
| Extensibility: | ||
| New action types can be added to the union. Always handle the default | ||
|
|
@@ -25,9 +25,9 @@ | |
|
|
||
|
|
||
| class Proceed(BaseModel): | ||
| """Allow tool to execute immediately without intervention. | ||
| """Allow execution to continue without intervention. | ||
|
|
||
| The tool call proceeds as planned. The reason provides context | ||
| The action proceeds as planned. The reason provides context | ||
| for logging and debugging purposes. | ||
| """ | ||
|
|
||
|
|
@@ -36,30 +36,50 @@ class Proceed(BaseModel): | |
|
|
||
|
|
||
| class Guide(BaseModel): | ||
| """Cancel tool and provide contextual feedback for agent to explore alternatives. | ||
| """Provide contextual guidance to redirect the agent. | ||
|
|
||
| The tool call is cancelled and the agent receives the reason as contextual | ||
| feedback to help them consider alternative approaches while maintaining | ||
| adaptive reasoning capabilities. | ||
| The agent receives the reason as contextual feedback to help guide | ||
| its behavior. The specific handling depends on the steering context | ||
| (e.g., tool call vs. model response). | ||
| """ | ||
|
|
||
| type: Literal["guide"] = "guide" | ||
| reason: str | ||
|
|
||
|
|
||
| class Interrupt(BaseModel): | ||
| """Pause tool execution for human input via interrupt system. | ||
| """Pause execution for human input via interrupt system. | ||
|
|
||
| The tool call is paused and human input is requested through Strands' | ||
| Execution is paused and human input is requested through Strands' | ||
| interrupt system. The human can approve or deny the operation, and their | ||
| decision determines whether the tool executes or is cancelled. | ||
| decision determines whether execution continues or is cancelled. | ||
| """ | ||
|
|
||
| type: Literal["interrupt"] = "interrupt" | ||
| reason: str | ||
|
|
||
|
|
||
| # SteeringAction union - extensible for future action types | ||
| # Context-specific steering action types | ||
| ToolSteeringAction = Annotated[Proceed | Guide | Interrupt, Field(discriminator="type")] | ||
| """Steering actions valid for tool steering (steer_before_tool). | ||
|
|
||
| - Proceed: Allow tool execution to continue | ||
| - Guide: Cancel tool and provide feedback for alternative approaches | ||
| - Interrupt: Pause for human input before tool execution | ||
| """ | ||
|
|
||
| ModelSteeringAction = Annotated[Proceed | Guide, Field(discriminator="type")] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is interrupt excluded because we cannot? Is that something that you'll want next?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If so, I wonder if we should just expose Interrupt now, throw in the case for now, and unlock the ability to do so later
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No Interrupt until #1165 since we can only interrupt on tool steering. I chose to break symmetry in favor of "compile" time checks rather than a runtime exception or no op. I think there is uncertainty here. |
||
| """Steering actions valid for model steering (steer_after_model). | ||
|
|
||
| - Proceed: Accept model response without modification | ||
| - Guide: Discard model response and retry with guidance | ||
| """ | ||
|
|
||
| # Generic SteeringAction union for backward compatibility | ||
| # IMPORTANT: Always handle the default case when pattern matching | ||
| # to maintain backward compatibility as new action types are added | ||
| SteeringAction = Annotated[Proceed | Guide | Interrupt, Field(discriminator="type")] | ||
| """Generic steering action type for backward compatibility. | ||
|
|
||
| Use ToolSteeringAction or ModelSteeringAction for type-safe context-specific steering. | ||
| """ | ||
Uh oh!
There was an error while loading. Please reload this page.