Agent workflows implemented as pure logic, runtime adapters, and thin API wrappers — cleanly separated for testability and reuse.
AbstractAgent separates concerns into three clean layers, making each independently testable and replaceable.
src/abstractagent/logic/)WorkflowSpec with durable EffectType.* steps (src/abstractagent/adapters/)BaseAgent + concrete agents (src/abstractagent/agents/)Three agent patterns, durable execution, and production controls.
Reason + Act loop. The LLM observes, thinks, picks a tool, observes the result, and repeats until it has an answer. The classic agentic pattern.
The LLM writes Python code blocks to accomplish tasks. Code is extracted and executed in a sandboxed subprocess with configurable timeout.
ReAct extended with durable session memory. The agent persists knowledge across runs using runtime memory spans and knowledge graph edges.
Every agent iteration is checkpointed by AbstractRuntime. Runs survive process restarts. Resume mid-conversation or mid-tool-execution.
Configurable ToolApprovalPolicy gates dangerous operations. Safe tools auto-execute; mutations pause for human approval before proceeding.
Agents enforce a configurable iteration limit (default 50). When reached, the agent concludes with its best answer rather than looping indefinitely.
CodeAct runs Python in a local subprocess sandbox with timeout. execute_python tool with configurable security boundaries.
Agents can delegate subtasks to other agents via the built-in delegate_agent tool, enabling hierarchical multi-agent workflows.
All LLM calls, tool executions, and decisions are logged to the append-only ledger. Replay any agent run from history for debugging.
Create an agent in a few lines and run it against any provider.
pip install abstractagentfrom abstractagent.agents.react import create_react_agent
agent = create_react_agent(
provider="openai",
model="gpt-4o-mini",
)
result = agent.run("What is the capital of France?")
print(result)from abstractagent.agents.codeact import create_codeact_agent
agent = create_codeact_agent(
provider="ollama",
model="qwen3:4b",
)
result = agent.run("Write a function that computes fibonacci numbers, then compute fib(10).")
print(result)from abstractagent.agents.memact import create_memact_agent
agent = create_memact_agent(
provider="anthropic",
model="claude-haiku-4-5",
)
# Memory persists across runs in the same session
result = agent.run("My name is Alice and I work at Acme Corp.")
result = agent.run("Where do I work?")
print(result) # Recalls from session memoryfrom abstractcore import tool
from abstractagent.agents.react import create_react_agent
@tool
def lookup_user(user_id: str) -> str:
"""Look up user details by ID."""
return f"User {user_id}: Alice, Engineering"
agent = create_react_agent(
provider="openai",
model="gpt-4o-mini",
tools=[lookup_user],
)
result = agent.run("Look up user #42 and summarize their info.")
print(result)Package structure, imports, and key components.
# Agent constructors
from abstractagent.agents.react import ReactAgent, create_react_agent
from abstractagent.agents.codeact import CodeActAgent, create_codeact_agent
from abstractagent.agents.memact import MemActAgent, create_memact_agent
# Base agent (for custom agents)
from abstractagent.agents.base import BaseAgent
# Runtime-agnostic logic (prompting + parsing)
from abstractagent.logic.react import ReActLogic
from abstractagent.logic.codeact import CodeActLogic
from abstractagent.logic.memact import MemActLogic
# Runtime workflow adapters
from abstractagent.adapters.react_runtime import create_react_workflow
from abstractagent.adapters.codeact_runtime import create_codeact_workflow
from abstractagent.adapters.memact_runtime import create_memact_workflow| Pattern | How It Works | Best For |
|---|---|---|
| ReAct | Think → select tool → observe result → repeat | General-purpose agentic tasks, information retrieval, multi-step reasoning |
| CodeAct | Generate Python code → execute in sandbox → observe output | Data analysis, computation, file manipulation, automation scripts |
| MemAct | ReAct + durable session memory & knowledge graph | Long-running assistants, cross-session context, personalization |
abstractruntime imports in logic/WorkflowSpec with durable EffectType.* stepsBaseAgent handles lifecycle, persistence, ledger accessabstractagent.agents.memact