Skip to main content

Step

Step wraps a callable and turns it into a traceable, optionally validated unit of work.

Construction

from coevolved.base.step import Step

step = Step(
    fn,                        # Callable[[I], O]
    name="optional_name",      # defaults to fn.__name__
    input_schema=None,         # Optional[Pydantic model]
    output_schema=None,        # Optional[Pydantic model]
    annotations=None,          # Optional[dict]
)

Execution

Step is callable:
out = step(state)
During execution, Coevolved:
  • Validates input/output (if schemas are provided)
  • Emits step lifecycle events (start, end, error)
  • Tracks invocation context (run ID, step ID, invocation ID, group hash)

Key attributes

  • name: human-readable step name
  • step_id: stable hash of function source + metadata (useful for grouping)
  • annotations: metadata such as kind="llm"|"tool"|"agent"

step decorator

Use the step(...) decorator to create Steps with metadata more ergonomically.
from pydantic import BaseModel
from coevolved.base.step import step

class In(BaseModel):
    x: int

@step(name="inc", input_schema=In)
def inc(state: In) -> dict:
    return {"y": state.x + 1}

Next steps