NewWacht Bench is live — AI-assisted development for Wacht

useAgentThread() hook

useAgentThread() is the single-thread hook. It loads one thread by id and exposes the thread-level update, archive, and unarchive helpers for detail pages and editors.

Usage

The following example shows a basic usage of useAgentThread().

import { useAgentThread } from '@wacht/nextjs';export default function ThreadDetail({  threadId,}: {  threadId: string;}) {  const { thread, updateThread } = useAgentThread(threadId, true);  if (!thread) {    return <div>Loading thread...</div>;  }  return (    <button      onClick={async () => {        await updateThread({          title: 'Updated title',        });      }}    >      {thread.title}    </button>  );}

Return value

The hook returns the following fields and methods.

thread?: AgentThread | null | undefined;
The loaded thread record.
id?: string | undefined;
Thread identifier.
project_id?: string | undefined;
Owning project identifier.
title?: string | undefined;
Thread title.
thread_purpose?: string | undefined;
Thread purpose such as conversation or review.
status?: string | undefined;
Current execution state.
execution_state?: ThreadExecutionState | undefined | undefined;
Execution-specific state such as pending approvals.

Overview

Use this hook when the UI already knows which thread it wants. It is the smallest thread read surface in the SDK, and it leaves events, assignments, conversation state, filesystem, and task graphs to the specialized hooks that sit beside it.

On this page