Skip to content

fix(payments): T01 Strands Step 5c uses a fresh agent#1674

Closed
fahadfa-aws wants to merge 1 commit into
awslabs:mainfrom
fahadfa-aws:fix/payments-t01-strands-agent-reuse-interrupt
Closed

fix(payments): T01 Strands Step 5c uses a fresh agent#1674
fahadfa-aws wants to merge 1 commit into
awslabs:mainfrom
fahadfa-aws:fix/payments-t01-strands-agent-reuse-interrupt

Conversation

@fahadfa-aws

Copy link
Copy Markdown

Issue

Tutorial 01's Strands variant reuses budget_agent for Step 5a (paid weather call) and Step 5c (plugin built-in tools). If Step 5a's ProcessPayment fails mid-call — for example because delegated signing wasn't granted via WalletHub — Strands activates the agent's interrupt state. The next call to that agent must then pass a list of `interruptResponse` objects, not a string. Step 5c passes a string, which raises:

```
TypeError: prompt_type=<class 'str'> | must resume from interrupt with list of interruptResponse's
```

Reproduced in the original test session at T01a_strands_first_run.log:137-138 after the WalletHub grant was missing.

Verification

  1. Strands docs confirm the behavior is intentional. Per strandsagents.com user guide on hooks: "When the agent is in an interrupt state, you must resume with a list of interruptResponse objects. Passing a plain string raises a TypeError."
  2. Live SDK reproduction. Built an Agent against strands-agents 1.43.0, manually activated _interrupt_state, called it with a string — got the exact same TypeError. Built a second fresh Agent — its _interrupt_state.activated is False and accepts strings normally.

Changes

strands_payment_agent.py:227-245 — build an introspection_agent for Step 5c instead of reusing budget_agent. Same budget_plugin is wired in so the plugin's introspection tools (get_payment_session, get_payment_instrument, list_payment_instruments) are still registered.

The LangGraph variant builds a new react agent per session via create_agent and isn't affected — no change there.

Code-only fix, no behavior change for users on the happy path. For users on the unhappy path (Step 5a payment fails), Step 5c now succeeds instead of crashing the script before reaching Step 5d.

Step 5a calls budget_agent against a paid endpoint. If ProcessPayment
fails mid-call (e.g. when delegated signing isn't fully granted), the
Strands runtime activates the agent's interrupt state. Step 5b spins up
tiny_agent (fresh) so it works, but Step 5c then reuses budget_agent
with a string prompt, which the activated interrupt state rejects:

    TypeError: prompt_type=<class 'str'> | must resume from interrupt
    with list of interruptResponse's

Strands documents this as expected behavior — once an agent is in
interrupt state it must be resumed with a list of interruptResponse
objects, never a string (see strandsagents.com user guide on hooks).

Build a fresh introspection_agent for Step 5c that uses the same
budget_plugin, so the plugin's get_payment_session,
get_payment_instrument, and list_payment_instruments tools are still
available. The new agent has a clean interrupt state and accepts string
prompts.

The LangGraph variant builds a new react agent per session and isn't
affected.
@fahadfa-aws

Copy link
Copy Markdown
Author

@mvangara10 — flagging this for your review when you have a moment. Tagged across the full set of payments-tutorial fixes I've been pushing today; happy to walk through any of them. Audit logs and test evidence are referenced in the PR description.

@fahadfa-aws

Copy link
Copy Markdown
Author

Superseded by #1738 (consolidated PR)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant