Read threads
Add comments
Comment bodies are Markdown. Each method returns the new comment’s ID, ornull when the target no longer exists.
Panel and selection
addCommentAtSelection. The chip is hidden during a draft, in read-only
documents, and on selections that already have a thread.
Comments and suggestions together
A comment can be linked to suggestions. A reviewer can then accept or reject those suggestions from the comment:Agent comments
Theleave_comment tool adds comments from an agent:
{ start_text, end_text } for a long range, and
{ whole_block: true } for structural or empty content.
To reply, call the same tool without an anchor:
data.blockId is where it landed and data.requestedBlockId is the block you
asked for. Block IDs change when a file is imported again, so this keeps a
stale ID from failing.
Read tools return existing threads as <comment-thread> elements in their
HTML. A new thread that overlaps an unresolved thread is rejected, and the
agent should reply to that thread instead. To add an overlapping thread
anyway, list the overlapping IDs in acknowledge_existing_thread_ids.
Tool comments are signed “Revise Agent” unless you set
agent.name.
Comment agents
Thecomments controller runs an agent scoped to one thread. Use it when each
thread is a separate conversation with the model:
getState(threadId) returns the thread’s run state. subscribe() publishes a
map of every active run.