Skip to content

flowgentic.agent

agent

Framework-neutral agent components executed through AsyncFlow.

This module provides the inverse of an AsyncFlow-backed agent tool: it makes an agent-framework component callable as an AsyncFlow task. Applications can keep their orchestration and scientific state in ordinary Python and AsyncFlow while using LangGraph, CrewAI, Academy, or another framework only inside agents.

Each call of a bound agent is an OpenTelemetry invoke_agent span in the caller's process, with the AsyncFlow task that ran it as a child.

Classes:

Name Description
ModelDumpable

Structured object exposing the Pydantic-compatible dump operation.

AgentComponent

Minimal interface implemented by an agent-framework component.

AgentTask

An addressable agent component placed on an AsyncFlow backend.

Functions:

Name Description
bind_agent

Bind one framework-specific agent component to an AsyncFlow task.

ModelDumpable

Bases: Protocol

Structured object exposing the Pydantic-compatible dump operation.

Methods:

Name Description
model_dump

Return the structured decision as a plain mapping.

model_dump

model_dump() -> dict[str, Any]

Return the structured decision as a plain mapping.

AgentComponent

Bases: Protocol

Minimal interface implemented by an agent-framework component.

Methods:

Name Description
ainvoke

Return a structured decision for the supplied bounded context.

ainvoke async

ainvoke(context: Mapping[str, Any]) -> AgentResponse

Return a structured decision for the supplied bounded context.

AgentTask dataclass

AgentTask(
	identity: str,
	framework: str,
	backend: str,
	_submit: AgentSubmitter,
)

An addressable agent component placed on an AsyncFlow backend.

Methods:

Name Description
ainvoke

Invoke the agent through AsyncFlow and return decision plus metadata.

ainvoke async

ainvoke(context: Mapping[str, Any]) -> dict[str, Any]

Invoke the agent through AsyncFlow and return decision plus metadata.

bind_agent

bind_agent(
	flow: WorkflowEngine,
	component: AgentComponent,
	*,
	identity: str,
	framework: str,
	backend: str = "ai",
) -> AgentTask

Bind one framework-specific agent component to an AsyncFlow task.

The surrounding application sees a stable, framework-neutral AgentTask. The component remains free to use a LangGraph graph, CrewAI crew, Academy actor, direct LLM call, or scripted rehearsal implementation internally.