Skip to main content

Graph-based agent framework powered by oauth-codex

Project description

Fabrix

Language: English | 한국어
API Guides: English | 한국어

Overview

Fabrix is a graph-based agent framework built on top of oauth-codex>=2.3.0. It provides a structured execution graph with streaming events for tool-driven workflows.

Key Features

  • Graph-based 4-state execution: reasoning, tool_call, response, finish
  • Structured state outputs powered by Pydantic models
  • Sequential tool execution with strict payload validation
  • Async streaming event API for step-by-step observability
  • Multimodal input with explicit message models: TextMessage, ImageMessage

Installation

pip install fabrix-ai

Quickstart

import asyncio

from pydantic import BaseModel

from fabrix import Agent
from fabrix.events import (
    ReasoningEvent,
    ResponseEvent,
    TaskFailedEvent,
    TaskFinishedEvent,
    ToolEvent,
)
from fabrix.messages import TextMessage


class AddInput(BaseModel):
    a: int
    b: int


def add_numbers(payload: AddInput) -> int:
    return payload.a + payload.b


async def main() -> None:
    agent = Agent(
        instructions="You are a precise assistant.",
        model="gpt-5.3-codex",
        tools=[add_numbers],
    )

    messages = [TextMessage(text="Use add_numbers to compute 3 + 9")]
    async for event in agent.run_stream(messages=messages):
        print(f"[step={event.step}] {event.event_type}")

        if isinstance(event, ReasoningEvent):
            print("reasoning:", event.reasoning)
            print("focus:", event.focus)
        elif isinstance(event, ToolEvent):
            if event.phase == "start":
                print("tool call:", event.tool_name, event.arguments)
            elif event.result is not None:
                print("tool result:", event.result.model_dump())
        elif isinstance(event, ResponseEvent):
            print("response:", event.response)
        elif isinstance(event, TaskFinishedEvent):
            print("completion reason:", event.completion_reason)
            print("final:", event.final_output)
        elif isinstance(event, TaskFailedEvent):
            print("failed:", event.error_code, event.message)


asyncio.run(main())

Message Models

Fabrix input is now list[TextMessage | ImageMessage].

  • TextMessage(role: str = "user", text: str)
  • ImageMessage(role: str = "user", image: str | Path | bytes, text: str | None = None)
  • Unknown message fields are rejected at construction time.

ImageMessage.image accepts:

  • remote URL (https://...)
  • local path (Path or string path)
  • raw bytes (bytes), encoded to a data URL internally

Multimodal Input

from fabrix.messages import ImageMessage, TextMessage

messages = [
    TextMessage(text="Describe this screenshot"),
    ImageMessage(image="https://example.com/screenshot.png"),
    TextMessage(text="Focus on errors"),
]

async for event in agent.run_stream(messages=messages):
    ...

Tool Contract

Fabrix accepts tools in this shape:

def tool(payload: BaseModel) -> Any: ...
  • The tool must accept exactly one parameter.
  • The parameter type must be a Pydantic BaseModel.
  • Runtime arguments must be a JSON object matching payload fields.
  • Extra argument keys are rejected.
  • Both sync and async tools are supported.

Event Stream

run_stream(...) yields these event types:

  • reasoning
  • tool (phase="start" / phase="finish")
  • response
  • task_finished
  • task_failed

reasoning is a step-level decision trace / plan summary, not raw internal chain-of-thought.

Migration (Breaking)

run_task_stream(task, images, context) has been removed.

  • Before: agent.run_task_stream(task=..., images=..., context=...)
  • After: agent.run_stream(messages=[...])

Mapping:

  • task text -> TextMessage(text="...")
  • images -> ImageMessage(image="..." | Path(...) | b"...")
  • context -> include serialized context in TextMessage.text

Documentation

Examples

Notes

  • Public runtime entry point is fabrix.Agent.
  • Execution defaults are fixed internally: max_steps=128 and no public per-tool timeout option.
  • If max_steps is reached and at least one response was emitted, the stream ends with task_finished (completion_reason="max_steps_reached") using the last response.
  • If max_steps is reached before any response/final output, the stream ends with task_failed (error_code="max_steps_reached").

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

fabrix_ai-1.1.0.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

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

fabrix_ai-1.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file fabrix_ai-1.1.0.tar.gz.

File metadata

  • Download URL: fabrix_ai-1.1.0.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fabrix_ai-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9d7057e2bba7befc08612f12eac9e0af56c533ffa592efeeeadcf62b71f07ec2
MD5 1c0e371ed0fc1230bb459df35e237461
BLAKE2b-256 6e8a4f41b6009dd74e77bc047b1a6b1267027914e04108d0e6622b0de6047eca

See more details on using hashes here.

Provenance

The following attestation bundles were made for fabrix_ai-1.1.0.tar.gz:

Publisher: publish-pypi.yml on smturtle2/fabrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fabrix_ai-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: fabrix_ai-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fabrix_ai-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ea800ed5aee08c70d2e812deb7c51f2741a332630076b648bdae4829d8262e7
MD5 13a6a9b50a870e302b923bd1bd8f211c
BLAKE2b-256 a5ae8158bb41e799b4982712f9fef226a5961a7ba108e9e9fefa707cee4d88f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fabrix_ai-1.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on smturtle2/fabrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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