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

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.0.tar.gz (14.2 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.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fluxos_agent-2.0.0.tar.gz
  • Upload date:
  • Size: 14.2 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.0.tar.gz
Algorithm Hash digest
SHA256 f8957cdb0e0c91e76f49df2d6462a3cdb3fd7ffe70196545662ef3ad616409d7
MD5 5bb3066fdad46e7690e61d1872c12742
BLAKE2b-256 1e2d7dd39768beca7feb07fe893c30f0f9fb6051321661e439161b92cedddc45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fluxos_agent-2.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80bac3c4463aa3e0efe78dbc7b1a58770482c549110ec5f9f238d34669f240dc
MD5 73793f23ec02e69c6e6985efe1aec518
BLAKE2b-256 0102e7aab366f13ab3489d7d5ac758b80dfcbc6657afea70b79fe20e47263406

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