Textual CLI for ADK Agents
The ADK supports an advanced Textual CLI (TUI) that provides persistent input capabilities, real-time agent interaction, and comprehensive visual feedback. This interface transforms the traditional command-line experience into a dynamic, responsive environment.
π― Key Features
Persistent Input Pane
- Always-available input: Type commands while the agent is processing
- Multi-pane interface: Dedicated output, thought, and input areas
- Real-time typing: Continue working without waiting for responses
- Command categorization: Organized auto-completion by functional areas
Agent Interruption & Control
- Ctrl+C interruption: Stop long-running operations instantly
- Graceful cancellation: Clean agent task termination
- Immediate responsiveness: Continue with new queries after interruption
- Task management: Visual indication of agent state and progress
Enhanced Visual Interface
- Themed interface: Dynamic dark and light themes with instant switching
- Status indicators: Real-time display of agent state, token usage, and tool activity
- Agent thoughts display: Optional side pane showing agentβs reasoning process
- Rich formatting: Markdown rendering, syntax highlighting, and structured output
- Token tracking: Real-time display of prompt, thinking, and output tokens
π Usage
Command Line Options
# Enable Textual CLI
adk run agents/devops --tui
# With theme selection
adk run agents/devops --tui --ui_theme dark
adk run agents/devops --tui --ui_theme light
# With session management
adk run agents/devops --tui --save_session --session_id my_session
# Resume previous session
adk run agents/devops --tui --resume my_session.json
Interface Layout
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π€ Agent Output (π’ Ready) β βΉοΈ Events (Ctrl+Y to toggle) β
β β β
β Agent responses appear here in β β’ Tool: code_search β
β real-time with rich formatting β Duration: 1.2s β
β and syntax highlighting β β’ Model: gemini-2.0-flash-001 β
β β Tokens: 150 prompt, 300 output β
β β β’ Agent thinking: 45 tokens β
βββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββ€
β π§ User Input β
β β
β > Type your commands here... Tab for completions β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π€ DevOps Agent | π§ Session: abc123... | π‘ Enter:submit Alt+Enter:newline β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β¨οΈ Keyboard Shortcuts
Essential Controls
| Shortcut | Action | Description | |βββ-|βββ|ββββ-| | Enter | Submit input | Send command to agent (when ready) | | Alt+Enter | Insert newline | Add line break for multi-line input | | Ctrl+C | Interrupt agent | Stop running agent operations | | Ctrl+D | Exit application | Quit the CLI | | Ctrl+L | Clear output | Clear the output pane |
Interface Controls
| Shortcut | Action | Description | |βββ-|βββ|ββββ-| | Ctrl+T | Toggle theme | Switch between dark/light themes | | Ctrl+Y | Toggle thoughts | Show/hide agent thought pane | | Tab | Auto-complete | Show categorized command completions | | β/β | History navigation | Navigate command history | | Ctrl+P/N | History navigation | Alternative history navigation |
Command Categories
The TUI provides intelligent auto-completion organized by functional areas:
π Infrastructure & DevOps
create a dockerfilecreate docker-compose.ymlwrite kubernetes manifestscreate helm chart forwrite terraform code forsetup CI/CD pipelineconfigure github actionssetup monitoring forlist the k8s clusters and indicate the current one
π Code Analysis
analyze this codereview the codebasefind security vulnerabilitiesoptimize performance ofrefactor this functionadd error handling towrite unit tests fordebug this issue
π¦ Deployment & Operations
deploy to productiondeploy to stagingrollback deploymentcheck service statustroubleshoot deploymentscale the service
π§ Development Workflow
create new feature branchmerge pull requesttag new releaseupdate changelogexecute regression testssummarize, commit, and push changes
π¨ Visual Features
Theme Support
- Dark Theme: Professional dark interface with syntax highlighting
- Light Theme: Clean light interface for bright environments
- Dynamic Switching: Instant theme changes with
Ctrl+T - Auto-detection: Respects system theme preferences
Status Indicators
- π’ Ready: Agent waiting for input
- π‘ Thinking: Agent processing with animated indicator
- π΄ Error: Error state with detailed information
- β‘ Running: Agent executing tools or operations
Token Usage Display
Real-time tracking of:
- Prompt Tokens: Input processing tokens
- Thinking Tokens: Reasoning tokens (Gemini 2.5 models)
- Output Tokens: Response generation tokens
- Total Usage: Cumulative token consumption
- Model Information: Current model and configuration
Tool Activity Monitoring
- Tool Execution: Real-time tool usage display
- Duration Tracking: Execution time for each tool
- Success/Failure: Visual indication of tool results
- Tool Categories: Organized display by tool type
π§ Technical Architecture
Async Task Management
class AgentTUI(App):
"""Textual application with concurrent agent interaction."""
# Reactive state management
agent_running: reactive[bool] = reactive(False)
agent_thinking: reactive[bool] = reactive(False)
# Token and tool tracking
_prompt_tokens: reactive[int] = reactive(0)
_thinking_tokens: reactive[int] = reactive(0)
_tools_used: reactive[int] = reactive(0)
Interruption Mechanism
- Signal Detection:
Ctrl+Cbinding captures interrupt - Task Cancellation: Current agent task receives cancellation
- Cleanup: Resources cleaned up gracefully
- State Recovery: System returns to ready state
Component Architecture
- AgentTUI: Main Textual application managing layout and state
- CategorizedInput: Enhanced input widget with auto-completion
- CompletionWidget: Modal completion selection interface
- RichLog: Output rendering with rich formatting support
π Usage Examples
Basic Interaction
# Start TUI
adk run agents/devops --tui
# Type command
> create a kubernetes deployment for nginx
# While agent responds, type next command
> what are the current pods in default namespace?
# Interrupt if needed
[Ctrl+C]
# Continue with new command
> help me troubleshoot the failing pod
Multi-line Commands
# Use Alt+Enter for complex requests
> Create a comprehensive monitoring setup that includes:
[Alt+Enter]
> - Prometheus for metrics collection
[Alt+Enter]
> - Grafana for visualization
[Alt+Enter]
> - AlertManager for notifications
[Alt+Enter]
> - Custom dashboards for our services
[Enter to submit]
Session Management
# Start with session saving
adk run agents/devops --tui --save_session --session_id infrastructure_work
# Work on tasks...
# Session automatically saved on exit
# Resume later
adk run agents/devops --tui --resume infrastructure_work.json
π― Best Practices
Efficient Workflows
- Use Tab Completion: Leverage categorized commands for faster input
- Multi-line Planning: Use
Alt+Enterfor complex, structured requests - Interrupt Wisely: Use
Ctrl+Cto stop long operations when needed - Monitor Tokens: Keep an eye on token usage for cost management
- Save Sessions: Use session management for long-term projects
Performance Tips
- Theme Selection: Choose theme based on environment and preference
- Thought Display: Toggle thoughts pane based on need for reasoning visibility
- Command History: Use
β/βto quickly access recent commands - Categorized Completion: Use Tab to discover available command patterns
π Troubleshooting
Common Issues
TUI Not Starting:
# Check terminal compatibility
echo $TERM
# Try with explicit theme
adk run agents/devops --tui --ui_theme dark
# Fall back to regular CLI
adk run agents/devops
Input Not Responding:
- Ensure agent is in ready state (π’)
- Try
Ctrl+Cto interrupt if agent is running - Check for terminal focus issues
Theme Issues:
- Use
Ctrl+Tto toggle themes - Set explicit theme with
--ui_themeflag - Check terminal color support
Completion Not Working:
- Press
Tabto trigger completions - Ensure input focus is active
- Try typing partial command before Tab
Debug Mode
# Enable enhanced logging
adk run agents/devops --tui --log_level DEBUG
# With cloud tracing
adk run agents/devops --tui --trace_to_cloud
π Advanced Features
Custom Styling
The TUI uses CSS-like styling defined in ui_textual.tcss:
- Customizable colors and themes
- Responsive layout adaptation
- Rich text formatting support
Integration Points
- Session Services: SQLite, Agent Engine, PostgreSQL
- Artifact Storage: Google Cloud Storage, local storage
- Monitoring: Cloud Trace, structured logging
- Authentication: Configurable auth mechanisms
The Textual CLI transforms agent interaction from sequential Q&A to a dynamic, responsive interface that puts you in complete control of your DevOps workflows.