Skip to content
HendrikRehPublic

About

PoC: Planner/executor agent proof-of-concept for OCaml inspired by LangGraph: modular library, Cmdliner CLI, Lwt-powered memory, OpenAI client, and dune-based tests for scripting multi-step goals.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

31 Commits

Folders and files

Repository files navigation

OCaml Agents (PoC)

OCaml Status Build Status License PRs Welcome Maintenance

A LangGraph-inspired planner/executor agent system implemented in OCaml using Lwt for asynchronous execution.

Installation • Usage • Architecture • Development • Contributing

Dependencies Platform Code Style LangGraph Inspired

Features

  • 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

Installation

Prerequisites

  • OCaml >= 5.1
  • opam package manager
  • An OpenAI API key

Setup

  1. Clone the repository:
git clone https://github.com/HendrikReh/agents.git
cd agents
  1. Install dependencies:
opam install . --deps-only
  1. Build the project:
dune build
  1. Create a .env file with your OpenAI API key:
echo "OPENAI_API_KEY=your-api-key-here" > .env

Usage

Run the agent with a goal:

dune exec agents -- --goal "Research the latest developments in quantum computing"

Command Line Options

  • --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)

Architecture

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

Development

Testing

  • 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.

Local CI Testing with act

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.x

Note: 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.

Code Formatting

Once .ocamlformat is configured:

dune fmt

Watch Mode

For development with automatic rebuilding:

dune build --watch

Contributing

Please see GUIDELINES.md for detailed contribution guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Version Experimental Made with OCaml Powered by OpenAI Last Commit Issues Stars

About

PoC: Planner/executor agent proof-of-concept for OCaml inspired by LangGraph: modular library, Cmdliner CLI, Lwt-powered memory, OpenAI client, and dune-based tests for scripting multi-step goals.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages