Skip to content

Ability to intercept or emulate agent messages in plugins #14451

@yurihbm

Description

@yurihbm

Question

I would like to know if there is a recommended way to:

  • Inject Agent Responses: Send a message that is visually and functionally treated as an "Assistant/Agent" output (including markdown/syntax highlighting).
  • Message Interception: A hook or middleware to intercept a message generated by the agent before it reaches the UI, allowing for real-time transformation.

Context

I am developing a plugin where I need to either intercept agent messages for transformation or send messages on behalf of the agent.

Current Behavior

Currently, using client.session.prompt with the noReply: true option allows sending a message to the session, but it has two main limitations for this use case:

  • User Role: The message is sent as the user, not the agent.
  • Formatting & Costs: These messages appear to consume input tokens and lack the syntax highlighting typically applied to agent outputs.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions