Overview
AgentCtrl provides a unified interface for executing prompts against CLI-based code agents (like Claude Code, OpenCode, Codex, etc.). This example demonstrates the simplest possible usage: sending a prompt and receiving a structured response with metadata. Key concepts:AgentCtrl::make(): Factory for creating agent instancesAgentType: Enum specifying which CLI agent to useAgentResponse: Structured response with text, session info, usage stats, and cost
Example
Expected Output
Key Points
- Unified interface: Same API works across different CLI agents
- Agent selection: Use
AgentTypeenum to specify which agent to use - Response metadata: Access session IDs, token usage, and cost information
- Error handling: Check
isSuccess()before accessing response data - Simple execution: One method call (
execute()) handles the entire interaction