Repository navigation
Description
Summary
StrandsPlugin installs StrandsFailureConverter only when the Client's payload converter is the
SDK default. Any other payload converter, including pydantic_data_converter, is returned
unchanged with its own failure converter. An Activity tool's InterruptException then crosses the
Activity boundary as an ordinary, retryable ApplicationError of type InterruptException, so
TemporalActivityTool never rebuilds the interrupt. The plugin does not warn.
The same converter also leaves MaxTokensReachedException, ContextWindowOverflowException,
StructuredOutputException and SessionException retryable, though the plugin sends them as
non-retryable (seen in the same temporalio.contrib.strands 1.33.0 runs as the Worker runs below).
Versions
temporalio-strands-agents from main at 5e91c26 (same plugin source as 0.1.0) and from #155 at
dc2f54c; main at 1e8ae93 has the same _data_converter. temporalio 1.34.0, strands-agents
1.56.0, Python 3.13.
Reproduction
No server needed:
import sys
from strands.interrupt import Interrupt, InterruptException
from temporalio.api.failure.v1 import Failure
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.strands_agents import StrandsPlugin
for given in (None, pydantic_data_converter):
config = {"data_converter": given} if given else {}
active = StrandsPlugin(models={}).configure_client(config)["data_converter"]
failure = Failure()
active.failure_converter.to_failure(
InterruptException(Interrupt(id="i1", name="approval", reason="ok?")),
active.payload_converter,
failure,
)
info = failure.application_failure_info
print(
"given:", "pydantic_data_converter" if given else None,
"| active:", type(active.failure_converter).__name__,
"| type:", info.type,
"| non_retryable:", info.non_retryable,
)
sys.exit(0 if info.type == "StrandsInterrupt" else 1)Output, the same on both revisions (exit 1):
given: None | active: StrandsFailureConverter | type: StrandsInterrupt | non_retryable: True
given: pydantic_data_converter | active: DefaultFailureConverter | type: InterruptException | non_retryable: False
The first line is the control: with no caller converter, the plugin installs its own failure
converter.
On a real Worker, with Client.connect(..., data_converter=pydantic_data_converter, plugins=[StrandsPlugin(...)]) and an activity_as_tool Activity that raises InterruptException
as the README shows, no approval request reaches the Workflow and the Activity is retried. Under the
default retry policy the run stays open. With retry_policy=RetryPolicy(maximum_attempts=3), the
model gets Error: Activity task failed as the tool result and the run completes without asking
for approval. These runs used the same callback in temporalio.contrib.strands 1.33.0.
Expected: the interrupt reaches the Workflow, as it does with no caller converter.
Impact
A caller who needs a codec has to pass a DataConverter. If it uses a Pydantic payload converter,
the codec is kept but the approval gate never asks: the run retries the Activity, or with a retry
limit, completes with the approval step skipped.
Proposed fix
Add the Strands handling to the caller's failure converter on that path too: use
StrandsFailureConverter when the caller's failure converter is the SDK default, and wrap any other
class so that its from_failure stays the caller's, since replacing it would change the errors
Workflow code reads. Raising a ValueError, as the openai_agents plugin does for a payload
converter it can't use, would break every caller that passes pydantic_data_converter.
The TypeScript plugin has the same gap with its default setup; #200 fixes it there.
Activity