QueryMT Agent - Agent Modes
QueryMT Agent supports three runtime modes that control what the agent can do and how it behaves. Modes can be switched at runtime, allowing flexible workflows.
Available Modes
| Mode | Access Level | Primary Use Case |
|---|---|---|
| Build | Full read/write | Implementing code changes |
| Plan | Read-only | Analyzing and planning |
| Review | Read-only | Code review and feedback |
Mode Details
Build Mode
Default mode - Full read and write access to the workspace.
Capabilities: - Read and modify any file - Execute shell commands (including mutating ones) - Create and delete files - Use all configured tools
System Reminder: None (full access)
When to use: - Implementing features - Fixing bugs - Making code changes - Any task requiring modifications
Example:
Plan Mode
Read-only mode - Agent can observe and analyze but cannot make changes.
Capabilities:
- Read files
- Search code
- List directories
- Run read-only shell commands (git log, grep, find, etc.)
- Create todo lists
- Ask clarifying questions
Restrictions:
- Cannot edit files
- Cannot create files
- Cannot delete files
- Cannot run mutating shell commands (sed, tee, echo >, rm, cargo build, etc.)
System Reminder:
When to use: - Before implementing complex changes - Understanding existing codebase - Creating implementation plans - Risk assessment - Architecture analysis
Example:
Review Mode
Read-only mode - Agent acts as a code reviewer providing feedback.
Capabilities:
- Read files and search code
- Analyze code quality
- Identify bugs and issues
- Check for security concerns
- Run read-only commands (tests with --dry-run, linting, etc.)
Restrictions: - Cannot edit files - Cannot create files - Cannot delete files - Cannot run mutating shell commands
System Reminder:
When to use: - Reviewing PRs - Code quality checks - Security audits - Performance reviews - Architecture validation
Example:
Switching Modes
Via Dashboard (Interactive)
The embedded dashboard exposes the agent mode as an ACP session configuration option. Use the mode control in the session composer to select Build, Plan, or Review.
Via API
Via ACP
ACP Session Updates
QueryMT publishes the session state it already tracks so ACP clients stay
synchronized. Stable updates are emitted to every ACP v1 client; Preview
updates are emitted only when the client advertises the matching capability
during initialize.
Stable updates
| Update | Emitted when |
|---|---|
current_mode_update |
The active session mode changes |
config_option_update |
Mode, model, profile, or reasoning effort changes; always carries the complete option set |
session_info_update |
A session title or last-activity timestamp is persisted |
usage_update |
Provider request usage or a post-compaction context size becomes available |
plan |
Legacy plan replacement for clients without plan operations |
A mode change produces current_mode_update first, followed by
config_option_update. usage_update reports used as the tokens currently
occupying model context (cached tokens included) and size as the active
model's effective context limit; the update is omitted when the limit is
unknown, and cumulative USD cost is included only when available.
Preview (capability-gated) updates
| Update | Client capability | Notes |
|---|---|---|
plan_update / plan_removed |
plan (top level) |
Item-based plan with the stable ID querymt-todos |
notice |
session.notices |
Advisory hook notices only; never conversation history |
compaction_update / compaction_summary_chunk |
session.compaction |
ID-addressed compaction lifecycle |
Omitted and null capability fields mean unsupported. Capabilities are parsed
per connection, so one client's Preview support never affects another client.
A fully capable client advertises all three during initialize:
Leaving any of these fields out (or setting them to null) treats that Preview
surface as unsupported for that connection.
Fallbacks
Clients without plan operations receive the legacy full-replacement plan
update (an empty snapshot stays an empty replacement because v1 has no removal
primitive). Clients without compaction support receive neither
compaction_update nor compaction_summary_chunk. Notices fall back to the
event source's existing user-visible behavior.
Replay semantics
When session history is replayed (for example on session/load), QueryMT
materializes current state instead of replaying every historical event:
- One current mode/config snapshot, one folded metadata patch, and the latest
valid
usage_update. - The current todo plan using its stable ID.
- Terminal compactions with their original IDs and final summaries.
- Notices, historical compaction summary chunks, and obsolete in-progress compaction states are never replayed.
Replay applies the connection's capabilities after materialization, so unsupported Preview variants are never sent.
Via Configuration
Set default mode in configuration:
Mode Transition Flow
flowchart LR
B["Build Mode<br/>(default)"]
P[Plan Mode]
R[Review Mode]
B -->|"Select Plan"| P
P -->|"Select Review"| R
R -->|"Select Build"| B
Mode-Aware Behavior
Tool Access
| Tool | Build | Plan | Review |
|---|---|---|---|
read_tool |
✓ | ✓ | ✓ |
edit |
✓ | ||
write_file |
✓ | ||
delete_file |
✓ | ||
shell |
✓* | ✓ (read-only) | ✓ (read-only) |
glob |
✓ | ✓ | ✓ |
search_text |
✓ | ✓ | ✓ |
ls |
✓ | ✓ | ✓ |
*Shell commands are restricted in Plan/Review mode
System Prompt Injection
When in Plan or Review mode, the AgentModeMiddleware injects a system reminder that:
- Reminds the agent of its mode restrictions
- Clarifies what actions are allowed
- Provides guidance on the mode's purpose
Permission Handling
In Plan and Review modes: - Mutating tools are automatically denied - No permission prompts are shown (access is denied by design) - The agent receives clear feedback about mode restrictions
Use Cases
Development Workflow
- Plan Phase (Plan Mode)
- Analyze requirements
- Understand existing code
- Create implementation plan
-
Get user approval
-
Implementation Phase (Build Mode)
- Implement the planned changes
- Write tests
-
Verify functionality
-
Review Phase (Review Mode)
- Review own changes
- Check for issues
-
Ensure code quality
-
Repeat as needed
Code Review Workflow
- Submit Changes
-
Developer makes changes in Build mode
-
Request Review
- Switch to Review mode
-
Ask agent to review changes
-
Get Feedback
- Agent provides detailed feedback
- Lists issues by severity
-
Suggests specific fixes
-
Iterate
- Developer addresses feedback in Build mode
- Request additional review if needed
Architecture Analysis
- Initial Analysis (Plan Mode)
- Explore codebase structure
- Identify dependencies
-
Map data flow
-
Planning (Plan Mode)
- Create migration plan
- Identify risks
-
Estimate effort
-
Implementation (Build Mode)
- Execute the plan
-
Make changes incrementally
-
Validation (Review Mode)
- Verify changes meet requirements
- Check for regressions
Configuration
Custom Mode Reminders
Customize the system reminders for Plan and Review modes:
Mode-Specific Tools
Configure different tools per mode:
Best Practices
When to Use Each Mode
Use Plan Mode when: - Task complexity is high - You want to avoid accidental changes - You need to understand the codebase first - You want user approval before implementing
Use Review Mode when: - You want objective code feedback - You're checking for security issues - You need quality assurance - You're doing a pre-commit check
Use Build Mode when: - You're ready to implement - You need to make changes - You're fixing bugs - You're adding features
Mode Switching Tips
- Start in Plan Mode for complex tasks
- Switch to Build Mode when ready to implement
- Use Review Mode before finalizing changes
- Cycle through modes for thorough development
Communication
When switching modes, communicate with the user: - "Switching to Plan mode to analyze the requirements" - "Ready to implement, switching to Build mode" - "Changes complete, switching to Review mode for final check"
Troubleshooting
Agent Still Making Changes in Plan/Review Mode
- Check that
AgentModeMiddlewareis in the middleware stack - Verify the mode is actually set in the session configuration
- Check logs for mode-related warnings
- Ensure mutating tools are in the
mutating_toolslist
Mode Not Switching
- Verify the dashboard was built with the
dashboardfeature and started with--dashboard - Check that the mode session configuration option is available
- Try switching via the ACP API instead
- Check for middleware errors in logs
Permission Errors in Build Mode
- Verify
assume_mutatingsetting - Check
mutating_toolsconfiguration - Ensure tools are properly registered
- Check for tool-specific permission requirements
Examples
See examples/confs/single_coder.toml for a complete configuration with mode-aware middleware.
Related Documentation
- Middleware Guide - AgentModeMiddleware configuration
- Configuration Guide - Full config reference
- API Reference - Mode API types