Catalog PyPI
Back to packageRELEASE DETAILS

1.3.0

PyPI

afmx

Agent Flow Matrix Execution Engine — production-grade execution fabric for autonomous agents

agentsaiasyncawsbedrockcognitivecrewaidagexecutionfastapigoogle-adkgovernancehyperstatelangchainlanggraphmap
All keywords (26)
matrixmcpmodel-context-protocolmulti-agentopenaiorchestrationrhflsemantic-kerneltcfpworkflow
Published5 Apr 2026
Direct dependencies30
Transitive dependenciesNot calculated

README

Version 1.3.0 documentation

AFMX — Agent Flow Matrix Execution Engine

"Tag your agent's cognitive intent once. Get 60–90% cheaper LLM costs automatically, with a full audit trail. No rewrites. Works with LangGraph, CrewAI, OpenAI, MCP, and anything else you're already running."

CI PyPI Python License

The one-line pitch

from afmx import Node, CognitiveLayer

# Add ONE field to your existing node.
# AFMX auto-routes: cheap model for retrieval/action, premium for reasoning/planning.
node = Node(name="analyse", handler="my_agent", cognitive_layer=CognitiveLayer.REASON)
# → Claude Opus / GPT-4o selected automatically
# → cheaper layers get Haiku / gpt-4o-mini automatically
# → every node result logged to tamper-evident audit trail
# → visual heatmap shows cost + model per cell

AFMX is the production execution fabric for autonomous agents. Deterministic, fault-tolerant, built like infrastructure.

Docs


What is AFMX?

AFMX is a production-grade, deterministic execution fabric for autonomous agents. It is not an agent reasoning framework — it is the layer that controls how agents act reliably in production.

Your Agent Logic  (LangChain / LangGraph / CrewAI / OpenAI / custom Python)
        ↓
ExecutionMatrix   (DAG: nodes + edges + mode + abort policy)
        ↓
AFMXEngine
        ↓
Deterministic execution:
  retry · fallback · circuit breaker · hooks · events · audit · RBAC

Install

pip install afmx

With extras:

pip install "afmx[redis,metrics]"    # Redis store + Prometheus
pip install "afmx[full]"             # everything except framework adapters
pip install "afmx[dev]"              # development + testing toolchain

Quick Start

python3.10 -m afmx serve --reload
# API:       http://localhost:8100
# Docs:      http://localhost:8100/docs
# Dashboard: http://localhost:8100/afmx/ui
curl -s -X POST http://localhost:8100/afmx/execute \
  -H "Content-Type: application/json" \
  -d '{
    "matrix": {
      "name": "research-pipeline",
      "mode": "SEQUENTIAL",
      "nodes": [
        {"id":"analyst",  "name":"analyst",  "type":"AGENT","handler":"analyst_agent"},
        {"id":"writer",   "name":"writer",   "type":"AGENT","handler":"writer_agent"},
        {"id":"reviewer", "name":"reviewer", "type":"AGENT","handler":"reviewer_agent"}
      ],
      "edges": [
        {"from":"analyst","to":"writer"},
        {"from":"writer","to":"reviewer"}
      ]
    },
    "input": {"topic": "Production multi-agent systems in 2026"}
  }' | python3 -m json.tool

Live demo — 7 multi-agent scenarios

pip install httpx
python demo_multiagent.py --scenario all

Core Features

LayerResponsibility
ExecutionMatrixDAG of nodes and edges — the execution topology
AFMXEngineSEQUENTIAL, PARALLEL, HYBRID orchestration
NodeExecutorPer-node execution with retry, timeout, circuit breaker
RetryManagerExponential backoff + jitter + per-node circuit breaker
ToolRouterDeterministic rule-based tool selection
AgentDispatcherRoutes agents by complexity, capability, or policy
HookRegistryPRE/POST node and matrix hooks
EventBusEvery state transition emits an observable event
ConcurrencyManagerGlobal semaphore with queue timeout
StateStoreIn-memory or Redis-backed execution persistence
MatrixStoreNamed, versioned matrix definitions
CheckpointStorePer-node incremental checkpoints for resumability
AuditStoreAppend-only audit trail (JSON/CSV/NDJSON export)
RBACMiddleware5 roles × 16 permissions API key authentication
PluginRegistryDecorator-first handler registration

