[FEATURE] Provide officially supported method for force stopping agent execution
Problem Statement
The current approach to force stop an agent requires setting interrupt state on context and flag to true. This is not an officially supported pattern and may break with future SDK updates. We need a stable, documented method for force stopping agent execution.
Proposed Solution
Provide a first-class API for force stopping agents, such as:
- agent.force_stop() method
- context.request_stop() method available in hooks
- A dedicated event type for stop requests
The mechanism should cleanly terminate the agent loop and allow for proper cleanup.
Use Case
Force stop is needed for:
- Timeout handling in production workloads
- User-initiated cancellation of long-running agents
- Error recovery scenarios where continuing execution is unsafe
- Resource management when agents exceed limits
Alternatives Solutions
Our current workaround manipulates internal state, which is fragile and undocumented.
Additional Context
No response
Hi @nagabharann, thanks for reaching out!
We recently added a cancellation feature as a part of this pull request: https://github.com/strands-agents/sdk-python/pull/1772
There are some docs here as well covering this feature: https://strandsagents.com/docs/user-guide/concepts/agents/agent-loop/#cancellation
Does this cover your use case? If not, can you help me understand what features are missing? Thanks!
This issue has been automatically closed as it was marked for auto-closure by the team and no additional responses was received within 7 days.