Metadata-Version: 2.4
Name: flowgentic
Version: 0.7.2
Summary: Flowgentic runs LLM agents on HPC resources with the RADICAL stack: as AsyncFlow workflow tasks, and as agents at scale, on its own agent loop and OpenAI-compatible model servers, whose tools run as RHAPSODY tasks and whose state lives in RaDEX; LangGraph is optional.
Author-email: Javier Dominguez <jdominguez.ieu2023@student.ie.edu>, Yousef Amirghofran <yamirghofran.ieu2023@student.ie.edu>, Matteo Turilli <mturilli@faculty.ie.edu>
License-Expression: MIT
Project-URL: Homepage, https://github.com/stride-research/flowgentic
Project-URL: Documentation, https://stride-research.github.io/flowgentic/
Project-URL: Repository, https://github.com/stride-research/flowgentic
Project-URL: Issues, https://github.com/stride-research/flowgentic/issues
Project-URL: Changelog, https://github.com/stride-research/flowgentic/blob/main/CHANGELOG.md
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: System :: Distributed Computing
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0.0
Requires-Dist: opentelemetry-api<2,>=1.43
Requires-Dist: httpx<1,>=0.27
Provides-Extra: langgraph
Requires-Dist: langgraph<2.0,>=1.1.5; extra == "langgraph"
Requires-Dist: langgraph-checkpoint<5,>=4.3; extra == "langgraph"
Requires-Dist: langchain<2.0,>=1.0; extra == "langgraph"
Requires-Dist: langchain-core<2.0,>=1.0; extra == "langgraph"
Requires-Dist: langchain-openai<2.0,>=1.0; extra == "langgraph"
Requires-Dist: langchain-ollama<2.0,>=1.0; extra == "langgraph"
Provides-Extra: openai
Requires-Dist: openai<4,>=1.109; extra == "openai"
Provides-Extra: asyncflow
Requires-Dist: radical-asyncflow<0.9,>=0.7; extra == "asyncflow"
Provides-Extra: rhapsody
Requires-Dist: rhapsody-py<0.9,>=0.7; extra == "rhapsody"
Provides-Extra: mcp
Requires-Dist: mcp<2.4,>=2.3; extra == "mcp"
Provides-Extra: agents
Requires-Dist: flowgentic[mcp,rhapsody]; extra == "agents"
Provides-Extra: otlp
Requires-Dist: opentelemetry-sdk<2,>=1.43; extra == "otlp"
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.43; extra == "otlp"
Provides-Extra: examples
Requires-Dist: flowgentic[asyncflow,langgraph]; extra == "examples"
Requires-Dist: python-dotenv>=1.0; extra == "examples"
Requires-Dist: academy-py<2,>=1.0; extra == "examples"
Requires-Dist: opentelemetry-sdk<2,>=1.43; extra == "examples"
Requires-Dist: opentelemetry-instrumentation-genai-langchain<1.4,>=1.3b0; extra == "examples"
Requires-Dist: opentelemetry-instrumentation-genai-openai<1.4,>=1.3b0; extra == "examples"
Requires-Dist: rhapsody-py[telemetry]<0.9,>=0.7; extra == "examples"
Provides-Extra: dev
Requires-Dist: flowgentic[agents,examples,openai,otlp]; extra == "dev"
Requires-Dist: ruff>=0.12.11; extra == "dev"
Requires-Dist: pre-commit>=4.0; extra == "dev"
Requires-Dist: mkdocs-material>=9.6; extra == "dev"
Requires-Dist: mkdocstrings[python]>=1.0.7; extra == "dev"
Requires-Dist: pymdown-extensions>=10.16; extra == "dev"
Requires-Dist: mkdocs_gen_files>=0.5; extra == "dev"
Requires-Dist: mkdocs-literate-nav>=0.6; extra == "dev"
Requires-Dist: mkdocs-section-index>=0.3.10; extra == "dev"
Requires-Dist: pytest>=8.4.2; extra == "dev"
Requires-Dist: pytest-asyncio>=1.2.0; extra == "dev"
Requires-Dist: pytest-cov>=7.0; extra == "dev"
Requires-Dist: numpy>=1.26; extra == "dev"
Dynamic: license-file