Fault Tolerance

from afmx import Node, RetryPolicy, CircuitBreakerPolicy, TimeoutPolicy

Node(
    name="external_api",
    handler="api_call",
    retry_policy=RetryPolicy(
        retries=5,
        backoff_seconds=1.0,
        backoff_multiplier=2.0,   # 1s → 2s → 4s → 8s → 16s
        jitter=True,
    ),
    circuit_breaker=CircuitBreakerPolicy(
        enabled=True,
        failure_threshold=5,
        recovery_timeout_seconds=60.0,
    ),
    fallback_node_id="api_fallback",
)

Framework Adapters

from afmx.adapters.langchain import LangChainAdapter
from langchain.tools import DuckDuckGoSearchRun

adapter = LangChainAdapter()
node = adapter.to_afmx_node(DuckDuckGoSearchRun(), node_id="search")

Built-in adapters: LangChain · LangGraph · CrewAI · OpenAI — all lazy-loaded.


Registering Handlers

from afmx.plugins import default_registry

@default_registry.agent("my_analyst")
async def analyst(node_input: dict, context, node) -> dict:
    return {"analysis": "...", "confidence": 0.87}

@default_registry.tool("web_search")
async def search(node_input: dict, context, node) -> dict:
    return {"results": await run_search(node_input["input"])}

Cognitive Execution Matrix

AFMX v1.2 introduces the Cognitive Execution Matrix — a 2D coordinate system that maps every node to a cognitive layer (what type of thinking) and an agent role (which domain role performs it).

                  ROLES (open, domain-specific)
                  OPS   ANALYST  QUANT  CLINICIAN  PARALEGAL
LAYERS  PERCEIVE   ■      □       □       □          □
(fixed) RETRIEVE   ■      □       ■       □          □
        REASON     □      ■       ■       ■          □
        PLAN       ■      □       □       ■          ■
        ACT        ■      □       ■       □          □
        EVALUATE   □      ■       □       ■          □
        REPORT     ■      □       □       □          □

Row axis = CognitiveLayer (fixed, universal, drives automatic LLM cost routing). Column axis = AgentRole (open string — any industry vocabulary).

from afmx import Node, NodeType, CognitiveLayer
from afmx.domains.finance import FinanceRole

# Finance domain node
node = Node(
    name            = "risk-scorer",
    type            = NodeType.AGENT,
    handler         = "risk_model",
    cognitive_layer = CognitiveLayer.REASON,    # → premium LLM auto-selected
    agent_role      = FinanceRole.RISK_MANAGER, # == "RISK_MANAGER"
)

# Healthcare domain node
from afmx.domains.healthcare import HealthcareRole
node = Node(
    name            = "diagnosis",
    type            = NodeType.AGENT,
    handler         = "diagnostic_model",
    cognitive_layer = "REASON",
    agent_role      = HealthcareRole.CLINICIAN,
)

# Custom domain — any UPPER_SNAKE_CASE string is valid
node = Node(
    cognitive_layer = "PLAN",
    agent_role      = "DISPATCHER",   # logistics domain
    ...
)

Built-in domain packs: tech · finance · healthcare · legal · manufacturing. Custom domains: register in 8 lines with DomainPack + domain_registry.

LLM cost routing (automatic)

The CognitiveModelRouter auto-selects models by cognitive layer:

PERCEIVE / RETRIEVE / ACT / REPORT  →  cheap model  (Haiku, gpt-4o-mini)
REASON   / PLAN     / EVALUATE      →  premium model (Opus, o3, gpt-4o)

Typical result: 60–90% LLM cost reduction on multi-agent workflows.


REST API

MethodEndpointDescription
POST/afmx/executeExecute matrix synchronously
POST/afmx/execute/asyncExecute and return immediately
GET/afmx/result/{id}Full result with node outputs
POST/afmx/validateValidate matrix without executing
POST/afmx/retry/{id}Retry failed execution
POST/afmx/resume/{id}Resume from checkpoint
POST/afmx/matricesSave named matrix
GET/afmx/executionsList recent executions
GET/afmx/matrix-view/{id}Cognitive Matrix view for an execution
GET/afmx/domainsList all domain packs
GET/afmx/domains/{name}Get a domain pack by name
GET/afmx/auditQuery audit log
WS/afmx/ws/stream/{id}Real-time event streaming
GET/healthHealth check
GET/metricsPrometheus metrics

