Skip to content

ant_ai.steps.protocol

Step

Bases: Protocol

Minimal interface every executor step must satisfy.

Implementations should be BaseModel subclasses so they can be declared as Pydantic fields on the executor and benefit from validation, serialization, and introspection for free.

Source code in src/ant_ai/steps/protocol.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Step(Protocol):
    """Minimal interface every executor step must satisfy.

    Implementations should be `BaseModel` subclasses so they can be declared
    as Pydantic fields on the executor and benefit from validation,
    serialization, and introspection for free.
    """

    @property
    def name(self) -> str:
        """Human-readable identifier used in logs and hook dispatch."""
        ...

    def run(
        self,
        state: State,
        ctx: InvocationContext | None,
    ) -> AsyncIterator[Event | StepResult]:
        """Stream events as they happen, then yield the final `StepResult`.

        Args:
            state: Current agent state, including the conversation history.
            ctx: Invocation context, or None if not available.

        Returns:
            An async iterator of `Event` items followed by a single `StepResult`.
        """
        ...

name property

name: str

Human-readable identifier used in logs and hook dispatch.

run

run(
    state: State, ctx: InvocationContext | None
) -> AsyncIterator[Event | StepResult]

Stream events as they happen, then yield the final StepResult.

Parameters:

Name Type Description Default
state State

Current agent state, including the conversation history.

required
ctx InvocationContext | None

Invocation context, or None if not available.

required

Returns:

Type Description
AsyncIterator[Event | StepResult]

An async iterator of Event items followed by a single StepResult.

Source code in src/ant_ai/steps/protocol.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def run(
    self,
    state: State,
    ctx: InvocationContext | None,
) -> AsyncIterator[Event | StepResult]:
    """Stream events as they happen, then yield the final `StepResult`.

    Args:
        state: Current agent state, including the conversation history.
        ctx: Invocation context, or None if not available.

    Returns:
        An async iterator of `Event` items followed by a single `StepResult`.
    """
    ...