Chat & Do

The two primary interaction modes in Opta CLI. chat gives you a conversational session with manual control. do runs an autonomous agent loop to complete a task from start to finish.

Chat Mode

opta chat starts an interactive conversation session. The model receives your messages, streams back responses token by token, and maintains full context across the conversation. You stay in control of tool approvals and can guide the conversation at every step.

Start interactive chat
opta chat
Start chat with a specific model
opta chat --model deepseek-r1

Streaming Output

Responses stream in real time as tokens are generated. You see the output building character by character, giving immediate feedback even for long responses. The stream includes thinking indicators and turn statistics (tokens generated, speed in tokens/sec, elapsed time) displayed after each response completes.

Tool Execution

During a chat session, the model can invoke tools to interact with your system. Tools let the AI read files, write code, run shell commands, and search your codebase. Each tool call is displayed in a collapsible card showing the tool name, arguments, and result.

ToolDescriptionAuto-approve
read_fileRead contents of a fileYes
write_fileCreate or overwrite a filePrompt
run_commandExecute a shell commandPrompt
search_filesSearch file contents with regexYes
list_directoryList directory contentsYes

Permission Prompts

When the model requests a tool that modifies your system (writing files, running commands), the CLI displays a permission prompt. You can approve, deny, or approve all similar operations for the rest of the session.

Permission prompt
Tool: write_file
Path: src/auth/validate.ts
Content: (47 lines)

[A]pprove  [D]eny  [A]ll for this tool  [Q]uit
Info
Read-only tools like read_file, search_files, and list_directory are auto-approved by default. This can be changed in configuration.

Do Mode

opta do takes a natural-language task and runs an autonomous agent loop. It plans the work, executes tool calls, and iterates until the task is complete. Safe tools (reads, searches) are auto-approved; destructive tools (writes, commands) still require confirmation unless you opt in to full auto-approval.

Run an autonomous task
opta do "Refactor the auth module to use JWT tokens"

How Do Works

When you run opta do, the agent follows this loop:

  1. Receives your task description as the initial prompt
  2. Analyzes the codebase by reading relevant files
  3. Creates a plan of changes needed
  4. Executes changes step by step, using tools
  5. Verifies the result (runs tests if applicable)
  6. Reports completion with a summary of changes made

Mode Flag

The --mode flag controls how the agent approaches the task.

--mode plan makes the agent analyze and propose changes without executing them. It produces a detailed plan you can review before running the actual implementation.

opta do "Add error handling to API routes" --mode plan

Tool Call Limits

To prevent runaway agent loops, opta do enforces a maximum of 30 tool calls per task. If the agent reaches this limit, it stops and reports what it accomplished. You can then resume or start a new task to continue the work.

Tool call limit
If a task consistently hits the 30-call limit, consider breaking it into smaller, more focused tasks. Complex refactors across many files often work better as a series of targeted do commands.

Cancelling a Task

Press Ctrl+C at any time to cancel a running task. The agent will stop after completing its current tool call. Any changes already written to disk remain in place -- the cancellation does not roll back previous tool calls.

Cancelling a running task
# Press Ctrl+C during execution
Task cancelled. 12 of 30 tool calls used.\nChanges written to 3 files.

Available Tools

Both chat and do modes have access to the same set of tools. The difference is only in approval behavior -- do mode auto-approves safe tools while chat mode may prompt depending on your settings.

CategoryToolsSafety
Readread_file, search_files, list_directorySafe
Writewrite_file, edit_file, delete_fileDestructive
Executerun_commandDestructive
Browserbrowser_open, browser_navigate, browser_screenshotDestructive

Examples

Basic chat session
opta chat
Chat with a specific model
opta chat --model qwen3-30b
Resume a previous session
opta chat --session abc123