Designing Full-Modal CLI Tools for AI Agents: Practical Principles
This article explores how command-line tools must evolve when the primary consumer shifts from humans to AI agents. It outlines four common pain points agents face with traditional CLIs—mixed output, weak error semantics, blocking on missing arguments, and synchronous long-running tasks—and presents four core design principles: separating human-readable output from machine-readable data, semantic exit codes, non-blocking asynchronous task control, and a unified abstraction across modalities. It closes with practical guidance for building stable, parallelizable full-modal agent workflows.
1. Background: The Consumers of Model Capabilities Are Expanding from Humans to Agents
Model capabilities used to be consumed mainly by people and developers: people asked questions through chat interfaces, and developers embedded models into applications through APIs. Today, however, a growing share of consumers are agents themselves. An agent is not an individual sitting at a terminal reading prompts one by one. It must execute tasks continuously in unattended environments: reading objectives, breaking down steps, calling tools, validating results, retrying after failures, and running work in parallel.
This creates a fundamental shift: the user experience standard for tools must no longer target human intuition alone, but also machine parseability. An interface that is friendly to humans may be a source of noise for an agent; a prompt that seems “slightly verbose” to a human may break an automated workflow outright.
The command line has become a common form for agents working in terminals for a straightforward reason: commands are discrete, composable, and scriptable. One command maps to one action, and one exit status maps to one result judgment, making commands naturally suited to orchestration. Packaging full-modal capabilities into command-line tools—so an agent can “run one command and get one clean result”—is therefore a key path to improving automation efficiency.
2. Four Typical Pain Points When Agents Call Tools
Ordinary CLI tools are designed on the assumption that “someone is watching the screen.” Once an agent takes over, the problems surface quickly.
Mixed output that is hard to parse
Progress bars, colored characters, status messages, and decorative borders are human-friendly but distracting to agents. An agent needs to reliably extract file paths or structured data. Once escape characters leak into standard output, parsing logic becomes fragile.Insufficient error semantics that require “reading English” to interpret
If failure information is only a natural-language description, the agent must rely on text understanding to guess the error type—slow and unreliable. Automated systems need machine-decidable error categories.Hanging and waiting for input when arguments are missing
Interactive tools prompt users for missing input, but in non-interactive environments this stalls the task, occupies an execution slot, and can even cause the entire pipeline to time out.Blocking on long tasks with no parallelism
Tasks such as video generation and long-form audio synthesis take considerable time. If the agent waits synchronously in the foreground, it cannot work on other subtasks at the same time, severely reducing overall throughput.
3. Design Principles for Agent-Oriented CLI Tools
Addressing these problems requires shifting tool design from “human interaction first” to “machine contract first.” Four key designs follow.
3.1 Output Isolation and a Pure-Data Mode
The core idea is to separate human-readable information from machine-parseable data.
- Human-friendly messages (progress, status, colored output) are written uniformly to standard error;
- Standard output carries only clean results, such as file paths or structured data;
- A quiet mode and a structured-output option fully disable interactive decoration.
Illustrative call logic (conveying design intent only):
# Return only a clean result so the agent can parse it directlyresult=$(mmtool generate --prompt "..." --quiet --output json)# During human debugging, status information is available# Progress and status go to stderr and do not pollute stdout
The benefit is that the agent no longer needs to strip noise: parsing changes from “fault-tolerant guessing” to “reading by contract.”
3.2 Semantic Exit Codes: Making Failures Programmatically Decidable
Automated systems fear “uncategorizable errors” most. A mature approach assigns a distinct exit code to each failure type, for example:
- Authentication failure;
- Invalid arguments;
- Timeout;
- Network error;
- Insufficient resources or quota limits.
The agent only needs to read the exit code to decide whether to retry, switch parameters, or terminate the flow. Compared with parsing natural-language errors, this is faster, more stable, and better suited to unattended operation.
if mmtool run ...; thenecho "success"elsecode=$?case $code in10) echo "auth error, stop";;20) echo "bad args, fix input";;30) echo "timeout, retry";;40) echo "network, retry with backoff";;*) echo "unknown";;esacfi
3.3 Non-Blocking and Asynchronous Task Control
Agent automation requires two capabilities: exit immediately on missing arguments and move long tasks to the background.
- In non-interactive environments, incomplete arguments should cause an immediate error and exit rather than waiting for input;
- For long-running tasks, provide an asynchronous mode that returns a task identifier immediately, so the agent can move on to other work and later poll or receive a callback for the result.
Pseudocode illustration:
# Submit asynchronously and return a task ID immediatelytask_id=$(mmtool render --async --input brief.json --output json | jq -r .task_id)# The agent does other work and checks latermmtool status --task "$task_id" --output json
This design turns “serial waiting” into “parallel scheduling” and is the foundation for multi-agent collaboration and pipeline automation.
3.4 A Unified Abstraction for Full-Modal Capabilities
Text generation, speech synthesis, music composition, and image and video generation differ greatly in their underlying implementations. For agents, however, the calling convention should be as consistent as possible: a unified parameter style, a unified output contract, and a unified exit-code system. Only when the tool layer completes this abstraction can an agent drive different modalities with the same orchestration logic, enabling end-to-end automation such as “research → copywriting → voiceover → images and music → video assembly.”
4. Implementation Guidance: Running Full-Modal Workflows Stably with Agents
- Define the contract before the capabilities: specify the output format, exit codes, and asynchronous task model first, then integrate concrete model capabilities.
- Default to non-interactive: design every command for non-interactive environments by default, exiting on missing arguments to avoid hangs.
- Prefer structured output: use structured output first and reduce natural-language parsing.
- Tier retry strategies: do not retry authentication or argument errors; use exponential backoff for timeouts and network errors.
- Separate observability: route human debugging information to standard error, machine results to standard output, and collect logs and metrics separately.
- Parallelize task orchestration: make long tasks asynchronous and pair them with task-status queries to run multiple tasks in parallel.
5. Conclusion
The infrastructure of the agent era is not only more capable models, but also a tool layer that agents can use reliably. Building full-modal capabilities as command-line tools—with output isolation, semantic exit codes, and non-blocking asynchronous control as core designs—can significantly reduce the fragility of automation pipelines. For developers, mastering this design methodology turns multimodal capabilities into agent infrastructure that is orchestrable, reusable, and scalable.
