Repository navigation
fix(strands_agents): install the failure converter with a non-default payload converter - #392
Conversation
… payload converter StrandsPlugin returned a data converter with a non-default payload converter unchanged, so Activity-tool interrupts and the non-retryable Strands exceptions crossed the Activity boundary as ordinary retryable ApplicationErrors. Keep the caller's payload converter but always install the Strands failure converter.
|
Please fix the lint failure @pcbeingused333 |
brianstrauch
left a comment
There was a problem hiding this comment.
The interrupt fix introduces a custom failure-decoding regression that can break workflow replay.
| else: | ||
| # Keep the caller's payload converter (for example ``pydantic_data_converter``), | ||
| # but still install the failure converter: Activity-tool interrupts and the | ||
| # non-retryable Strands exceptions depend on it. | ||
| payload_converter_class = converter.payload_converter_class |
There was a problem hiding this comment.
[P1] Preserve custom failure decoding for non-default payload converters
When a caller supplies both a non-default payload converter and a custom failure converter, this branch now falls through to code that discards the caller's from_failure. For example, combining the existing DomainFailureConverter with pydantic_data_converter previously decoded recorded failures as DomainError, but now produces ApplicationError, for both client and replayer. This changes exception-handling branches during replay and can break existing workflows. Add Strands-specific failure handling without replacing custom decoding on this previously preserved path.
…efault payload converter With a non-default payload converter the caller's failure converter was always preserved. The previous commit replaced it, which changes how recorded failures decode (client and replayer). Add the Strands exception handling on top of the caller's class instead, so its from_failure keeps running.
A failure converter that does not subclass DefaultFailureConverter cannot take the Strands handling by subclassing. Return it as supplied, as before, so its from_failure keeps decoding recorded failures.
|
Good catch, thanks. Fixed in 50d2ad0 and d6a8a63: on the non-default payload converter path the caller's failure converter is no longer replaced. A This reply was drafted with the help of an AI assistant (Claude Code). |
Fixes #299
Root cause
_data_converterin the Strands plugin returned the caller'sDataConverterunchanged whenever its payload converter was notDefaultPayloadConverter(for examplepydantic_data_converter).StrandsFailureConverterwas therefore never installed. An Activity tool'sInterruptExceptioncrossed the Activity boundary as a retryableApplicationError, soTemporalActivityToolcould not rebuild the interrupt.MaxTokensReachedException,ContextWindowOverflowException,StructuredOutputExceptionandSessionExceptionalso stayed retryable.Fix
Keep the caller's payload converter and add the Strands exception handling on top of the caller's failure converter: a
DefaultFailureConvertersubclass gets the Strandsto_failuremixed in, so its ownfrom_failurestill decodes recorded failures (client and replayer); the plain default converters map to the Strands ones as before (encoded attributes stay encoded); a converter that does not subclassDefaultFailureConverteris kept unchanged. README note updated.Tests
test_custom_payload_converter_gets_strands_failure_converter(client and replayer) feedspydantic_data_converterthrough the plugin and checks the payload converter is kept, the failure converter isStrandsFailureConverter, and anInterruptExceptionbecomes a non-retryableStrandsInterruptfailure. It fails before the change and passes after.test_custom_payload_converter_is_preservednow checks the payload converter class and codec instead of object identity.test_custom_payload_converter_keeps_caller_failure_decodingandtest_minimal_failure_converter_with_custom_payload_converter_is_kept(client and replayer) cover the caller's decoding on this path.tests/test_plugin.py: 18 passed.This change was prepared with the help of an AI assistant (Claude Code), and the author is responsible for the change.
🤖 Generated with Claude Code