A minimal, human-centered Python agent harness for building controllable AI workflows.
Project description
Pyxis
A minimal, human-centered Python agent harness for building controllable AI workflows.
Pyxis is named after the mariner's compass constellation. It is built around a simple idea:
The conversation is the control surface, and the human stays in the loop.
Use Pyxis when you want an agent workflow that can act, but can also pause, explain, resume, stream, record events, save snapshots, and keep risky actions under human control.
What You Get
- A small
Sessionruntime for dialogue, tools, checkpoints, workflows, memory, events, and snapshots. - Controlled tool calls with argument validation before user code runs.
- Human approval through
Checkpointand configurableControlPolicy. - Restorable JSON snapshots through explicit tool and workflow catalogs.
- OpenAI-compatible provider support with common
OPENAI_*environment variables, SSE streaming, usage, finish reasons, retries, timeout, and cancellation. - Stable event schemas for provider, tool, checkpoint, policy, workflow, and restore observability.
- A practical CLI for demo, run, stream, inspect, memory, and workflow smoke tests.
- A PyTorch-like control style: use
navigate()for the default path, or split the turn into analysis, prompt building, provider calls, action dispatch, and response recording.
Install
From this repository:
pip install -e ".[dev]"
When published as a package:
pip install pyxis-ai
Pyxis has no required model SDK dependency.
Try It Locally
Run a no-credential demo:
pyxis demo
Check provider configuration without printing secrets:
pyxis doctor
Run a provider-backed prompt after configuring OPENAI_BASE_URL,
OPENAI_API_KEY, and OPENAI_MODEL:
pyxis run "Plan a simple research workflow"
pyxis run "Draft a concise plan" --stream
pyxis run "Plan a simple research workflow" --save-snapshot session-audit.json
pyxis inspect session-audit.json
CLI defaults to .env.local and .pyxis-memory.json. Both are local-first;
.env.local should hold real credentials and stay out of git.
3-Minute Python Start
from pyxis import Agent, MockProvider, Pyxis
agent = Agent(
name="navigator",
instructions="Help the user move through work calmly and clearly.",
provider=MockProvider(output="Here is a concise plan."),
)
session = Pyxis(agent=agent).session()
result = session.navigate("Plan a controlled research workflow")
print(result.decision)
print(result.output)
Session.navigate() is the main entry point. It records dialogue, asks the
Compass what kind of step is needed, runs the agent when appropriate, and
records observable events.
Write Your Own Loop
The high-level API is only a convenience. Advanced users can control the turn step by step:
analysis = session.analyze("Plan a controlled research workflow")
prompt = session.build_agent_prompt(
"Plan a controlled research workflow",
analysis,
)
if prompt is not None:
agent_result = session.run_agent(
prompt,
context={"decision": analysis.decision.type.value},
)
action = session.parse_action(agent_result.output)
output, metadata = session.dispatch_action(
action,
original_output=agent_result.output,
)
result = session.record_agent_response(
output,
decision=analysis.decision.type.value,
metadata=metadata,
)
This keeps Pyxis convenient like a harness, but flexible like a framework: you can customize prompting, routing, retries, review steps, or UI handoffs without giving up events, checkpoints, policy, or snapshots.
Use A Real Provider
Pyxis works with OpenAI-compatible chat completions APIs through standard environment variables:
export OPENAI_BASE_URL="https://example.com/v1"
export OPENAI_API_KEY="..."
export OPENAI_MODEL="your-model"
import os
from pyxis import Agent, OpenAICompatibleProvider, Pyxis
provider = OpenAICompatibleProvider(
model=os.environ["OPENAI_MODEL"],
max_retries=2,
backoff=0.5,
)
agent = Agent(name="navigator", provider=provider)
session = Pyxis(agent=agent).session()
result = session.navigate("Plan a simple research workflow")
print(result.output)
Streaming uses the same session:
for event in session.stream("Draft a concise plan"):
if event.type == "delta":
print(event.data["text"], end="")
Add A Controlled Tool
Tools are normal Python callables with explicit risk and action metadata. Pyxis validates arguments before executing the function.
from pyxis import Agent, Pyxis, tool
@tool(risk="high", action="file_write")
def write_file(path: str, content: str) -> str:
"""Pretend to write content to a file."""
return f"would write {len(content)} characters to {path}"
session = Pyxis(agent=Agent(name="navigator", tools=[write_file])).session()
result = session.call_tool("write_file", "notes.txt", content="hello")
if result.requires_confirmation:
checkpoint = result.checkpoint
print(checkpoint.summary)
print(checkpoint.preview)
High-risk actions pause by default. The host application can approve, reject, persist, inspect, or render the checkpoint.
Save And Restore A Session
Snapshots are JSON-safe, versioned, and optionally redacted:
from pyxis import SnapshotRedactionPolicy
policy = SnapshotRedactionPolicy(redact_keys={"api_key", "customer_email"})
session.save_snapshot("session-audit.json", redact=True, redaction_policy=policy)
Restore is explicit. Snapshots never import arbitrary Python code:
from pyxis import SnapshotRestoreCatalog, load_snapshot, restore_session
snapshot = load_snapshot("session-audit.json")
restored = restore_session(
snapshot,
catalog=SnapshotRestoreCatalog(tools={"write_file": write_file}),
)
Pending tool calls and workflows can resume after their callables are registered by name.
Observe What Happened
Every session has an append-only event log:
for event in session.events:
print(event.type, event.payload)
Use EVENT_SCHEMAS when building a UI, audit exporter, or test harness that
needs stable payload contracts.
CLI Cheat Sheet
pyxis demo
pyxis doctor
pyxis run "Plan a simple research workflow"
pyxis run "Draft a concise plan" --stream
pyxis run "..." --approve
pyxis inspect session-audit.json
pyxis memory show
pyxis memory clear
pyxis workflow demo
Examples
PYTHONPATH=src python3 examples/pi_like_guided_planning.py
PYTHONPATH=src python3 examples/basic_openai_compatible.py
PYTHONPATH=src python3 examples/agent_tool_call.py
examples/pi_like_guided_planning.py does not need provider credentials. The
OpenAI-compatible examples read .env.local; that file is ignored by git.
Documentation
Start here:
- API Reference: stable public API and compatibility policy.
- Cookbook: small composable usage patterns.
- Control Flow Guide: use the default
navigate()path or write your own loop. - Tool Authoring Guide: tools, validation, policy, and restore expectations.
- Provider Guide: provider contracts, streaming, timeout, cancellation, and errors.
- Safety And Control: policy modes, deny lists, risk overrides, and checkpoint options.
- Migration Guide: moving early MVP code to the 1.0 contract.
Concept docs:
Chinese entry point:
Design Principles
Pyxis stays small at the center:
- no hidden autonomous loop
- no required vector database
- no forced web framework
- no provider-specific logic in session orchestration
The core job is to make agent work navigable: visible decisions, controlled actions, resumable state, and enough structure for people to stay oriented.
Status
Pyxis is preparing the 1.0.0 release line. The 1.0 contract focuses on a
stable public API, controlled tools, restorable snapshots, provider streaming,
policy/consent semantics, event observability, CLI workflows, and synchronized
documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyxis_ai-1.0.0.tar.gz.
File metadata
- Download URL: pyxis_ai-1.0.0.tar.gz
- Upload date:
- Size: 64.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f24babbfcf2680388393f8784b1895ca3745ca2904af2b75133cdc654624891
|
|
| MD5 |
3ab223844f4ab7197abefcbf4e17a1b7
|
|
| BLAKE2b-256 |
84e3a6b9cb0d473fecec88a95223d68a13bf27812c2867bdb0ae591aadb8ff84
|
File details
Details for the file pyxis_ai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pyxis_ai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 40.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98c51e23a70e34b234f5b5790644a83c526d1b852f5290f4cd3724812f4a022e
|
|
| MD5 |
2b243bffe6b4654c63ae62ae0c65d3b6
|
|
| BLAKE2b-256 |
a4e14a3bdf1400adc8cf30366f1c1e142962f0d1d5de1b1c64c5874e0b135f7b
|