Skip to content

AgentExecutionStep.__init__ receives caller_input_mode=None for A2AAgent due to elif ordering in deserialization plugin #142

@groganz

Description

@groganz

Summary

_builtins_deserialization_plugin.convert_to_wayflow checks isinstance(component, AgentSpecAgentNode) before isinstance(component, AgentSpecExtendedAgentNode). Because AgentSpecExtendedAgentNode inherits from AgentSpecAgentNode, the first branch always fires for any extended node type, passing caller_input_mode=None to AgentExecutionStep.__init__.

AgentExecutionStep.__init__ then raises a ValueError because None is not a valid CallerInputMode, which pyagentspec wraps into a TypeError via model_validator_with_error_accumulation.

Reproduction

  1. Create an agent.json with an AgentNode that contains an A2AAgent component.
  2. Call AgentSpecLoader.load_json(spec_str).
  3. The deserialization raises:
TypeError: ValueError: 'error' required in context

The root cause: the elif chain in the deserialization plugin should check isinstance(component, AgentSpecExtendedAgentNode) before isinstance(component, AgentSpecAgentNode) so that the more-specific subclass branch is reached first.

Expected behaviour

A2AAgent nodes (which produce AgentSpecExtendedAgentNode instances) should be handled by the extended-node branch of the deserialization plugin, receiving the correct caller_input_mode value instead of None.

Workaround

We monkey-patch AgentExecutionStep.__init__ at container startup to default caller_input_mode=None to CallerInputMode.ALWAYS:

_orig = AgentExecutionStep.__init__
_sig = inspect.signature(_orig)

def _patched(self, *args, **kwargs):
    bound = _sig.bind(self, *args, **kwargs)
    bound.apply_defaults()
    if bound.arguments.get("caller_input_mode") is None:
        bound.arguments["caller_input_mode"] = CallerInputMode.ALWAYS
    _orig(*bound.args, **bound.kwargs)

AgentExecutionStep.__init__ = _patched

Environment

  • wayflowcore[a2a]==26.1.1
  • Python 3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions