Metadata-Version: 2.4
Name: pyflue
Version: 0.2.0
Summary: Python-first agent harness framework with Markdown skills, sessions, sandboxes, and pluggable backends.
Project-URL: Homepage, https://super-agentic.ai/pyflue
Project-URL: Documentation, https://superagenticai.github.io/pyflue/
Project-URL: Repository, https://github.com/SuperagenticAI/pyflue
Project-URL: Issues, https://github.com/SuperagenticAI/pyflue/issues
Project-URL: Source, https://github.com/SuperagenticAI/pyflue
Author-email: Superagentic AI <hello@super-agentic.ai>, Shashi Jagtap <shashikant.jagtap@icloud.com>, Shashi Jagtap <shashi@super-agentic.ai>
Maintainer-email: Superagentic AI <hello@super-agentic.ai>
License: Apache License
        Version 2.0, January 2004
        http://www.apache.org/licenses/
        
        TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
        1. Definitions.
        
        "License" shall mean the terms and conditions for use, reproduction, and
        distribution as defined by Sections 1 through 9 of this document.
        
        "Licensor" shall mean the copyright owner or entity authorized by the copyright
        owner that is granting the License.
        
        "Legal Entity" shall mean the union of the acting entity and all other entities
        that control, are controlled by, or are under common control with that entity.
        For the purposes of this definition, "control" means (i) the power, direct or
        indirect, to cause the direction or management of such entity, whether by
        contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
        outstanding shares, or (iii) beneficial ownership of such entity.
        
        "You" (or "Your") shall mean an individual or Legal Entity exercising
        permissions granted by this License.
        
        "Source" form shall mean the preferred form for making modifications, including
        but not limited to software source code, documentation source, and configuration
        files.
        
        "Object" form shall mean any form resulting from mechanical transformation or
        translation of a Source form, including but not limited to compiled object code,
        generated documentation, and conversions to other media types.
        
        "Work" shall mean the work of authorship, whether in Source or Object form,
        made available under the License, as indicated by a copyright notice that is
        included in or attached to the work.
        
        "Derivative Works" shall mean any work, whether in Source or Object form, that
        is based on or derived from the Work and for which the editorial revisions,
        annotations, elaborations, or other modifications represent, as a whole, an
        original work of authorship. For the purposes of this License, Derivative Works
        shall not include works that remain separable from, or merely link or bind by
        name to the interfaces of, the Work and Derivative Works thereof.
        
        "Contribution" shall mean any work of authorship, including the original version
        of the Work and any modifications or additions to that Work or Derivative Works
        thereof, that is intentionally submitted to Licensor for inclusion in the Work
        by the copyright owner or by an individual or Legal Entity authorized to submit
        on behalf of the copyright owner. For the purposes of this definition,
        "submitted" means any form of electronic, verbal, or written communication sent
        to the Licensor or its representatives, including but not limited to
        communication on electronic mailing lists, source code control systems, and
        issue tracking systems that are managed by, or on behalf of, the Licensor for
        the purpose of discussing and improving the Work, but excluding communication
        that is conspicuously marked or otherwise designated in writing by the copyright
        owner as "Not a Contribution."
        
        "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
        of whom a Contribution has been received by Licensor and subsequently
        incorporated within the Work.
        
        2. Grant of Copyright License. Subject to the terms and conditions of this
        License, each Contributor hereby grants to You a perpetual, worldwide,
        non-exclusive, no-charge, royalty-free, irrevocable copyright license to
        reproduce, prepare Derivative Works of, publicly display, publicly perform,
        sublicense, and distribute the Work and such Derivative Works in Source or
        Object form.
        
        3. Grant of Patent License. Subject to the terms and conditions of this License,
        each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
        no-charge, royalty-free, irrevocable patent license to make, have made, use,
        offer to sell, sell, import, and otherwise transfer the Work, where such license
        applies only to those patent claims licensable by such Contributor that are
        necessarily infringed by their Contribution alone or by combination of their
        Contribution with the Work to which such Contribution was submitted. If You
        institute patent litigation against any entity alleging that the Work or a
        Contribution incorporated within the Work constitutes direct or contributory
        patent infringement, then any patent licenses granted to You under this License
        for that Work shall terminate as of the date such litigation is filed.
        
        4. Redistribution. You may reproduce and distribute copies of the Work or
        Derivative Works thereof in any medium, with or without modifications, and in
        Source or Object form, provided that You meet the following conditions:
        
        (a) You must give any other recipients of the Work or Derivative Works a copy of
        this License; and
        
        (b) You must cause any modified files to carry prominent notices stating that
        You changed the files; and
        
        (c) You must retain, in the Source form of any Derivative Works that You
        distribute, all copyright, patent, trademark, and attribution notices from the
        Source form of the Work, excluding those notices that do not pertain to any part
        of the Derivative Works; and
        
        (d) If the Work includes a "NOTICE" text file as part of its distribution, then
        any Derivative Works that You distribute must include a readable copy of the
        attribution notices contained within such NOTICE file, excluding those notices
        that do not pertain to any part of the Derivative Works, in at least one of the
        following places: within a NOTICE text file distributed as part of the
        Derivative Works; within the Source form or documentation, if provided along
        with the Derivative Works; or, within a display generated by the Derivative
        Works, if and wherever such third-party notices normally appear. The contents of
        the NOTICE file are for informational purposes only and do not modify the
        License. You may add Your own attribution notices within Derivative Works that
        You distribute, alongside or as an addendum to the NOTICE text from the Work,
        provided that such additional attribution notices cannot be construed as
        modifying the License.
        
        You may add Your own copyright statement to Your modifications and may provide
        additional or different license terms and conditions for use, reproduction, or
        distribution of Your modifications, or for any such Derivative Works as a whole,
        provided Your use, reproduction, and distribution of the Work otherwise complies
        with the conditions stated in this License.
        
        5. Submission of Contributions. Unless You explicitly state otherwise, any
        Contribution intentionally submitted for inclusion in the Work by You to the
        Licensor shall be under the terms and conditions of this License, without any
        additional terms or conditions. Notwithstanding the above, nothing herein shall
        supersede or modify the terms of any separate license agreement you may have
        executed with Licensor regarding such Contributions.
        
        6. Trademarks. This License does not grant permission to use the trade names,
        trademarks, service marks, or product names of the Licensor, except as required
        for reasonable and customary use in describing the origin of the Work and
        reproducing the content of the NOTICE file.
        
        7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
        writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR
        CONDITIONS OF ANY KIND, either express or implied, including, without
        limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
        MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
        responsible for determining the appropriateness of using or redistributing the
        Work and assume any risks associated with Your exercise of permissions under
        this License.
        
        8. Limitation of Liability. In no event and under no legal theory, whether in
        tort (including negligence), contract, or otherwise, unless required by
        applicable law (such as deliberate and grossly negligent acts) or agreed to in
        writing, shall any Contributor be liable to You for damages, including any
        direct, indirect, special, incidental, or consequential damages of any character
        arising as a result of this License or out of the use or inability to use the
        Work, even if such Contributor has been advised of the possibility of such
        damages.
        
        9. Accepting Warranty or Additional Liability. While redistributing the Work or
        Derivative Works thereof, You may choose to offer, and charge a fee for,
        acceptance of support, warranty, indemnity, or other liability obligations or
        rights consistent with this License. However, in accepting such obligations, You
        may act only on Your own behalf and on Your sole responsibility, not on behalf
        of any other Contributor, and only if You agree to indemnify, defend, and hold
        each Contributor harmless for any liability incurred by, or claims asserted
        against, such Contributor by reason of your accepting any such warranty or
        additional liability.
        
        END OF TERMS AND CONDITIONS
License-File: LICENSE
Keywords: agent-framework,agent-harness,agents,ai-agents,autonomous-agents,deepagents,markdown,pydantic,python-agents,sandbox,skills
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
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: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: aiosqlite>=0.21.0
Requires-Dist: fastapi<1,>=0.124.0
Requires-Dist: httpx<1,>=0.28.1
Requires-Dist: mcp>=1.27.0
Requires-Dist: pydantic-ai<1.90.0,>=1.89.1
Requires-Dist: pydantic<3,>=2.12.2
Requires-Dist: python-frontmatter>=1.1.0
Requires-Dist: pyyaml<7,>=6.0.2
Requires-Dist: rich>=13.7.0
Requires-Dist: typer>=0.12.0
Requires-Dist: uvicorn<1,>=0.38.0
Requires-Dist: watchdog<7,>=6
Provides-Extra: daytona
Requires-Dist: daytona-sdk>=0.22.0; extra == 'daytona'
Provides-Extra: deepagents
Requires-Dist: deepagents<0.6.0,>=0.5.6; extra == 'deepagents'
Provides-Extra: dev
Requires-Dist: deepagents<0.6.0,>=0.5.6; extra == 'dev'
Requires-Dist: opentelemetry-sdk>=1.20; extra == 'dev'
Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
Requires-Dist: pytest<10,>=9; extra == 'dev'
Requires-Dist: ruff>=0.14; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material<10,>=9.6.0; extra == 'docs'
Requires-Dist: mkdocs<2,>=1.6.1; extra == 'docs'
Requires-Dist: pymdown-extensions<11,>=10.14; extra == 'docs'
Provides-Extra: e2b
Requires-Dist: e2b>=2.7.0; extra == 'e2b'
Provides-Extra: google
Requires-Dist: google-adk<1.33.0,>=1.32.0; extra == 'google'
Requires-Dist: google-genai<2,>=1.72; extra == 'google'
Provides-Extra: modal
Requires-Dist: modal>=1.3.0; extra == 'modal'
Provides-Extra: monty
Requires-Dist: pydantic-monty<0.0.18,>=0.0.17; extra == 'monty'
Provides-Extra: openai
Requires-Dist: openai-agents<0.16.0,>=0.15.1; extra == 'openai'
Requires-Dist: openai<3,>=2.26.0; extra == 'openai'
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.20; extra == 'otel'
Provides-Extra: pydanticai
Requires-Dist: pydantic-ai-harness[code-mode]; extra == 'pydanticai'
Requires-Dist: pydantic-ai-slim<1.90.0,>=1.89.1; extra == 'pydanticai'
Requires-Dist: pydantic-ai<1.90.0,>=1.89.1; extra == 'pydanticai'
Provides-Extra: runloop
Requires-Dist: runloop-api-client>=0.82.0; extra == 'runloop'
Provides-Extra: sandboxes
Requires-Dist: daytona-sdk>=0.22.0; extra == 'sandboxes'
Requires-Dist: e2b>=2.7.0; extra == 'sandboxes'
Requires-Dist: modal>=1.3.0; extra == 'sandboxes'
Requires-Dist: runloop-api-client>=0.82.0; extra == 'sandboxes'
Provides-Extra: server
Requires-Dist: fastapi<1,>=0.124.0; extra == 'server'
Requires-Dist: uvicorn<1,>=0.38.0; extra == 'server'
Requires-Dist: websockets>=12; extra == 'server'
Description-Content-Type: text/markdown

# PyFlue

[![CI](https://github.com/SuperagenticAI/pyflue/actions/workflows/ci.yml/badge.svg)](https://github.com/SuperagenticAI/pyflue/actions/workflows/ci.yml)
[![Docs](https://img.shields.io/badge/docs-superagenticai.github.io%2Fpyflue-blue)](https://superagenticai.github.io/pyflue/)
[![Landing Page](https://img.shields.io/badge/landing-super--agentic.ai%2Fpyflue-black)](https://super-agentic.ai/pyflue)
[![PyPI](https://img.shields.io/pypi/v/pyflue)](https://pypi.org/project/pyflue/)
[![Python](https://img.shields.io/pypi/pyversions/pyflue)](https://pypi.org/project/pyflue/)
[![License](https://img.shields.io/pypi/l/pyflue)](https://github.com/SuperagenticAI/pyflue/blob/main/LICENSE)


PyFlue is the agent harness framework for Python. You build persistent **agents**
and finite **workflows**, with Markdown skills, stateful sessions, sandboxed
filesystem and shell access, typed Pydantic outputs, streaming events,
OpenTelemetry tracing, and deployment-ready project structure.

PyFlue adapts the agent harness model for Python teams. The harness that drives
it is pluggable: Pydantic AI by default (typed, model agnostic, no LangChain), or
DeepAgents for LangChain users, with the registry open for more backends.

> **Warning: Active Development**
>
> PyFlue is under active development. The API may change. Pin your dependencies
> and review changelogs before updating.

Use it to build coding agents, issue triage agents, data analysis agents,
support agents, and workflow agents that need controlled access to files,
commands, tools, and structured outputs.

Documentation: <https://superagenticai.github.io/pyflue/>

Landing page: <https://super-agentic.ai/pyflue>

## Install

With `uv`:

```bash
uv add pyflue
```

With `pip`:

```bash
pip install pyflue
```

Optional extras:

```bash
uv add "pyflue[monty]"
uv add "pyflue[sandboxes]"
```

```bash
pip install "pyflue[monty]"
pip install "pyflue[sandboxes]"
```

## Quick Start

```bash
pyflue init my-agent
cd my-agent
pyflue run --prompt "Review this project"
```

Run a local server/client smoke demo without a model key:

```bash
uv run python examples/server_client/run_smoke.py
```

## Agents and Workflows

PyFlue has two boundaries for model driven work. A persistent **agent** keeps
sessions over time; a finite **workflow** runs one bounded operation and returns
a result.

```python
# A persistent agent in src/agents/assistant.py
from pyflue import create_agent

default = create_agent(lambda ctx: {"model": "openai:gpt-5.5"})
```

```python
# A finite workflow in src/workflows/summarize.py
from pyflue import FlueContext, create_agent

agent = create_agent(lambda ctx: {"model": "openai:gpt-5.5"})


async def run(ctx: FlueContext) -> dict:
    harness = await ctx.init(agent)
    session = await harness.session()
    response = await session.prompt(ctx.payload["text"])
    return {"summary": response.text}
```

Agents are served at `POST /agents/<name>/<id>` and over WebSocket, and accept
asynchronous input with `dispatch(...)`. Workflows run with `pyflue run <name>`,
`POST /workflows/<name>`, or WebSocket. See the
[Agents vs Workflows](https://superagenticai.github.io/pyflue/concepts/agents-vs-workflows/)
guide.

## Choose a harness

The harness that runs the model loop is pluggable and does not change your agent
or workflow code.

```python
agent = await init(harness="pydanticai")    # default: typed, model agnostic, no LangChain
agent = await init(harness="deepagents")    # optional, for LangChain users: pip install 'pyflue[deepagents]'
```

## Python API

```python
from pydantic import BaseModel
from pyflue import init


class FixResult(BaseModel):
    fix_applied: bool
    summary: str


async def main():
    agent = await init(
        model="openai:gpt-5.5",
        sandbox="virtual",
        allow_write=True,
        allow_shell=True,
        allowed_commands=["git"],
    )
    session = await agent.session("fix-123")
    result = await session.skill(
        "triage",
        args={"issue_number": 123},
        result=FixResult,
    )
    if result.fix_applied:
        await session.shell("git status --short")
```

## What PyFlue Gives You

| Capability | What it means |
| --- | --- |
| Agents | Define persistent, addressable agents with `create_agent`, served over HTTP and WebSocket. |
| Workflows | Define finite operations with `run(ctx)`, run locally, over HTTP, or WebSocket. |
| Subagents | Delegate to declared profiles with `task(agent="name")`. |
| Dispatch | Accept asynchronous agent input with `dispatch(...)`. |
| Observability | Correlated event stream and an OpenTelemetry adapter (`pyflue[otel]`). |
| Harness backends | DeepAgents (default) or Pydantic AI, pluggable through a registry. |
| Markdown skills | Put reusable workflows in `.agents/skills/*.md`. |
| Project instructions | Use `AGENTS.md` for global behavior and context. |
| Roles | Scope behavior with `.agents/roles/*.md`. |
| Sessions | Resume agent state with stable session IDs. |
| Tasks | Run focused child tasks with isolated history and shared sandbox. |
| Sandbox | Read, write, edit, grep, glob, and shell behind explicit policies. |
| Secret grants | Keep secrets out of prompts and grant them only per call. |
| Typed outputs | Validate results with Pydantic, extract JSON from text, and repair invalid JSON automatically. |
| Streaming | Use `session.stream(...)`, `pyflue run --stream`, or SSE. |
| Abort | Cancel active prompt, stream, task, and shell operations with `session.abort()`. |
| Structured commands | Expose reusable shell or callable commands with `PyFlueCommand`. |
| Python client | Call deployed PyFlue servers with `PyFlueClient`. |
| Webhooks | Expose `agents/*.py` as `/agents/{name}/{agent_id}`. |
| Python code backend | Use `pyflue[monty]` for safe host-side Python snippets. |
| Remote sandboxes | Use Daytona, E2B, Modal, or Runloop with optional extras. |
| Connector guides | Use `pyflue add` to print agent-readable setup guides for sandbox providers. |
| Deployment | Generate Docker/FastAPI, CI, Railway, Render, Fly.io, Vercel, Netlify, and Cloudflare Containers starter files. |

## Project Layout

`src/` is the canonical layout. Agents and workflows are also discovered from
the project root and from `.agents` or `.pyflue`.

```text
AGENTS.md
pyflue.toml
.agents/
  roles/
    coder.md
  skills/
    triage.md
src/
  agents/
    assistant.py
  workflows/
    summarize.py
```

## File-Based Agent (legacy)

The original file based handler model is still supported and is treated as
workflow like. New projects use `create_agent` agents and `run(ctx)` workflows
(see [Agents and Workflows](#agents-and-workflows)).

```python
triggers = {"webhook": True}


async def default(context):
    agent = await context.init()
    session = await agent.session(context.agent_id)
    result = await session.prompt(context.payload["prompt"])
    return {"text": result.text}
```

Run it locally:

```bash
pyflue dev --port 2024
```

Call it:

```bash
curl http://127.0.0.1:2024/agents/default/demo \
  -H "Content-Type: application/json" \
  -d '{"payload": {"prompt": "Review this repository"}}'
```

## Streaming

```bash
pyflue run --stream --prompt "Review this project"
```

```python
async for event in session.stream("Review this project"):
    print(event.type, event.data)
```

## Connector Guides

List available guides:

```bash
pyflue add
```

Print a guide for a known sandbox provider:

```bash
pyflue add daytona --print
```

Start from any provider documentation URL:

```bash
pyflue add https://e2b.dev/docs --category sandbox --print | codex
```

## Security Model

PyFlue starts with safe defaults:

- writes are disabled until `allow_write=True`
- shell execution is disabled until `allow_shell=True`
- compound shell syntax is blocked by default
- command allowlists are supported with `allowed_commands`
- secrets are not injected into prompts
- secrets are mounted into sandbox calls only when requested with `secrets=[...]`

## Deployment

Generate deployment files:

```bash
pyflue build --target docker
pyflue build --target railway
pyflue build --target fly
pyflue build --target vercel
pyflue build --target netlify
pyflue build --target cloudflare
```

Deploy with a supported provider CLI:

```bash
pyflue deploy --target fly
```

## Development

```bash
uv sync --extra dev --extra docs
uv run --extra dev ruff check .
uv run --extra dev pytest
uv run --extra docs mkdocs build --strict
uv build
```
