Skip to content

[PORT] Port PendingToolExecution in place of interrupt tool context #3719

Description

@liramon2

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

  • The change is complete in the source SDK, and every related artifact is listed above (source, tests, and docs, if the change has any).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-hilHuman in the loop and suspend/resumechoreMaintenance tasks, dependency updates, CI changes, refactoring with no user-facing impactportpythonPull requests that update python code

    Type

    Fields

    Language

    Python

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions