async-media-agents
Async Multi-Agent POC using LangGraph + FastMCP + real media processing.
Overview
A lightweight async multi-agent system that processes images, audio, and video via base64-encoded payloads. Uses LangGraph for workflow orchestration, FastMCP for tool registration, and real processing libraries (Pillow, OpenCV, stdlib wave).
Architecture
User Request
|
SupervisorAgent
|
Fan-out (parallel conditional edge)
┌──────────┼──────────┐
| | |
ImageAgent AudioAgent VideoAgent
| | |
Pillow stdlib wave OpenCV
processor processor processor
| | |
└──────────┼──────────┘
Fan-in to Aggregator
Features
- ✅ Real media processing — Powered by Pillow (Images), OpenCV (Video), and stdlib
wave(Audio). - ✅ Parallel execution — High-performance fan-out/fan-in orchestration using LangGraph.
- ✅ MCP Integration — Model Context Protocol support via FastMCP for tool registration.
- ✅ Robust error handling — Graceful recovery from corrupt base64 or invalid formats.
- ✅ Shared state — Concurrent-safe state management via
Annotatedreducers. - ✅ Type Safety — Comprehensive static analysis with
basedpyright.
Requirements
langgraph
langchain
fastmcp
Pillow
opencv-python-headless
numpy
pytest
pytest-asyncio
Setup
1. Create and activate a virtual environment
# Create the virtual environment
python -m venv .venv
# Activate it
source .venv/bin/activate # Linux / macOS
.venv\Scripts\activate # Windows (cmd)
2. Install dependencies
pip install -r requirements.txt
Project Structure
project/
├── async_media_agents/
│ ├── agents/
│ │ ├── image_agent.py # Specialized image logic
│ │ ├── audio_agent.py # Specialized audio logic
│ │ ├── video_agent.py # Specialized video logic
│ │ └── supervisor.py # Orchestration & routing
│ │
│ ├── tools/
│ │ ├── mcp_server.py # FastMCP server registration
│ │ ├── mcp_client.py # Async client interface
│ │ └── processors/ # Pure processing logic (decoupled)
│ │ ├── image_processor.py # Pillow-based
│ │ ├── audio_processor.py # stdlib wave
│ │ └── video_processor.py # OpenCV-based
│ │
│ ├── graph/
│ │ └── workflow.py # LangGraph workflow definition
│ │
│ ├── state/
│ │ ├── state.py # Shared AgentState with reducers
│ │ └── shared_memory.py # Global shared context utilities
│ │
│ └── __init__.py
│
├── scripts/
│ └── test_workflow.py # Integration & payload tests
│
├── main.py # CLI demo & examples
├── requirements.txt
├── pyproject.toml # Project & Tool configuration
└── README.md
Usage
Run the demo
python main.py
The demo demonstrates three core patterns:
- Text-based routing — Auto-detects task type from user natural language.
- Parallel processing — Simultaneously processes multiple media types via fan-out.
- Supervisor workflow — Uses the Supervisor agent to route to a single target.
Run tests
Tests can be executed directly or through pytest:
# Direct execution (includes payload generation logs)
python scripts/test_workflow.py
# Using pytest
pytest scripts/test_workflow.py
The test suite covers:
- Base64 payload integrity (PNG, WAV, MP4)
- Real metadata extraction via processors
- Parallel transport through the workflow
- Partial payload handling
- Robust error handling for corrupted data
Programmatic use
from async_media_agents.graph.workflow import Workflow
wf = Workflow()
# Text-based — auto-routes to image/audio/video agent
result = await wf.run("Analyze this image")
# Parallel — feeds base64 to all three agents
result = await wf.run_parallel(
image_data="base64_encoded_png",
audio_data="base64_encoded_wav",
video_data="base64_encoded_mp4",
)
Processing Pipeline
| Media | Library | Extracted Metadata |
|---|---|---|
| Image | Pillow | width, height, format, mode, thumbnail |
| Audio | stdlib wave |
duration, sample rate, channels, sample width, frames |
| Video | opencv-python-headless | duration, fps, resolution, frame count, dimensions |
All processors return structured dicts: {"status": "success", "metadata": {...}} or {"status": "error", "error": "..."}.
Static Analysis
The project uses basedpyright for type checking:
pip install basedpyright
basedpyright .
Configuration lives in pyproject.toml under [tool.pyright].
State Management
AgentState extends MessagesState with custom fields. Fields written concurrently during parallel fan-out use Annotated reducers for safe merging:
results—_merge_resultsdict mergemetadata—_merge_resultsdict mergecurrent_agent—_last_winserror—_last_wins
Metadata
Release files for async-media-agents 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| async_media_agents-0.1.3.tar.gz | 15.0 kB | With provenance | Details for async_media_agents-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| async_media_agents-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for async_media_agents-0.1.3-py3-none-any.whl |
Total release size: 35.7 kB
Release files / async_media_agents-0.1.3.tar.gz
| Download URL | async_media_agents-0.1.3.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c04a7e82aa8ac18e45fa45c8dde802cf35b2b4270946c47645f912d39123a893
|
|
BLAKE2b-256 checksum How to use checksums |
7e68b123ceb710c623e4b24f66a10f6408c49b5c118f213ab3687b957085313a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.
Transparency logRelease files / async_media_agents-0.1.3-py3-none-any.whl
| Download URL | async_media_agents-0.1.3-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d83d7c5e10b4ca3f2883ddbe4d993f367bcd1c3d8df260c5f304cbc444fb65bd
|
|
BLAKE2b-256 checksum How to use checksums |
f830992160ed7e60df0359a6ee49594858cf16f46288b6d4d3a2eb2b09aa3584
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.
Transparency logSecurity for async-media-agents 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for async_media_agents-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.