Contents

Update Document Block

library_block_update · Tools · Documents

Replace one block of a Library document by its id

Parameters

NameTypeRequiredDescription
blockobjectYesOne block, as BlockNode JSON: an object whose `type` names the block, with an optional `id`. load_skill("library-documents") gives every block type with its fields.
block_idstringYesA block's `id`, as library_get returns it: 10 letters and digits. A blockquote's child blocks have ids too.
identifierstringYesThe item's id (ULID) or slug, as library_list, library_search and library_get return them.

Update Document Block Tool#

library_block_update replaces one block of a Library document, addressed by its id.

When to Use#

The agent uses it to correct or rewrite one block it read with library_get. The block keeps its id and may change type.

Parameters#

Parameter Type Required Description
identifier string Yes The item's id (ULID) or slug, as library_list, library_search and library_get return them
block_id string Yes The block's id (10 letters and digits); blockquote children are addressable too
block object Yes The replacement block

A block is BlockNode JSON: an object whose type names the block. An id in it is ignored: the block keeps the addressed block_id, and its blockquote children keep the ids they state unless another block holds them.

load_skill("library-documents") gives every block type with its fields, and get_docs("documents") says what a document can contain, including pages drawn from HTML or SVG. The agent reads get_docs("documents") before writing to a document the first time. A malformed block is refused with a message naming what is wrong.

Returns#

Field Type Description
item object The item: id, slug, name, kind (document, folder or file), path (folder slugs; null when unfiled), path_names, icon, color, ai_access_policy, revision, created_at, updated_at, url; a file adds object_id, media_kind, content_type, filename, size_bytes
blocks array The one block as stored, with its unchanged id

url is the item's link. The agent gives it to the user when it reports the change, labelled with the item's name rather than its folder path.

Example Scenario#

{
  "identifier": "q1-research-notes-ab12cd",
  "block_id": "AbCdE12345",
  "block": { "type": "heading", "level": 2, "content": [{ "type": "text", "text": "Key findings" }] }
}

Notes#

  • Each call is one read-modify-write of the document's current content, so it never overwrites an edit made since the agent read it. The result is stored as the document's new version and bumps its revision; within 5 minutes of the current version, the write replaces that version instead of adding another.
  • An unknown block_id is refused with Block not found: <id>; a malformed one is refused before anything is read
  • A folder or file is refused: it has no blocks
  • An unknown or trashed identifier is refused with Library item not found: <identifier>
  • Refused when the item's AI access policy denies reads or writes: AI access denied: this resource is not writable by AI tools. (or not readable)
  • Risk: write