Skip to main content

Module 14: Sending Updates

Send all types of session updates from an agent to its client.

What You’ll Learn

  • Convenience methods: sendMessage(), sendThought()
  • Full API: sendSessionUpdate() for complex types (plans, tool calls, commands)
  • All SessionUpdate types from the agent’s perspective

The Code

The prompt handler demonstrates each update type:
As of 0.80.0, sendSessionUpdate(update) takes no session ID: the context already belongs to one prompt’s session, so a separate ID was redundant (and a wrong one silently sent the update to another session). To update a different session from outside its own prompt handler, call AcpAsyncAgent.sendSessionUpdate(sessionId, update) (or AcpSyncAgent.sendSessionUpdate) instead.
ToolCall and ToolCallUpdateNotification take a name argument after title: the tool’s own identifier, separate from the human-readable title, and it may be null.

Convenience vs Full API

Convenience methods handle wrapping in TextContent and setting the type field. Use sendSessionUpdate() for complex types that need full control over their structure.

Source Code

View on GitHub

Running the Example

Next Module

Module 15: Agent Requests — read files, write files, and request permissions from the client.