tree

Structured data (nested objects and lists), such as a large tool result, stored once and passed by its handle.

At a glance

Writing

Write a JSON object or array; YAML is accepted too. The top level is always an object or a list, so any other value is refused. Keys keep the order you wrote them in, but two trees with the same content in another key order share one handle.

A value inside the tree can be a handle of its own: a PDF, an image, a recording, a file or another tree in a result. Write it as {"__dtype__": "pdf-…"}, or as the exact <attachment id="pdf-…"/> marker an agent sees. Any other string is text, even one that looks like a handle.

In an entity's record a tree is written as its handle, {"__dtype__": "tree-…"}. A small one also carries its data, as {"__dtype__": "tree-…", "__value__": …}, so it can be read without another call.

Written as

A JSON object whose schema format is tree.

Reading

get_content reads part of a tree with path, range, query or hql:

Add as_handle to keep the selection as a new tree and pass its handle on instead of copying the rows. get_media gives the whole tree as a JSON file to download.

A tree too large to show is shown in part: a list as its first items and the index range of the rest, an object as an outline of its keys and values.

Querying

HQL does not search inside trees: a tree in a field is not indexed for text. Find the records that hold one, then read it with get_content. Structured tool results are kept in the content of the tool's message as trees:

Message | role = "tool" AND content.dtype = "tree" | select id, created_at | limit 20

Every operator is in the HQL reference.

Editing

edit changes a tree with JSON Pointer ops, which address the data as path reads it: {"op": "replace", "path": "/rows/3/status", "value": "cancelled"}. A result of a named type keeps its type. The result is a new tree under a new handle.

In agent tools

A tool's structured result reaches the agent as a tree: shown whole when it fits, otherwise in part with its <attachment id="tree-…"/> marker. To pass part of it to another tool without copying it, write the argument as <ref id="tree-…" path="/rows/3"/>, which stands for the value at that pointer with its type. For a selection of many rows, keep it with as_handle and pass the new handle. See values and handles.

Operations

Through the dtypes resource: