[FEATURE]: `message` tool for subagent-to-user direct output
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Feature Request: message tool for subagent-to-user direct output
Problem
When a subagent (via subtask: true command or Task tool) generates carefully
formatted output, the main agent receives it and often reformulates, summarizes,
or adds commentary before presenting to the user. There's no way to guarantee
verbatim output delivery.
Example scenario:
A subagent generates a SQL migration script that must be exact:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
CREATE INDEX idx_users_last_login ON users(last_login);
UPDATE users SET last_login = created_at WHERE last_login IS NULL;
The subagent produces exactly what the user needs. But the main agent receives this and responds with:
"I've generated a migration script for you. It adds a
last_logincolumn and creates an index. Here's what it does..."
The user wanted the raw SQL to copy-paste, not an explanation of it.
Proposed Solution
Add a message tool that subagents can invoke to push content directly to the
user, bypassing the main agent's interpretation layer.
API Design
message({
content: string, // Content to display to user
format?: "text" | "markdown" | "code", // Display hint (default: "text")
language?: string, // For format: "code", e.g., "sql", "yaml"
label?: string, // Optional header, e.g., "Migration Script"
})
Usage Example
---
description: Generate database migration
agent: db-expert
subtask: true
---
Analyze the schema changes needed and generate a migration script.
After generating, use the `message` tool to send it directly to the user:
message({
content: "<the migration SQL>",
format: "code",
language: "sql",
label: "Migration Script"
})
Behavior
- Subagent calls
messagetool with content - OpenCode captures and displays content directly in TUI (verbatim)
- Main agent still receives subagent's return value for context awareness
- Message content is marked as "already displayed" so main agent knows not to repeat it
Symmetry with question tool
This mirrors the existing question tool pattern:
-
question: Subagent -> User (input) -> Subagent -
message: Subagent -> User (output)
Both enable direct subagent-user communication without main agent mediation.
Use Cases
- Migration scripts - SQL/schema changes that must be copy-paste ready
- Config file generation - YAML/JSON/TOML that shouldn't be narrated
- Code generation - Output code blocks without explanation
- CLI commands - Exact commands the user should run
- Reports/analysis - Structured output the user will export or share
Implementation Notes
-
Permission: Follow
questionpattern - denied by default, enable withpermission.message: allow - TUI: Display in a distinct block (similar to tool output) with optional label
- Main agent prompt: Inject note like "The following content was already displayed to the user via message tool: [truncated preview]"