CLI Agent Models
Run Claude Code or Codex as your agent's model for long-running, tool-driven agentic tasks.
Why Use CLI Agent Models
A chat completion answers one prompt in one pass. Some tasks need more: researching a topic across your knowledge bases, iterating on generated files, or working through a multi-step plan that calls tools dozens of times. Squeezing that into single completions means orchestrating every step yourself.
CLI agent models put a full agentic CLI, Claude Code or Codex, behind the same agent API you already use. Squid runs the CLI server-side in an isolated session; the CLI plans, invokes your agent's tools, and iterates until the task is done:
await squid.ai().agent('research-assistant').updateModel('claude-code');
const jobId = crypto.randomUUID();
await squid.ai().agent('research-assistant').askAsync('Compare our Q1 and Q2 sales data and summarize the trends', jobId);
// An askAsync job resolves with the agent's answer as a plain string.
const answer = await squid.job().awaitJob<string>(jobId);
Overview
CLI agent models are selected exactly like vendor models: pass the model name to upsert(), updateModel(), or the model ask option (see Building AI agents). Instead of calling a chat completions API, Squid launches the corresponding CLI in a sandboxed session, forwards your agent's instructions and tools, and returns the CLI's final response.
Available models
| Model name | Provider CLI | Runs | Context window |
|---|---|---|---|
claude-code | Claude Code | The CLI's default model tier | 200K tokens |
claude-code-opus | Claude Code | The latest Opus tier | 200K tokens |
claude-code-sonnet | Claude Code | The latest Sonnet tier | 200K tokens |
claude-code-haiku | Claude Code | The latest Haiku tier | 200K tokens |
codex | Codex | The CLI's default model | 272K tokens |
codex-gpt-5.5 | Codex | GPT-5.5 | 272K tokens |
codex-gpt-5.4 | Codex | GPT-5.4 | 272K tokens |
codex-gpt-5.4-mini | Codex | GPT-5.4 Mini | 272K tokens |
codex-gpt-5.3-codex | Codex | GPT-5.3 Codex | 272K tokens |
Claude Code tiers track the latest model of each tier automatically; the Codex variants pin specific models. All CLI agent models support up to 64K output tokens.
When to use a CLI agent model
| Use Case | Recommendation |
|---|---|
| Multi-step tasks that chain many tool calls | CLI agent model |
| Long-running research or analysis (minutes of work) | CLI agent model with askAsync() + jobs |
| Fast conversational responses with token streaming | A vendor chat model (e.g. 'claude-sonnet-4-6', 'gpt-5.5') |
| Simple Q&A over a knowledge base | A vendor chat model with knowledge bases |
How it works
- You select a CLI agent model for your agent and send an ask
- Squid starts an isolated CLI session server-side, passing your agent's instructions
- The agent's AI functions, connected integrations, and knowledge bases are exposed to the CLI as MCP tools
- The CLI plans, calls tools, and iterates until the task completes; the ask runs as a long-running job
- The final response is returned; conversation state persists in the CLI session for follow-up asks
Quick Start
Step 1: Add the provider API key
CLI agent models use your own provider API key, configured under Settings > AI Settings in the Squid Console:
- Claude Code models require an Anthropic API key
- Codex models require an OpenAI API key
Step 2: Select the model
await squid.ai().agent('research-assistant').updateModel('claude-code');
Or override per-request with the model ask option.
Step 3: Ask, and track the run as a job
CLI agent runs can take minutes, so avoid holding a single request open. Pass a job ID and await it through the jobs API:
const jobId = crypto.randomUUID();
await squid.ai().agent('research-assistant').askAsync('Audit our onboarding docs for outdated steps', jobId);
// Optionally, observe interim progress (tool calls, status messages).
const statusSubscription = squid
.ai()
.agent('research-assistant')
.observeStatusUpdates(jobId)
.subscribe((status) => console.log(status));
// An askAsync job resolves with the agent's answer as a plain string.
const answer = await squid.job().awaitJob<string>(jobId);
statusSubscription.unsubscribe();
Core Concepts
Long-running execution
Every CLI agent ask runs as a long-running job, with a default and maximum wall time of 30 minutes. To bound a run more tightly, set quotas.maxRuntimeSeconds in the ask options (clamped between 30 seconds and 30 minutes):
await squid
.ai()
.agent('research-assistant')
.askAsync('Summarize the support tickets from this week', jobId, {
quotas: { maxRuntimeSeconds: 300 },
});
maxRuntimeSeconds is ignored for non-CLI-agent models.
Sessions and conversation memory
Conversation state lives in the CLI's own session, which Squid persists and resumes across asks according to the agent's memory options. Because the CLI manages its own transcript, the conversation does not appear in Squid's chat history APIs.
Switching between variants of the same provider (for example claude-code to claude-code-opus) resumes the same session, so a conversation can continue across model tiers.
One ask runs at a time per agent conversation. A concurrent ask for the same conversation is rejected with a busy message asking to retry shortly.
Shared workspaces
By default each conversation works in its own isolated directory. To share files across asks, or across different agents, pass a sharedWorkspaceId in the ask options. Asks with the same workspace ID operate in the same persistent working directory:
await squid.ai().agent('report-writer').askAsync('Draft the quarterly report as report.md', jobId, {
sharedWorkspaceId: 'q3-reporting',
});
Workspace IDs may contain letters, numbers, underscores, and dashes (up to 200 characters). The option is ignored for non-CLI-agent models.
Tools via MCP
CLI agent models access your agent's abilities through MCP rather than native function calling:
- AI functions and connected integrations are exposed as MCP tools the CLI can invoke
- Knowledge bases are exposed as search tools; the CLI queries them on demand instead of receiving retrieved context in the prompt
This gives the CLI control over when and how often to consult each source during a task.
Limitations
| Limitation | Detail |
|---|---|
| No token streaming | The response arrives when the run completes. Use observeStatusUpdates() for interim progress. |
| No file upload | The file upload APIs are not supported with CLI agent models |
| Structured output | responseFormat: 'json_object' is supported; JSON schema-guaranteed output is not |
| Chat history APIs | Transcripts live in the CLI session and are not returned by Squid's chat history methods |
| One run per conversation | Concurrent asks on the same conversation are rejected with a busy error; retry after the active run |
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Ask fails with a missing API key message | No provider key configured for the selected model | Add the Anthropic (Claude Code) or OpenAI (Codex) key under Settings > AI Settings |
| Busy / retry response | Another ask is already running in the same conversation | Wait for the active run to finish, then retry |
| Run ends at the time limit | The task exceeded maxRuntimeSeconds (or the 30-minute max) | Split the task into smaller asks, or raise maxRuntimeSeconds up to the cap |
Best Practices
- Use
askAsync()with a job ID. CLI agent runs routinely take minutes; awaiting the job keeps your app responsive and survives page reloads (any client with the ID can await it). - Show progress. Subscribe to
observeStatusUpdates(jobId)so users see tool activity instead of a silent multi-minute wait. - Bound runtimes for interactive flows. Set
quotas.maxRuntimeSecondswhen a user is actively waiting; reserve the full 30 minutes for background tasks. - Use shared workspaces for multi-step workflows. A stable
sharedWorkspaceIdlets successive asks (or cooperating agents) build on each other's files. - Pin Codex variants for reproducibility.
codex-gpt-5.5and friends pin exact models;claude-code-*tiers track the latest release of each tier.
Next Steps
- Building AI agents - Create agents, set instructions, and manage models
- Asynchronous jobs - Track long-running asks with
awaitJob()andgetJob() - AI functions - Backend tools your CLI agent can invoke
- Abilities - Attach knowledge bases, integrations, and tools to your agent