<p align="center">
  <a href="https://opensource.org/licenses/MIT">
    <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT">
  </a>
  <a href="https://www.python.org/downloads/">
    <img src="https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue.svg" alt="Python 3.11, 3.12, 3.13">
  </a>
  <a href="https://github.com/stride-research/flowgentic/actions/workflows/continuous_integration.yml">
    <img src="https://github.com/stride-research/flowgentic/actions/workflows/continuous_integration.yml/badge.svg?branch=main" alt="CI">
  </a>
  <a href="https://github.com/stride-research/flowgentic/actions/workflows/docs-deployment.yml">
    <img src="https://github.com/stride-research/flowgentic/actions/workflows/docs-deployment.yml/badge.svg" alt="Documentation">
  </a>
</p>

# Flowgentic

Flowgentic runs LLM agents on HPC resources with the RADICAL stack: as
AsyncFlow workflow tasks, and, from 0.5.0, as agents at scale whose tools run
as RHAPSODY tasks and whose state lives in RaDEX. Agents at scale run on
Flowgentic's own agent loop and OpenAI-compatible model servers; LangGraph is
optional.
Documentation: [stride-research.github.io/flowgentic](https://stride-research.github.io/flowgentic/).

## Where Flowgentic sits

![Where Flowgentic sits: what uses it, what it uses, and the seams where another tool fits](https://raw.githubusercontent.com/stride-research/flowgentic/main/docs/assets/diagrams/stack.svg)

<!-- --8<-- [start:stack] -->
The stack answers where Flowgentic sits: what uses it, what it uses, and which
of those another tool can replace.

Above Flowgentic are the systems whose agents it runs: agentic middleware such
as AUTONMI, agents written as LangGraph graphs, and AsyncFlow workflows that
call agents as tasks, such as the agentic ones built with Workflow Mini-Apps.
Around it, the boxes in blue are seams, each named by its interface. The tool
in each seam is an example of the layer: another tool that implements the
interface can take its place, today or after the work below. The application
starts the services among them and passes them in; Flowgentic starts none of
them.

| Seam | Interface | What Flowgentic ships | Another tool |
| --- | --- | --- | --- |
| Agent framework | The host's `Runner`: `start` and `resume` | `LoopRunner`, Flowgentic's own loop; `GraphRunner`, for LangGraph | After some work: another framework needs a runner, and an adapter for its tools |
| Model servers | OpenAI-compatible HTTP, through a `Transport` | `HTTPTransport`, for vLLM, SGLang or a hosted API; `OpenAITransport`; LangChain chat models | Fits today: any server that speaks the API, or the application's own `Transport`, such as a stub for tests |
| Store | `KeyValueStore`: `get`, `put`, `delete`, `contains` | `RadexStore`, on RaDEX under Dragon; `MemoryStore`, a dictionary in the process | Fits today: any object with these four methods |
| MCP servers | MCP, by URL or a connect function | The tool service's MCP clients | Fits today: any MCP server |
| Telemetry | The OpenTelemetry API | Spans and metrics from every part; `flowgentic.otlp`, to stream them to a collector | Fits today: any SDK and exporters the application sets up |
| Task runtime | A RHAPSODY `Session`, or an AsyncFlow engine | `ToolRuntime` takes either; RHAPSODY runs on its own backends, such as Dragon or a local pool | After some work: another runtime needs a module like `flowgentic._rhapsody` |
| Runtime | Processes, queues and memory, passed in | Dragon on an allocation; threads, `multiprocessing` queues and a dictionary locally | Fits today: Flowgentic imports nothing from Dragon |
<!-- --8<-- [end:stack] -->

## Architecture

![Flowgentic's architecture: its components by module, and the interfaces at its edge](https://raw.githubusercontent.com/stride-research/flowgentic/main/docs/assets/diagrams/architecture.svg)

<!-- --8<-- [start:architecture] -->
The architecture answers what Flowgentic's own components are, what each does,
and which interfaces connect them to each other and to the systems around
Flowgentic. Each runtime is reached through one private module, so the rest of
Flowgentic does not depend on it. `LangGraphIntegration` is frozen: it gets
fixes, not features.
<!-- --8<-- [end:architecture] -->

## How agents run

![How agents run: N agent processes on an allocation, and one agent's calls to the model servers, the store, the task workers and the tool service](https://raw.githubusercontent.com/stride-research/flowgentic/main/docs/assets/diagrams/execution.svg)

<!-- --8<-- [start:execution] -->
The execution model answers what happens, in order, when agents run, and in
which process.

1. **Start.** The application starts the model servers, the store, the tool
   service and N agent processes, and passes each process what it uses. Each
   process's `AgentHost` starts its agents, from a list or as they arrive, up
   to a cap of live agents. Thousands of agents share the process's event
   loop, each in one state at a time.
2. **A model turn.** The loop sends the agent's model call through the fleet,
   which admits it within this process's share of the caps and sends it to the
   agent's replica of a model server.
3. **A task tool.** The tool calls of a reply run at once. An inline tool runs
   in the agent's process: an async one on the event loop, any other in a
   thread pool. A task tool, such as a simulation, becomes a RHAPSODY task on
   a worker, or a task of the application's AsyncFlow engine.
4. **Suspend and resume.** While its task runs, the agent waits. If the tool
   suspends it, which needs a store, the loop puts its messages in the store,
   and the agent holds no memory in the process. When the task ends, the host resumes the agent, and the loop reads
   its messages back.
5. **An MCP tool.** An MCP tool goes to the tool service over queues: one
   service calls the MCP servers for every agent process.
6. **The end.** When the agent answers, the loop deletes its state from the
   store, and the host hands its result to the application, through `on_done`
   or the future that `submit` returned.
<!-- --8<-- [end:execution] -->

## Status

The agents-at-scale path, new in 0.5.0, is in active development. It runs many
thousands of agents per process on an HPC allocation: an agent host,
Flowgentic's own agent loop, which keeps a suspended agent's state in the
allocation's memory, tools that run inline, as RHAPSODY tasks or through a
shared MCP tool service, and a client for a fleet of OpenAI-compatible model
servers, such as vLLM and SGLang. LangGraph is optional: with the `langgraph`
extra, LangGraph graphs run on the same parts.

The AsyncFlow path is in maintenance mode: it gets fixes, not features. The
LangGraph execution adapter (`LangGraphIntegration`) is frozen. New
applications can bind agents with `bind_agent`, or run LangGraph on AsyncFlow
directly.

0.7.2 requires Python 3.11 or later, and installs each path's dependencies as
an extra.

| Path | Agent framework | Runs tasks on | Python |
| --- | --- | --- | --- |
| Agents at scale | Flowgentic's agent loop; LangGraph 1.x, optional | RHAPSODY 0.7 and 0.8 | 3.11, 3.12, 3.13 |
| AsyncFlow | LangGraph 1.x | RADICAL AsyncFlow 0.7 and 0.8, local backends | 3.11, 3.12, 3.13 |

[Project status](https://stride-research.github.io/flowgentic/status/) lists the tested versions, the known limitations
and the archived branches.

## What it provides

Agents at scale (see [Agents at scale](https://stride-research.github.io/flowgentic/guides/agents-at-scale/)):

- **`LoopRunner`** (`flowgentic.loop`) runs each agent as a tool-calling loop
  on OpenAI-format messages: the calls of a reply run at once, tool errors go
  back to the model, and an agent suspends while its task runs, its state in a
  key-value store (`flowgentic.store`): RaDEX on an allocation, a dictionary
  in the process elsewhere. It needs no LangGraph.
- **`AgentHost`** (`flowgentic.host`) runs thousands of agents in one process:
  it tunes the collector, caps the agents live at once, staggers their starts,
  resumes agents that wait on tasks, and counts agents by state. It runs a
  list of agents, or takes them one at a time, as a server's messages arrive
  (`start`, `submit`, `stop`).
- **`GraphRunner` and `KeyValueSaver`** (`flowgentic.langgraph`), with the
  `langgraph` extra, run LangGraph graphs in the same host, their checkpoints
  in the same store.
- **`task_tool` and `mcp_tool`** (`flowgentic.tools`) say where a tool runs: as
  a task on a RHAPSODY session or on the application's own AsyncFlow engine,
  which may suspend its agent and leaves a record of when the agent decided
  on it and when it ran, or through the tool service
  (`flowgentic.tools.service`), which calls MCP tools for many agent processes.
- **`Fleet`** (`flowgentic.fleet`) sends each agent's model calls to one
  replica of a model server, under caps on tokens and requests in flight. A
  replica is a transport, such as `HTTPTransport` for vLLM, SGLang or
  OpenRouter.
- **`read_export`** (`flowgentic.telemetry`) reads back the OpenTelemetry
  export of every agent process of a run, and checks it: each fleet's calls
  against its `chat` spans, and its tokens against the model servers' own
  counters.
- **`configure`** (`flowgentic.otlp`), with the `otlp` extra, streams each
  agent process's metrics and spans to an OpenTelemetry collector, and
  `examples/live-dashboard` shows the run live in Grafana: agents in each
  state, model calls and tokens per second, queues at the replicas, tools.
  Its stack runs per user, on 127.0.0.1, behind a login and a token; on a
  shared node, other users of the node can reach 127.0.0.1, so keep both.

The AsyncFlow path:

- **`bind_agent`** (`flowgentic.agent`) binds an agent component, any object
  with an `ainvoke(context)` method, to an AsyncFlow task on a named backend.
  Each call to the bound agent runs the component as that task and returns its
  structured decision with the agent's identity and timing, and is an
  OpenTelemetry `invoke_agent` span.
- **`accept`** (`flowgentic.acceptance`) accepts or rejects an agent's output
  on explicit checks, before it becomes HPC work. It asks again with the
  reasons, within an attempt budget, and falls back to a deterministic value
  when no proposal passes. Each call, attempt and check is recorded in the
  run's trace.
- **`LangGraphIntegration`** (`flowgentic.langgraph`) runs a LangGraph graph's
  tools, services, tasks and nodes as AsyncFlow tasks, in their caller's trace.

## Install

From PyPI, with the extra of each path you use:

```bash
pip install "flowgentic[agents]"
```

Flowgentic's core installs no agent framework and no workflow engine. Each
path is an extra:

| Extra | Installs | For |
| --- | --- | --- |
| `agents` | `rhapsody` and `mcp` | Agents at scale |
| `rhapsody` | RHAPSODY | Task tools on a RHAPSODY session |
| `mcp` | The MCP SDK | The tool service's MCP clients |
| `langgraph` | LangGraph and LangChain | LangGraph graphs on agents at scale (`agents,langgraph`), and the LangGraph integration on AsyncFlow (`langgraph,asyncflow`) |
| `asyncflow` | RADICAL AsyncFlow | `bind_agent`, and task tools on an AsyncFlow engine |
| `openai` | The `openai` SDK | `OpenAITransport`, the fleet's transport over the SDK |
| `otlp` | The OpenTelemetry SDK and its OTLP/HTTP exporter | Streaming a run's telemetry to an OpenTelemetry collector, for a live dashboard |

RaDEX, which keeps agents' state in a Dragon distributed dictionary on an
allocation, is not on PyPI, and no extra installs it: `RadexStore` needs its
Python client, built from source with its C++ core; see
[radical-cybertools/radex](https://github.com/radical-cybertools/radex). A
laptop needs neither RaDEX nor Dragon.

The examples and the demos run from a clone, with the locked environment:

```bash
git clone https://github.com/stride-research/flowgentic.git
cd flowgentic
uv sync --locked
```

The demos' `make` targets add the extras they need.

## Run the examples

`examples/agents-at-scale/` runs a campaign of agents on Flowgentic's loop on
a laptop, with a scripted model, RHAPSODY on a thread pool and a real MCP
server, in one agent process or several; `--runner graph` runs the same
agents as a LangGraph graph:

```bash
uv run --extra agents python examples/agents-at-scale/campaign.py --agents 1000
uv run --extra agents --extra langgraph python examples/agents-at-scale/campaign.py --agents 1000 --runner graph
```

[Agents at scale](https://stride-research.github.io/flowgentic/guides/agents-at-scale/) walks through it.

Two demos of the AsyncFlow path, in `examples/ai-hpc-coupling/`, run offline,
with no model credentials: a deterministic LangGraph graph, and an agentic
one whose agents take scripted decisions.

```bash
make examples-ai-hpc-deterministic
make examples-ai-hpc-agentic
```

[Getting started](https://stride-research.github.io/flowgentic/getting-started/)
explains their output, and `examples/ai-hpc-coupling/README.md` the other
demos.

## Development

```bash
uv sync --locked --extra dev
uv run --extra dev pytest -q
uv run --extra dev mkdocs build --strict
```

[CONTRIBUTING.md](https://github.com/stride-research/flowgentic/blob/main/CONTRIBUTING.md) covers the environment, coding style,
tests and pull requests. Report bugs and requests as
[GitHub issues](https://github.com/stride-research/flowgentic/issues/new).
[CHANGELOG.md](https://github.com/stride-research/flowgentic/blob/main/CHANGELOG.md) lists the changes in each release.

## How to cite

If you use Flowgentic in your work, please cite it. [CITATION.cff](https://github.com/stride-research/flowgentic/blob/main/CITATION.cff)
holds the metadata, and GitHub's "Cite this repository" menu turns it into APA
or BibTeX:

> Alsaadi, A., Amirghofran, Y., Barbero, C., Cordovez, D., Dominguez, J.,
> Oliveros, D., & Turilli, M. (2026). *Flowgentic* (Version 0.7.2) [Computer
> software]. https://github.com/stride-research/flowgentic

## License

MIT; see [LICENSE](https://github.com/stride-research/flowgentic/blob/main/LICENSE).