Dashboard

cd afmx/dashboard
npm install && npm run build   # served at /afmx/ui
npm run dev                    # hot-reload at localhost:5173

Pages: Overview · Executions · Live Stream · Run Matrix · Saved Matrices · Plugins · Cognitive Matrix · Domain Packs · Audit Log · API Keys

Run Matrix includes cross-domain templates: cognitive (SRE) · finance · healthcare · legal.


Observability

@bus.subscribe(EventType.NODE_FAILED)
async def on_fail(event):
    await alert_team(event.execution_id, event.data["error"])

Prometheus metrics at GET /metrics. WebSocket streaming at WS /afmx/ws/stream/{id}.


Agentability Integration

AFMX integrates with Agentability — captures confidence scores, reasoning chains, token costs, and conflict detection per node execution.

AFMX_AGENTABILITY_ENABLED=true
AFMX_AGENTABILITY_DB_PATH=agentability.db
python demo_agentability.py

Docker

docker build -t afmx:latest .
docker run -p 8100:8100 --env-file .env afmx:latest

# Full stack: AFMX + Redis + Prometheus
docker-compose up -d

Testing

pytest                              # 290+ tests
pytest tests/unit/ -v               # unit only
pytest tests/integration/ -v        # integration only
pytest --cov=afmx --cov-report=html # coverage report

Documentation

DocDescription
ArchitectureLayers, data flow, AFMX vs Airflow/Temporal/LangGraph
Core ConceptsNode, Edge, Matrix, Context, Record
Quick Start5-minute setup guide
HandlersWriting and registering handlers
Matrix DesignModes, edge conditions, variable resolver
API ReferenceAll REST endpoints
AdaptersLangChain, LangGraph, CrewAI, OpenAI
HooksPRE/POST hooks
ObservabilityEventBus, Prometheus, WebSocket, Agentability
ConfigurationAll AFMX_ environment variables
TestingRunning the test suite
DeploymentDocker, Oracle Cloud, production hardening

AFMX vs alternatives (March 2026)

AFMX 1.2LangGraph 1.0OpenAI Agents SDKCrewAI
Deterministic ordering✅❌ LLM-dependent❌❌
Per-node fault tolerance✅ Retry + CB + fallback❌ Manual⚠️ Basic❌
Full audit trail✅ Append-only, exportable❌⚠️❌
Cognitive cost routing✅ 60-90% LLM cost reduction❌❌❌
Cross-industry domains✅ 5 built-in + custom❌❌❌
Execution resume✅ Checkpoint-based❌❌❌
RBAC + multi-tenancy✅❌❌❌
Cognitive Matrix UI✅❌❌❌

Mental model: AFMX = how agents act. LangGraph = how agents think. They are complementary — AFMX can execute LangGraph graphs as nodes.


Contributing

See CONTRIBUTING.md. All contributions welcome.


License

Apache 2.0 — see LICENSE.

Enterprise features (multi-tenancy, SSO/OIDC, cryptographic execution integrity, distributed workers, cost governance, AFMX Cloud) available under a separate commercial license. See ENTERPRISE.md or contact support@inteleion.com.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 43

