Loading repository data…
Loading repository data…
xynehq / repository
Functional Python agent framework with MCP support, enterprise security, immutable state, and production-ready observability for building scalable AI systems.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A purely functional agent framework with immutable state and composable tools, professionally converted from TypeScript to Python. JAF enables building production-ready AI agent systems with built-in security, observability, and error handling.
Production Ready: Complete feature parity with TypeScript version, comprehensive test suite, and production deployment support.
Get Started → | API Reference → | Examples →
/docs# Install from GitHub (development version)
pip install git+https://github.com/xynehq/jaf-py.git
# Or install with all optional dependencies
pip install "jaf-py[all] @ git+https://github.com/xynehq/jaf-py.git"
# Install specific feature sets
pip install "jaf-py[server] @ git+https://github.com/xynehq/jaf-py.git" # FastAPI server support
pip install "jaf-py[memory] @ git+https://github.com/xynehq/jaf-py.git" # Redis/PostgreSQL memory providers
pip install "jaf-py[visualization] @ git+https://github.com/xynehq/jaf-py.git" # Graphviz visualization tools
pip install "jaf-py[tracing] @ git+https://github.com/xynehq/jaf-py.git" # OpenTelemetry and Langfuse tracing
pip install "jaf-py[dev] @ git+https://github.com/xynehq/jaf-py.git" # Development tools
JAF includes a powerful CLI for project management:
# Initialize a new JAF project
jaf init my-agent-project
# Run the development server
jaf server --host 0.0.0.0 --port 8000
# Show version and help
jaf version
jaf --help
git clone https://github.com/xynehq/jaf-py
cd jaf-py
pip install -e ".[dev]"
# Run tests
pytest
# Type checking and linting
mypy jaf/
ruff check jaf/
black jaf/
# Documentation
pip install -r requirements-docs.txt
./docs.sh serve # Start documentation server
./docs.sh deploy # Deploy to GitHub Pages
The complete, searchable documentation is available at xynehq.github.io/jaf-py with:
For offline access, documentation is also available in the docs/ directory:
jaf-py/
├── docs/ # Complete documentation
├── jaf/ # Core framework package
│ ├── core/ # Core types and engine
│ ├── memory/ # Conversation persistence
│ ├── providers/ # External integrations (LiteLLM, MCP)
│ ├── policies/ # Validation and security
│ ├── server/ # FastAPI server
│ └── cli.py # Command-line interface
├── examples/ # Example applications
└── tests/ # Test suite
JAF includes powerful visualization capabilities to help you understand and document your agent systems.
First, install the system Graphviz dependency:
# macOS
brew install graphviz
# Ubuntu/Debian
sudo apt-get install graphviz
# Windows (via Chocolatey)
choco install graphviz
Then install JAF with visualization support:
pip install "jaf-py[visualization]"
import asyncio
from jaf import Agent, Tool, generate_agent_graph, GraphOptions
# Create your agents
agent = Agent(
name='MyAgent',
instructions=lambda state: "I am a helpful assistant.",
tools=[my_tool],
handoffs=['OtherAgent']
)
# Generate visualization
async def main():
result = await generate_agent_graph(
[agent],
GraphOptions(
title="My Agent System",
output_path="./my-agents.png",
color_scheme="modern",
show_tool_details=True
)
)
if result.success:
print(f" Visualization saved to: {result.output_path}")
else:
print(f"❌ Error: {result.error}")
asyncio.run(main())
default, modern, or minimal themesdot, circo, neato, etc.)The visualization system generates clear, professional diagrams showing:
from jaf.visualization import run_visualization_examples
# Run comprehensive examples
await run_visualization_examples()
# This generates multiple example files:
# - ./examples/agent-graph.png (agent system overview)
# - ./examples/tool-graph.png (tool ecosystem)
# - ./examples/runner-architecture.png (complete system)
# - ./examples/agent-modern.png (modern color scheme)
from dataclasses import dataclass
from pydantic import BaseModel, Field
from jaf import Agent, Tool, RunState, run
# Define your context type
@dataclass
class MyContext:
user_id: str
permissions: list[str]
# Define tool schema
class CalculateArgs(BaseModel):
expression: str = Field(description="Math expression to evaluate")
# Create a tool
class CalculatorTool:
@property
def schema(self):
return type('ToolSchema', (), {
'name': 'calculate',
'description': 'Perform mathematical calculations',
'parameters': CalculateArgs
})()
async def execute(self, args: CalculateArgs, context: MyContext) -> str:
result = eval(args.expression) # Don't do this in production!
return f"{args.expression} = {result}"
# Define an agent
def create_math_agent():
def instructions(state):
return 'You are a helpful math tutor'
return Agent(
name='MathTutor',
instructions=instructions,
tools=[CalculatorTool()]
)
import asyncio
from jaf import run, make_litellm_provider, generate_run_id, generate_trace_id
from jaf.core.types import RunState, RunConfig, Message
async def main():
model_provider = make_litellm_provider('http://localhost:4000')
math_agent = create_math_agent()
config = RunConfig(
agent_registry={'MathTutor': math_agent},
model_provider=model_provider,
max_turns=10,
on_event=lambda event: print(event), # Real-time tracing
)
initial_state = RunState(
run_id=generate_run_id(),
trace_id=generate_trace_id(),
messages=[Message(role='user', content='What is 2 + 2?')],
current_agent_name='MathTutor',
context=MyContext(user_id='user123', permissions=['user']),
turn_count=0,
)
result = await run(initial_state, config)
print(result.outcome.output if result.outcome.status == 'completed' else result.outcome.error)
asyncio.run(main())
from jaf.policies.validation