fix(payments): T01 Strands Step 5c uses a fresh agent#1674
Closed
fahadfa-aws wants to merge 1 commit into
Closed
Conversation
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.
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. |
Author
|
Superseded by #1738 (consolidated PR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Tutorial 01's Strands variant reuses
budget_agentfor 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-138after the WalletHub grant was missing.Verification
interruptResponseobjects. Passing a plain string raises aTypeError."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.activatedis False and accepts strings normally.Changes
strands_payment_agent.py:227-245— build anintrospection_agentfor Step 5c instead of reusingbudget_agent. Samebudget_pluginis 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_agentand 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.