A LangGraph-inspired planner/executor agent system implemented in OCaml using Lwt for asynchronous execution.
Installation • Usage • Architecture • Development • Contributing
- Modular Architecture: Clean separation between planning, execution, and memory components
- Asynchronous Execution: Built on Lwt for non-blocking operations
- Flexible Planning: Support for actions, branching, loops, and conditional execution
- Extensible Tools: Easy to add new tools and integrations
- Type-Safe: Leverages OCaml's strong type system for reliability
- OCaml >= 5.1
- opam package manager
- An OpenAI API key
- Clone the repository:
git clone https://github.com/HendrikReh/agents.git
cd agents- Install dependencies:
opam install . --deps-only- Build the project:
dune build- Create a
.envfile with your OpenAI API key:
echo "OPENAI_API_KEY=your-api-key-here" > .envRun the agent with a goal:
dune exec agents -- --goal "Research the latest developments in quantum computing"--goal: The goal/task for the agent to accomplish (required)--max-cycles: Maximum planning cycles (default: 4)--model: OpenAI model to use (default: gpt-5)
The system consists of several key modules:
- Agent: Main orchestration module that coordinates planning and execution
- Planner: Generates execution plans based on goals and current state
- Executor: Executes plans, handling actions, branches, and loops
- Memory: Manages agent state and variables
- Nodes: Defines the plan structure (actions, branches, loops, etc.)
- OpenAI Client: Handles LLM API interactions
- Tools: Utility functions for the agent system
dune runtest– runs the full Alcotest suite (all cases are fast/deterministic).ALCOTEST_QUICK_TESTS=1 dune runtest– run only tests marked as quick (current default).ALCOTEST_VERBOSE=1 dune runtest– stream captured output to the terminal for debugging.
The suite stubs every OpenAI call, so no network access or API keys are needed. Recent additions exercise planner schema failures (including missing plan fields), executor loop bounds/unsupported tools, and memory persistence error handling to guard common edge cases.
Test GitHub Actions workflows locally using act:
# Install act
brew install act # macOS
# or: curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash
# Run the lint job locally
act push -j lint \
-P ubuntu-latest=catthehacker/ubuntu:act-latest \
--container-architecture linux/amd64
# Run a specific matrix job
act push -j build --matrix os=ubuntu-latest,ocaml-compiler=5.2.xNote: The OCaml setup action (setup-ocaml@v3) is automatically skipped when running under act due to Node.js version incompatibility. The workflow will succeed with informational output. For full integration testing, push to a branch and let GitHub Actions run.
See docs/DEVELOPER.md for detailed configuration and troubleshooting.
Once .ocamlformat is configured:
dune fmtFor development with automatic rebuilding:
dune build --watchPlease see GUIDELINES.md for detailed contribution guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.