LangGraph · API Reference

LangGraphThreadsAdapter

SDK-backed thread CRUD for LangGraph Platform threads. Use it with chat thread components instead of hand-rolling local thread lists.

#Configure

import {
  LANGGRAPH_THREADS_CONFIG,
  LangGraphThreadsAdapter,
  refreshOnRunEnd,
} from '@threadplane/langgraph';
 
export const appConfig: ApplicationConfig = {
  providers: [
    {
      provide: LANGGRAPH_THREADS_CONFIG,
      useValue: { apiUrl: 'http://localhost:2024' },
    },
    LangGraphThreadsAdapter,
  ],
};

LANGGRAPH_THREADS_CONFIG.apiUrl accepts the same absolute or relative LangGraph API URLs as provideAgent().

#Pair with chat thread UI

import { Component, inject } from '@angular/core';
import { ChatThreadListComponent, type ThreadActionAdapter } from '@threadplane/chat';
import { injectAgent, LangGraphThreadsAdapter, refreshOnRunEnd } from '@threadplane/langgraph';
 
@Component({
  standalone: true,
  imports: [ChatThreadListComponent],
  template: `
    <chat-thread-list
      [threads]="threads.threads()"
      [activeThreadId]="agent.threadId?.() ?? null"
      [actions]="actions"
      (selectThread)="agent.switchThread($event)"
    />
  `,
})
export class ThreadsPanel {
  protected readonly agent = injectAgent();
  protected readonly threads = inject(LangGraphThreadsAdapter);
 
  protected readonly actions: ThreadActionAdapter = {
    rename: (id, title) => this.threads.rename(id, title),
    delete: (id) => this.threads.delete(id),
    archive: (id) => this.threads.archive(id),
    pin: (id) => this.threads.pin(id),
  };
 
  constructor() {
    void this.threads.refresh();
    refreshOnRunEnd(this.agent, () => this.threads.refresh());
  }
}

The adapter maps SDK threads to the Thread type consumed by ChatThreadListComponent and ChatSidenavComponent. It expects titles in metadata.title.

#Shared SDK client

Provide LANGGRAPH_CLIENT when you want to share an SDK Client instance or inject a test double. Provide LANGGRAPH_CLIENT_OPTIONS once at the app root to tune the SDK retry budget used by both FetchStreamTransport and the threads adapter.

LangGraphThreadsAdapterclass

SDK-backed thread store. Wraps `client.threads.*` and maps SDK threads to the framework's Thread type for direct use with `<chat-thread-list>` / `<chat-sidenav>`. Consumers wire the framework's `ThreadActionAdapter` to instance methods (rename/delete/archive/pin/...) so the right-click menu round-trips through the LangGraph SDK without per-app boilerplate.

Properties

ParameterTypeDescription
archivedThreadsSignal<Thread[]>Threads whose `metadata.archived === true`.
threadsSignal<Thread[]>Active (non-archived) threads, sorted with pinned first.

Methods

archive(threadId: string): Promise<void>
ParameterTypeDescription
threadIdstring
create(metadata: Record<string, unknown>): Promise<string | null>
ParameterTypeDescription
metadata?Record<string, unknown>
delete(threadId: string): Promise<void>
ParameterTypeDescription
threadIdstring
getThread(threadId: string): Promise<Thread | null>

Fetch a single thread by id. Returns `null` when the server returns 404 (thread doesn't exist) so callers can distinguish "missing" from "couldn't reach the server" — genuine network errors rethrow. Used by URL-based thread routing to validate a pasted/shared thread id before activating it.

ParameterTypeDescription
threadIdstring
moveToProject(threadId: string, projectId: string | null): Promise<void>
ParameterTypeDescription
threadIdstring
projectIdstring | null
pin(threadId: string): Promise<void>
ParameterTypeDescription
threadIdstring
refresh(): Promise<void>

Fetch the latest thread list from the server. Failures are logged via `console.error` (not swallowed silently — silent catches have masked prod issues in the past). Invocation and resolution are logged at `console.debug` so prod inspection can distinguish "never called" from "called but resolved empty" from "called and threw." This was prompted by a demo.threadplane.ai cold-load bug where the sidenav stayed empty with no visible signal. Tighten the log volume if it becomes noisy.

rename(threadId: string, newTitle: string): Promise<void>
ParameterTypeDescription
threadIdstring
newTitlestring
reorderPinned(threadId: string, beforeId: string | null): Promise<void>

Re-stamp `metadata.pinnedOrder = 0,1,2,...` for the pinned slice to reflect the new ordering.

ParameterTypeDescription
threadIdstring
beforeIdstring | null
unarchive(threadId: string): Promise<void>
ParameterTypeDescription
threadIdstring
unpin(threadId: string): Promise<void>
ParameterTypeDescription
threadIdstring

Examples

const svc = inject(LangGraphThreadsAdapter);
const actions: ThreadActionAdapter = {
  rename: (id, t) => svc.rename(id, t),
  delete: (id) => svc.delete(id),
};