axon.thread

Every axon.request and axon.stream call runs inside a thread. A thread is a conversation history — the agent sees all prior entries when you continue it.

The execution thread

Omitting thread continues the script's own execution thread. Consecutive calls share context automatically.

const r1 = await axon.request("hello")
const r2 = await axon.request("say cheese")   // agent remembers r1
const r3 = await axon.request("tell a joke")  // agent remembers r1 and r2

This is the default. Most scripts that do one focused task never need anything else.

Named threads

Pass a string name to run a call in an isolated side thread. The runtime resolves the name to a stable ID for this session. Named threads don't share context with the execution thread or with each other.

const main = await axon.request("starting the main task")

const lookup = await axon.request({
    prompt: "what's the capital of france",
    thread: "geo-lookup",
})

const followup = await axon.request({
    prompt: "what's the population of that city",
    thread: "geo-lookup",   // agent has r1 on this thread — knows "that city"
})

// inject result back into main thread
const summary = await axon.request(
    `incorporate this: ${followup.text}`,
    // no thread: — back on the execution thread
)

Named threads are for work that needs its own clean context: research tasks, side lookups, parallel branches. They prevent unrelated content from polluting the agent's working memory on the main thread.

Thread handle

For repeated calls to the same named thread, a handle avoids repeating the name on every call. .request() and .stream() have the same signatures as the top-level calls, minus the thread field.

const research = axon.thread("research")

await research.request("find everything about the eiffel tower")
await research.request("now find the history of its construction")
await research.request("summarise into 3 bullet points")

// full entry timeline for this thread
const timeline = research.entries

Parallel branches

Multiple named threads run concurrently. Pull results back into the main thread for synthesis.

const [a, b] = await Promise.all([
    axon.request({ prompt: "research quantum computing", thread: "task-a" }),
    axon.request({ prompt: "research classical computing", thread: "task-b" }),
])

const synthesis = await axon.request(
    `compare these two:\n\nA: ${a.text}\n\nB: ${b.text}`
)

Persistence across script runs

Named threads are persisted server-side within the session. The same thread name on the next script run resumes with full prior context intact.

// run 1
const project = axon.thread("project-alpha")
await project.request("what are the tradeoffs of a document vs relational schema?")

// run 2 — next day
const project = axon.thread("project-alpha")
await project.request("what did we decide about the schema?")
// agent sees everything from run 1

This makes named threads useful as durable scratchpads for ongoing work — decisions, research, plans that accumulate across multiple invocations of the same script.