Native requirements
30 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
fastapi
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
fastapi<1.0,>=0.111.0runtime
uvicorn
Environment
{
  "extras": "standard",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
uvicorn[standard]<1.0,>=0.29.0runtime
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pydantic<3.0,>=2.7.0runtime
pydantic-settings
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pydantic-settings<3.0,>=2.2.0runtime
python-multipart
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
python-multipart>=0.0.9runtime
python-dotenv
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
python-dotenv>=1.0.0runtime
redis
Environment
{
  "extras": "asyncio",
  "marker": "extra == \"redis\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
redis[asyncio]>=5.0.0; extra == "redis"runtime
hiredis
Environment
{
  "extras": "",
  "marker": "extra == \"redis\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
hiredis>=2.3.0; extra == "redis"runtime
prometheus-client
Environment
{
  "extras": "",
  "marker": "extra == \"metrics\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
prometheus-client>=0.20.0; extra == "metrics"runtime
httpx
Environment
{
  "extras": "",
  "marker": "extra == \"http\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
httpx>=0.27.0; extra == "http"runtime
aiohttp
Environment
{
  "extras": "",
  "marker": "extra == \"http\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
aiohttp>=3.9.0; extra == "http"runtime
langchain
Environment
{
  "extras": "",
  "marker": "extra == \"langchain\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
langchain>=0.1.0; extra == "langchain"runtime
langgraph
Environment
{
  "extras": "",
  "marker": "extra == \"langgraph\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
langgraph>=0.0.40; extra == "langgraph"runtime
crewai
Environment
{
  "extras": "",
  "marker": "extra == \"crewai\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
crewai>=0.1.0; extra == "crewai"runtime
openai
Environment
{
  "extras": "",
  "marker": "extra == \"openai\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
openai>=1.0.0; extra == "openai"runtime
mcp
Environment
{
  "extras": "",
  "marker": "extra == \"mcp\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
mcp>=1.0.0; extra == "mcp"runtime
semantic-kernel
Environment
{
  "extras": "",
  "marker": "extra == \"semantic-kernel\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
semantic-kernel>=1.0.0; extra == "semantic-kernel"runtime
google-adk
Environment
{
  "extras": "",
  "marker": "extra == \"google-adk\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
google-adk>=0.1.0; extra == "google-adk"runtime
boto3
Environment
{
  "extras": "",
  "marker": "extra == \"bedrock\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
boto3>=1.34.0; extra == "bedrock"runtime
hyperstate-sdk
Environment
{
  "extras": "",
  "marker": "extra == \"hyperstate\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
hyperstate-sdk>=0.1.0; extra == "hyperstate"runtime
map-platform
Environment
{
  "extras": "",
  "marker": "extra == \"map\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
map-platform>=1.0.0; extra == "map"runtime
httpx
Environment
{
  "extras": "",
  "marker": "extra == \"rhfl\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
httpx>=0.27.0; extra == "rhfl"runtime
langchain
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
langchain>=0.1.0; extra == "adapters"runtime
langgraph
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
langgraph>=0.0.40; extra == "adapters"runtime
crewai
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
crewai>=0.1.0; extra == "adapters"runtime
openai
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
openai>=1.0.0; extra == "adapters"runtime
mcp
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
mcp>=1.0.0; extra == "adapters"runtime
semantic-kernel
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
semantic-kernel>=1.0.0; extra == "adapters"runtime
google-adk
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
google-adk>=0.1.0; extra == "adapters"runtime
boto3
Environment
{
  "extras": "",
  "marker": "extra == \"adapters\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
boto3>=1.34.0; extra == "adapters"runtime
afmx
Environment
{
  "extras": "http,mcp,metrics,redis",
  "marker": "extra == \"full\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
afmx[http,mcp,metrics,redis]; extra == "full"runtime
orjson
Environment
{
  "extras": "",
  "marker": "extra == \"full\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
orjson>=3.10.0; extra == "full"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest>=8.0.0; extra == "dev"runtime
pytest-asyncio
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest-asyncio>=0.23.0; extra == "dev"runtime
pytest-cov
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest-cov>=5.0.0; extra == "dev"runtime
httpx
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
httpx>=0.27.0; extra == "dev"runtime
black
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
black>=24.0.0; extra == "dev"runtime
ruff
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
ruff>=0.4.0; extra == "dev"runtime
mypy
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
mypy>=1.10.0; extra == "dev"runtime
orjson
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
orjson>=3.10.0; extra == "dev"runtime
redis
Environment
{
  "extras": "asyncio",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
redis[asyncio]>=5.0.0; extra == "dev"runtime
prometheus-client
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
prometheus-client>=0.20.0; extra == "dev"runtime
websockets
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
websockets>=12.0; extra == "dev"runtime

Distribution files

2 collected
afmx-1.3.0-py3-none-any.whl

bdist_wheel · 193.86 KB · Python py3

Source file
afmx-1.3.0.tar.gz

sdist · 157.27 KB · Python source

Source file

Repository

PENDING
inteleion-ai/afmx

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:09 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:03daf9538864bfd3e8ade864f1176f33160fd31e4d7ec42a4dd82e24bdb13cfa

Other collected versions

View all collected versions →