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
Metadata
Release files for thinkagain 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| thinkagain-0.1.1.tar.gz | 28.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thinkagain-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.6 kB
Release files / thinkagain-0.1.1.tar.gz
| Download URL | thinkagain-0.1.1.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9480a0600574481a00a81664a1ed6f671026ade5219891f4714e5cd14c860e98
|
|
BLAKE2b-256 checksum How to use checksums |
28a75d0fe843eab05eaf8ab52d044fe08bad09a7674e1bed0a080cbf2398bfcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / thinkagain-0.1.1-py3-none-any.whl
| Download URL | thinkagain-0.1.1-py3-none-any.whl |
|---|---|
| Size | 34.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73781adeae96249fbbf89b6405173ee6fe44c7961878021e3a86e2a3fb382bad
|
|
BLAKE2b-256 checksum How to use checksums |
c706a63a3085da4f0cd90e11966cc92919b3ddbb2b1138176bdd4edb11cd6518
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|