Skip to content

fix: raise specific error for interrupt responses without active interrupt state#1885

Open
giulio-leone wants to merge 1 commit intostrands-agents:mainfrom
giulio-leone:fix/interrupt-response-validation-error
Open

fix: raise specific error for interrupt responses without active interrupt state#1885
giulio-leone wants to merge 1 commit intostrands-agents:mainfrom
giulio-leone:fix/interrupt-response-validation-error

Conversation

@giulio-leone
Copy link
Contributor

Summary

Fixes #1644

When interrupt responses (list[InterruptResponseContent]) are passed to an agent that is not in interrupt state (e.g. fresh instance, serverless handler without session management), _convert_prompt_to_messages now raises a clear ValueError instead of the generic:

ValueError: Input prompt must be of type: `str | list[Contentblock] | Messages | None`.

Root Cause

_convert_prompt_to_messages validates the input prompt but did not recognize interrupt response payloads ([{"interruptResponse": {...}}]) as a valid input type. These dicts don't match Message (no role/content keys) or ContentBlock (no text/image/etc. keys), so the method fell through to messages is None and raised a generic ValueError.

When the interrupt state IS activated, this code path is never reached because line 926-927 returns [] early. The bug only surfaces when the agent is not in interrupt state — typically in stateless/serverless setups where the agent is reconstructed per request.

Fix

Added a detection branch in _convert_prompt_to_messages that recognizes interruptResponse payloads and raises a specific, actionable error message guiding users to preserve the agent instance or use session management.

Test

Added test_agent__call__resume_interrupt_not_activated — verifies that passing interrupt responses to a non-interrupt agent raises the new specific ValueError instead of the generic one.

All 114 agent tests + 16 interrupt tests pass.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…rrupt state

When interrupt responses (list of interruptResponse dicts) are passed to
an agent that is not in interrupt state, _convert_prompt_to_messages now
raises a clear ValueError explaining the cause instead of the generic
'Input prompt must be of type: str | list[Contentblock] | Messages | None'
error.

This helps users diagnose the issue when using stateless setups where the
interrupt state is not preserved across requests (e.g. serverless), guiding
them to use session management or preserve the agent instance.

Closes strands-agents#1644
@giulio-leone giulio-leone force-pushed the fix/interrupt-response-validation-error branch from 3fb4ad2 to 07e1b7a Compare March 15, 2026 16:12
@github-actions github-actions bot added size/xs and removed size/xs labels Mar 15, 2026
@giulio-leone
Copy link
Contributor Author

Friendly ping — raises a specific error when an interrupt response is received but no active interrupt state exists, replacing a confusing generic error.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ValueError raised when resuming execution with interruptResponse: _convert_prompt_to_messages validation fails

1 participant