A C++ project for learning how to build an AI agent harness, starting with a local language model connection.
- Interactive terminal interface.
- Local model responses through Ollama.
- HTTP requests using libcurl.
- JSON serialization and parsing using nlohmann/json.
- Empty-input validation and an
exitcommand. - Connection and request timeouts.
- Request error handling that keeps the terminal session running.
- Read-only workspace file access through
/read <path>. - File questions through
/askfile <path> <question>. - Workspace boundary checks that reject absolute paths and paths outside the project.
The current version keeps recent conversation history and supports read-only workspace commands. An autonomous tool execution loop is planned.
- macOS with Xcode or Command Line Tools
- Git
- CMake
- A C++20 compiler
- libcurl development files
- nlohmann/json
- Ollama
Development has been tested on a Mac with an Apple A18 Pro chip and 8 GB of memory.
Install the dependencies with Homebrew:
brew install cmake nlohmann-json ollamaThe development setup uses libcurl provided by the installed Apple developer tools.
Clone and build:
git clone https://github.com/bonigo1998/agentforge-cpp.git
cd agentforge-cpp
cmake -S . -B build -DCMAKE_PREFIX_PATH="$(brew --prefix nlohmann-json)"
cmake --build buildStart Ollama in one terminal with cloud features disabled:
OLLAMA_NO_CLOUD=1 ollama serveLeave that terminal open.
In a second terminal, download the model:
ollama pull qwen3:1.7bFrom the project folder, start AgentForge:
./build/agentforgeEnter a task such as:
Explain what a C++ class is in two short sentences.
Type exit to quit AgentForge.
Model inference runs locally and requires no API key or paid API usage. Internet access is needed for the initial software and model downloads.
Read a file directly in the terminal:
/read README.md
Ask the local model a question using a file:
/askfile README.md Summarize this project in one sentence.
Use /clear to remove conversation history and exit to quit.
File paths must be relative to the directory where AgentForge starts. Absolute paths and paths that escape the workspace are rejected.
- Model:
qwen3:1.7b - Endpoint:
http://127.0.0.1:11434/api/chat - Context window: 2,048 tokens
- Maximum generated response: 128 tokens
- Connection timeout: 5 seconds
- Total request timeout: 180 seconds
Responses that reach the output limit are marked as shortened.
- Create a C++20 project with CMake.
- Build an interactive command loop.
- Separate the interface and model client.
- Connect to a local model.
- Add conversation history.
- Define and validate tool requests.
- Implement workspace file tools.
- Add an agent tool execution loop with step limits.
- Add automated tests and execution logs.
Focused improvements and bug reports are welcome. Pull requests should explain the change and how it was verified.