[PORT] Port PendingToolExecution in place of interrupt tool context
Source SDK
strands-ts
Target SDK
strands-py
Related Files
strands-ts/src/interrupt.ts
strands-ts/src/agent/agent.ts
strands-ts/src/__tests__/interrupt.test.ts
strands-ts/src/agent/__tests__/agent.interrupt.test.ts
Description
Tool interrupt replay state (tool_use_message and tool_results) is stored in the Python SDK as ad-hoc string keys in _InterruptState.context, a shared untyped dict. This means the pending-execution predicate is coupled to the data — you can't clear "pending" without deleting the data, and readers access it by string key with no type safety. It also diverges from TypeScript, which already has a typed PendingToolExecution struct with independent lifecycle.
A PendingToolExecution dataclass on _InterruptState (pending_tool_execution: PendingToolExecution | None) would give typed fields, independent lifecycle control (set to None to clear without touching other context), and structural parity with TypeScript's PendingToolExecution interface. The dataclass would replace tool_use_message and tool_results on _InterruptState.context, as well as has_pending_tool_execution.
Confirmation
- [x] The change is complete in the source SDK, and every related artifact is listed above (source, tests, and docs, if the change has any).
Hi! I’d like to work on this one.
My plan is to bring the TypeScript PendingToolExecution shape over to Python, move the replay state out of _InterruptState.context, and make sure interrupt state serialized by older versions still loads correctly. I’ll add coverage for the interrupt/resume and cancellation paths and update the middleware docs where needed.
Does that scope sound right?
Yeah, that scope sounds good. You are free to work on this.