Show HN: Agex – An agent framework that lives in your Python runtime
ashenfad.github.io
ashenfad.github.io
Its closest relative is Hugging Face's excellent `smol-agents`. While both "think-in-code", `agex` focuses on interoperability, allowing agents to receive and return complex Python objects like DataFrames, Plotly figures, or even callables.
For example:
import math
from typing import Callable
from agex import Agent
agent = Agent(primer="You are an expert at writing small, useful functions.")
# Equip the agent with the math module
agent.module(math)
# The fn sig is the contract; the agent provides the implementation at runtime
@agent.task
def build_function(prompt: str) -> Callable:
"""Build a callable function from a text prompt."""
pass
# The agent returns a real, callable Python function, not a JSON blob
is_prime = build_function("a function that checks if a number is prime")
# You can use it immediately
print(f"Is 13 prime? {is_prime(13)}")
# > Is 13 prime? True
From the agent's point-of-view, it lives in a Python REPL with its own stdout, allowing it to inspect data, see errors, and self-correct. An agent's REPL is persisted across tasks, so it can build its own helpers and improve over time.Highlights:
* Code-as-Action: AST-style Python sandbox for agent actions.
* Library Integration: Plug into libraries rather than tools (& skip the JSON).
* Workspace Persistence: Git-like versioning for agent state (w/ time-travel debugging).
* Multi-Agent: Orchestrate agents with natural Python control flow.
* Observability: Real-time, notebook-friendly event streams.
* Benchmarking: A framework for data-driven agent evaluation.
The project is early stage but the core concepts are stabilizing. I'm hoping to find a few brave souls to kick the tires. Feedback is welcome.GitHub: https://github.com/ashenfad/agex
Docs & Examples: https://ashenfad.github.io/agex/