Agentic Workflow Orchestrator
The Problem
Most LLM applications are single-shot: one prompt, one answer. But real-world tasks — competitive research, code generation, multi-step planning — require an agent that can reason, use tools, spawn sub-agents, and recover from errors. LangChain's simple agent loop wasn't enough.
I needed a framework that could express complex, stateful workflows as a graph — with branching, looping, parallelism, and human-in-the-loop checkpoints built in from the start.
The Architecture
The orchestrator is built on LangGraph, which represents agent workflows as directed graphs of nodes (LLM calls, tool invocations, conditional routers) and edges (transitions). State flows through the graph, accumulating context and results.
Key Engineering Decisions
- Graph-based state machine — LangGraph's `StateGraph` lets me express conditional branching (e.g. "if the Critic scores below 7/10, send back to Planner") as first-class edges, not ad-hoc if/else in agent logic.
- Persistent checkpointing — Every node transition is checkpointed to Redis. If the workflow fails mid-execution (network error, rate limit), it resumes from the last checkpoint rather than restarting.
- Tool isolation via sandboxing — The Coder agent runs generated Python in a restricted Docker sandbox with no network access and a 30s timeout, preventing runaway or malicious code.
- Human-in-the-loop nodes — Critical decisions (e.g. sending an email, committing code) pause the graph and POST to a webhook, waiting for human approval before continuing. Timeout after 24h auto-rejects.
- Parallel fan-out — The Researcher agent spawns N parallel sub-agents for simultaneous web searches, joins their results, and deduplicates before passing upstream.
Outcome
The orchestrator now powers three internal products: an automated competitive intelligence digest, a code review + PR description generator, and a tender response drafting tool. Average task completion time is 5× faster than the previous manual process.