- Zero child processes – fully in-process
- Per-client environment isolation (config + session + tools) for safe parallel use
- Auto-approval of tools by default (configurable)
- Stream rich events or run to completion
- Programmatic agent configs (define in code) or load from file/string
Install / import
Prerequisites: set QODO_API_KEY in your environment (and optional QODO_BASE_URL) so the client can reach the Qodo backend.Quick start (blocking)
Streaming (typed event feed)
Defining agents in code (recommended for libraries)
You can define the agent configuration programmatically with strict types and sensible SDK defaults (execution_strategy defaults to ‘act’).Using agent content strings
Per-call output schema override
You can supply an output_schema per call. Pass either a JSON string (validated) or a structured object (use jsonSchema helper).Session context and resumability
- withSessionIds: Prefetch and inject summaries from previous session IDs (useful for continuity):
- Resuming a specific session: provide flags.sid. If the session is resumable, QodoClient will call resume under the hood.
Working directory and allowed roots
-
cwd (optional): Sets a preferred execution working directory for shell/git tools when their args omit cwd.
- If not provided but agentFile is set, QodoClient defaults cwd = dirname(agentFile).
- If neither is provided, falls back to process.cwd().
- projectRoots (optional): Additional allowed directories for filesystem/ripgrep tools. QodoClient uses [cwd, …projectRoots] for allowed roots.
- You can still override per-tool: pass cwd in shell_execute arguments.
Command and mode selection
QodoClient resolves the run target as follows (priority):- flags.mode → selected as a command equivalent from the agent file
- explicit command name passed to run()/stream()
- flags.command → if provided
- single command in the agent file → if only one exists
Tool approvals
- autoApproveTools (default true) will auto-approve all tool calls (non-interactive, CI-friendly).
- Set autoApproveTools: false to disable auto-approval. Note: the client remains non-interactive; you are responsible for handling any user engagement prompts emitted via messages.
Event reference
QodoClient streams events with this shape:-
init
- data: { protocol: ‘qodo.sdk.v1’, model: string, pid: number }
-
hello
- data: { message: string, mode: ‘sdk’, ready: true }
-
messages
- data: { messages: { langchain: Array<{ type: string; data: any }>, openai: any[] } }
-
progress
- data: any (JSON parsed from assistant progress messages)
-
isLoading
- data: boolean
-
error
- data: { message: string }
-
final
- data: { success: boolean, error?: string, session_id: string, model: string, result: { structured_output?: any; final_output?: string }, messages: { langchain: any[]; openai: any[] }, meta: { tools_auto_approved: boolean; subagents_used: boolean } }
Flags and advanced options
- model: Override the model at construction.
- flags: Arbitrary CLI-style flags supported by the core (e.g., { mode: ‘chat’, tools: ‘shell.exec,ripgrep.search’, noTools: ‘filesystem.*’, sid: ’…’ }).
- mcpFile: Path to an MCP servers file; also supports defining servers in the agent object under mcpServers.
- debug: true to keep internal logs enabled (by default, QodoClient mutes internal logging while streaming).
- debugChatMessages: true to pretty-print AI/chat messages and tool calls to stdout while streaming (useful for debugging agent behavior).
Cancellation and cleanup
Concurrency & isolation
You can safely create multiple QodoClient instances in parallel. Each instance owns its own logical “environment”:- Independent config/session (agent config + SessionContext)
- Its own MessageManager stream
- Its own MCP server registry and MCPManager (tool list, approvals, connection state)
- Backend metadata/cache from ServerData
-
stdout/stderr and global console (unless muted via
debugordebugChatMessages)
Troubleshooting
- If you don’t see progress or messages, ensure your agent emits them and that tools are available. Use debug: true to surface internal logs.
- If you pass a command name and your agent doesn’t contain it, QodoClient falls back to the default/selected command. Double‑check the command list in your agent config.
- For structured outputs, validate your per-call outputSchema. QodoClient validates and will throw if invalid.