Minimal, debuggable agent framework for explicit pipelines and computation graphs.
Project description
A minimal, debuggable agent framework for building explicit pipelines and computation graphs. ThinkAgain captures execution plans before they run so you can reason about complex control flow without hidden state.
Why ThinkAgain?
- Composable – Workers and graphs compose naturally with
>>operator - Transparent –
Contextcarries state and execution history;graph.visualize()shows your pipeline - Debuggable – Stream execution events, inspect history, and export plans as data
- Simple – Just Python classes; no DSLs or hidden orchestration layers
- Async-first – Native async support with sync wrappers when needed
Core Concepts
- Worker – Implement your logic; subclass and define
__call__orarun - Graph – Connect workers with edges; supports routing and cycles
- Context – Dict-like container that flows through your pipeline, tracking history
- Executable – Base interface that enables
>>composition
Installation
pip install thinkagain
# or with uv
uv add thinkagain
Quick Start
Sequential pipelines with the >> operator:
from thinkagain import Context, Worker
class Retriever(Worker):
async def arun(self, ctx: Context) -> Context:
ctx.documents = await self.search(ctx.query)
return ctx
pipeline = Retriever() >> Reranker() >> Generator()
ctx = await pipeline.arun(Context(query="What is ML?"))
print(ctx.answer)
Graphs with routing and cycles:
from thinkagain import Graph, END
graph = Graph(name="self_correcting_rag")
graph.add_node("retrieve", Retriever())
graph.add_node("generate", Generator())
graph.add_node("critique", Critic())
graph.set_entry("retrieve")
graph.add_edge("retrieve", "generate")
graph.add_conditional_edge(
"generate",
route=lambda ctx: "done" if ctx.quality >= 0.8 else "critique",
paths={"done": END, "critique": "critique"},
)
graph.add_edge("critique", "retrieve") # retry loop
ctx = await graph.arun(Context(query="What is ML?"))
Decorator syntax for simple workers:
from thinkagain import async_worker
@async_worker
async def fetch(ctx: Context) -> Context:
ctx.data = await ctx.client.get(ctx.url)
return ctx
pipeline = fetch >> process
Examples
Run the demo to see pipelines, graphs, and visualization:
python examples/minimal_demo.py
OpenAI-Compatible Server
Optional server with OpenAI-compatible /v1/chat/completions endpoint:
pip install "thinkagain[serve]"
# or with uv
uv pip install -e ".[serve]"
# Start server
python -m thinkagain.serve.openai.serve_completion
See thinkagain/serve/README.md for details.
Learn More
- ARCHITECTURE.md – design rationale
- DESIGN.md – control-flow primitives and roadmap
- examples/ – working demos
License
Apache 2.0 – see LICENSE
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 thinkagain-0.1.1.tar.gz.
File metadata
- Download URL: thinkagain-0.1.1.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9480a0600574481a00a81664a1ed6f671026ade5219891f4714e5cd14c860e98
|
|
| MD5 |
3079d0e53100def4f5c1e69f5cfde612
|
|
| BLAKE2b-256 |
28a75d0fe843eab05eaf8ab52d044fe08bad09a7674e1bed0a080cbf2398bfcd
|
File details
Details for the file thinkagain-0.1.1-py3-none-any.whl.
File metadata
- Download URL: thinkagain-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73781adeae96249fbbf89b6405173ee6fe44c7961878021e3a86e2a3fb382bad
|
|
| MD5 |
076ab44c7e709df316f172901c2aea58
|
|
| BLAKE2b-256 |
c706a63a3085da4f0cd90e11966cc92919b3ddbb2b1138176bdd4edb11cd6518
|