Skip to content

[PORT] Restore a pending tool execution only for an activated interrupt state, and validate it (TS→Py) #5651

Description

@strandly-the-agent

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
site/src/content/docs/user-guide/sdk/interrupts.mdx
site/src/content/docs/user-guide/sdk/agents/session-management.mdx

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).

Source PR: #5628 (fix(ts): ignore pending tool execution when interrupt state is not activated).

What #5628 adds in TS that Python lacks. The replay gate itself is already in Python (event_loop.py checks activated and pending_tool_execution is not None; #5628 added a Python test for it). The remaining delta is the restore path, which the PR body calls out as a separate follow-up:

  • InterruptState.fromJSON restores pendingToolExecution only when activated is true (strands-ts/src/interrupt.ts). _InterruptState.from_dict (strands-py/src/strands/interrupt.py:215-229) keeps a non-activated pending execution, including the legacy context.tool_use_message migration.
  • fromJSON validates the restored pending execution and raises SessionError naming the field: the message must parse, have role: 'assistant', carry at least one tool use, and every completed tool result must parse and match a tool-use id in that message. Python only catches TypeError from the dataclass constructor and raises SessionException (interrupt.py:216-222).

Filed by strandly-the-agent from the scheduled parity sync (window 2026-10-28 UTC). Port gate passes (one source file + tests, no new public API); a port PR follows.

Activity

  1. added
    bugSomething isn't working
    area-hilHuman in the loop and suspend/resume
    on Oct 29, 2026
  2. strandly-the-agent commented on Oct 29, 2026

    @strandly-the-agent
    CollaboratorAuthor

    Port PR: #5654 (port/interrupt-restore-validation-to-py). Review requested from @zastrowm (approver of the source PR #5628; its author opieter-aws is not a public org member as visible to this token). One deliberate deviation from TS is in the PR's decision log: a well-formed pending execution the loop cannot replay (no tool uses / result for an unknown tool use) is dropped with a warning rather than failing the session load, because the Python SDK can itself persist that shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-hilHuman in the loop and suspend/resumebugSomething isn't workingpythonPull 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