> ## Documentation Index
> Fetch the complete documentation index at: https://docs.standardagentbuilder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Thread

> Durable thread runtime, queueing, and parent/child subagent state

## What Is a Thread?

A thread is a conversation instance backed by a Cloudflare Durable Object and SQLite state.

Each thread has isolated:

* messages
* execution state
* logs
* filesystem

## Durable Runtime

New projects do not create local Durable Object subclass files. The `builder()`
Vite plugin generates the Worker entry and exports the built-in thread and
builder Durable Objects with the required Cloudflare bindings and migrations.

## ThreadState APIs

Tools/hooks/endpoints receive `ThreadState`.

Key methods:

* `getMessages()` / `injectMessage()` / `updateMessage()`
* `queueMessage()`
* `getParentThread()` / `getChildThread(referenceId)`
* `terminate()`
* filesystem methods (`readFile`, `writeFile`, etc.)

Key properties:

* `children` (resumable child registry)
* `terminated`
* `arguments` (read-only invocation or creation arguments)
* `context` (mutable scratch data for the current execution only)

## Queue Semantics

`queueMessage()` is durable and ordered:

* if thread is active, queued messages are injected before the next model step
* if thread is idle, queueing forces execution
* queue entries survive eviction
* message APIs expose `sendMessage()` and `queueMessage()` queued entries as pending messages with `metadata.queued: true`

## Parent/Child Communication

Subagent communication is message + filesystem aware:

### Parent -> Child

* initial invocation mapping and resumable `subagent_message`
* `subagent_create.arguments` persists with the child thread as `ThreadState.arguments` and renders as prompt variables for both child sides
* any referenced attachments are copied parent -> child

### Child -> Parent

* completion/failure payloads are queued as silent parent messages
* returned attachments are copied child -> parent
* copied attachment paths are rewritten for the destination thread

## Termination

`terminate()` performs soft shutdown:

* sets `terminated` timestamp
* aborts in-flight execution
* rejects new execution/queue operations
* propagates child termination status to parent registry when linked

## Registry and Message Projection

Parent threads maintain a child registry for resumable instances.

Messages may carry projected subagent fields (for UI/client grouping), including:

* `subagent_id`
* `subagent_name`
* `subagent_title`
* `subagent_status`
* `subagent_resumable`
* `subagent_blocking`

## Related Docs

* [Subagents](/core-concepts/subagents)
* [Tools](/core-concepts/tools)
* [API: get messages](/api-reference/rest/get-messages)
