NewWacht Bench is live — AI-assisted development for Wacht

useAgentThreadEvents() hook

useAgentThreadEvents() reads the paged event feed for one thread. It is the right hook for activity timelines, execution logs, and review surfaces that need the thread event stream but not the full conversation surface.

Usage

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

import { useAgentThreadEvents } from '@wacht/nextjs';export default function ThreadEvents({  threadId,}: {  threadId: string;}) {  const { events, hasMore, loadMore } = useAgentThreadEvents(threadId, {    enabled: !!threadId,  });  return (    <div>      <ul>        {events.map((event) => (          <li key={event.id}>{event.event_type}</li>        ))}      </ul>      {hasMore ? <button onClick={() => void loadMore()}>More</button> : null}    </div>  );}

Return value

The hook returns the following fields and methods.

events?: ThreadEvent[] | undefined;
Flattened event list for the current thread.
hasMore?: boolean | undefined;
Whether more event pages are available.
loadingMore?: boolean | undefined;
Whether the next event page is currently loading.

Overview

This hook is a read-only event feed. It keeps a paged, periodically refreshed list of thread events and flattens the pages for the caller, which is why it works well for event timelines and activity drawers.

On this page