Modern C++20 SDK for building applications that control Autohand code agents through the Autohand CLI JSON-RPC mode.
Documentation: https://autohand.ai/docs/agent-sdk/
Beta: this SDK is actively evolving while the Agent SDK APIs stabilize. Pin versions in production and review release notes before upgrading.
The C++ SDK wraps the existing Autohand CLI process and exposes a small host-friendly API:
C++ app -> autohand::sdk -> Autohand CLI subprocess -> provider -> model
Use it when you want Autohand inside native developer tools, editors, desktop apps, automation services, or CI utilities without reimplementing the CLI agent protocol.
- C++20 API with value-oriented configuration
- CMake target:
autohand::sdk - CLI subprocess transport over JSON-RPC 2.0
- Typed event helpers for message deltas, tools, permissions, and errors
- High-level
AgentandRunworkflow - Low-level
AutohandSdkcontrol methods - Structured JSON extraction helper
- Example parity with the TypeScript SDK examples
- C++20 compiler
- CMake 3.22 or later
- POSIX runtime for the initial transport implementation
- Autohand CLI installed and authenticated
- A configured provider in
~/.autohand/config.json, or environment variables accepted by the CLI
Set AUTOHAND_CLI_PATH when you want to force a local CLI binary:
export AUTOHAND_CLI_PATH=/path/to/autohandUse the repository as a CMake dependency:
include(FetchContent)
FetchContent_Declare(
autohand_sdk
GIT_REPOSITORY https://github.com/autohandai/code-agent-sdk-cpp.git
GIT_TAG main
)
FetchContent_MakeAvailable(autohand_sdk)
target_link_libraries(my_app PRIVATE autohand::sdk)#include <autohand/sdk.hpp>
#include <iostream>
int main() {
autohand::Agent agent(
autohand::Config::from_environment()
.with_cwd(".")
.with_instructions("Review code with senior C++ judgement."));
auto run = agent.send("Review this repository for release readiness.");
run.stream([](const autohand::SdkEvent& event) {
if (event.type == "message_update") {
std::cout << event.text_delta();
} else if (event.type == "permission_request") {
std::cerr << "\npermission requested: " << event.description() << "\n";
}
});
auto result = run.wait();
std::cout << "\nRun " << result.id << " finished with " << result.status << "\n";
}Use AutohandSdk when your host needs direct access to the JSON-RPC control surface:
#include <autohand/sdk.hpp>
#include <iostream>
int main() {
autohand::AutohandSdk sdk(autohand::Config::from_environment().with_cwd("."));
sdk.start();
sdk.set_plan_mode(true);
sdk.stream_prompt("Create a discovery plan for this SDK change.", [](const autohand::SdkEvent& event) {
std::cout << event.type << "\n";
});
sdk.stop();
}The examples/ directory mirrors the TypeScript SDK example inventory:
01-hello-agent.cpp02-streaming-query.cpp03-code-reviewer.cpp04-bash-command.cpp05-file-editor.cpp06-prompt-skills.cpp07-direct-skills.cpp08-memory-management.cpp10-multi-tool-reasoning.cpp13-permissions.cpp20-sdlc-discovery-plan.cpp21-sdlc-gated-implementation.cpp22-sdlc-release-readiness.cpp23-system-prompts.cpp24-high-level-agent.cpp25-structured-json.cppbasic-agent.cppbasic-usage.cpploop-strategies.cpppermission-handling.cppsdk-control-features.cppstreaming.cpp
Build and run an example:
cmake -S . -B build -DAUTOHAND_BUILD_EXAMPLES=ON
cmake --build build --target example_01_hello_agent
./build/example_01_hello_agentLive examples require an authenticated Autohand CLI and may ask for tool permissions depending on your CLI configuration.
- Getting Started
- API Reference
- Configuration
- Event Streaming
- Permissions
- Plan Mode
- SDLC Workflows
- Error Handling
- Examples
- Contributing
- Security
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DAUTOHAND_BUILD_TESTS=ON -DAUTOHAND_BUILD_EXAMPLES=ON
cmake --build build
ctest --test-dir build --output-on-failureThe transport tests use a deterministic fake CLI, so the unit suite does not require model credentials.
- SDK docs: https://autohand.ai/docs/agent-sdk/
- Issues: https://github.com/autohandai/code-agent-sdk-cpp/issues
- Security reports: security@autohand.ai