Skip to main content

Stateful agent runtime with tool execution and event streaming

Project description

fluxos-agent

Python port of pi-mono/packages/agent [https://github.com/badlogic/pi-mono/tree/main/packages/agent].

fluxos-agent provides:

  • Stateful agent runtime (Agent) with prompt/continue flows
  • Agent loop primitives (agent_loop, agent_loop_continue)
  • Tool execution with streaming update events
  • Steering and follow-up queues
  • Optional proxy stream adapter (stream_proxy)

Installation

Install from PyPI (recommended):

uv add fluxos-agent
# or: pip install fluxos-agent

Local editable install (repo development):

pip install -e packages/fluxos-agent

Quick Start

import asyncio

from flux_agent import Agent, AgentOptions
from flux_agent.types import (
    AssistantDoneEvent,
    AssistantMessage,
    Context,
    Model,
    TextContent,
    Usage,
    UsageCost,
)
from flux_agent.event_stream import EventStream


class MockAssistantStream(EventStream):
    def __init__(self):
        super().__init__(
            lambda event: event.type in {"done", "error"},
            lambda event: event.message if event.type == "done" else event.error,
        )


def stream_fn(model: Model, context: Context, options):
    stream = MockAssistantStream()
    message = AssistantMessage(
        content=[TextContent(text="Hello from Python agent")],
        api=model.api,
        provider=model.provider,
        model=model.id,
        usage=Usage(cost=UsageCost()),
        stop_reason="stop",
    )
    stream.push(AssistantDoneEvent(reason="stop", message=message))
    return stream


async def main():
    agent = Agent(
        AgentOptions(
            stream_fn=stream_fn,
            initial_state={
                "system_prompt": "You are helpful.",
                "model": Model(id="mock", name="mock", api="mock", provider="mock"),
            },
        )
    )

    agent.subscribe(lambda event: print(event.type))
    await agent.prompt("Hello")


asyncio.run(main())

Testing

cd packages/fluxos-agent
pip install -e ".[dev]"
pytest tests/unit -v

Run full suite (unit + e2e scaffolding):

pytest tests -v

Release Tracking

  • Keep package changes tracked in CHANGELOG.md.
  • For every release:
    1. Update pyproject.toml version.
    2. Add a new dated section in CHANGELOG.md.
    3. Publish and tag the release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluxos_agent-2.0.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluxos_agent-2.0.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file fluxos_agent-2.0.1.tar.gz.

File metadata

  • Download URL: fluxos_agent-2.0.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fluxos_agent-2.0.1.tar.gz
Algorithm Hash digest
SHA256 5553c54eea658f2f419863ee230fb15685d07eef02c86516def7bd6ce591cb7a
MD5 90bc726a57bb496d2ea998bcaa61647a
BLAKE2b-256 d75a58cc9cb4f7a2288d69a9e82798d31427aafbcf1e7f7fd6869e39b64e5adf

See more details on using hashes here.

File details

Details for the file fluxos_agent-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: fluxos_agent-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fluxos_agent-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18629d00c5e2ee53ad682a4b19c836cbf60ce20b65d3810dce42c467b8b3154e
MD5 05b3689c2b178a6e43a25d256bff236f
BLAKE2b-256 49f6c81a4a2f43378c29529a0c5563cc24a70ccbe4c1e1f1ffe2aae421ea5424

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page