Page actions

Quick Start

Send a trip-planning question and render the answer as it arrives. This walkthrough connects an Angular component to a LangGraph server, then explains what changes during the first turn. For the full path from a message to tools and saved state, start with Follow a conversation.

Note: Prerequisites

Angular 20–22 project using a Node.js version supported by that Angular major. If you need setup help, see the Installation guide.

Note: No backend yet?

Try without a backend renders the same <chat> with a fake agent — no server, no key.

1
Install the packages
npm install @threadplane/angular @threadplane/core @threadplane/langgraph @langchain/core @langchain/langgraph-sdk

@threadplane/angular holds the provider and injectAgent(). @threadplane/langgraph holds createSession(), the LangGraph implementation of the session contract in @threadplane/core. npm 7 and newer install peer dependencies automatically, so this command also brings in the peers @threadplane/angular/chat declares — @threadplane/telemetry, @threadplane/angular/render, @threadplane/a2ui, zod, @json-render/core, and marked. Listing the LangChain peers explicitly keeps stricter package managers quiet; the full contract is in the Installation guide.

2
Configure the provider

Add provideAgent() to your application config. Its createSession function builds a LangGraph session from your LangGraph Platform URL and assistant id. The agent calls it once at start and again each time it moves to another thread, and context carries the thread to use.

// app.config.ts
import type { ApplicationConfig } from '@angular/core';
import { provideAgent } from '@threadplane/angular';
 
export const appConfig: ApplicationConfig = {
  providers: [
    provideAgent({
      createSession: (context) =>
        import('@threadplane/langgraph').then(({ createSession }) =>
          createSession({
            ...context,
            apiUrl: 'http://localhost:2024',
            // 'chat' maps to the key in your langgraph.json "graphs" config
            assistantId: 'chat',
          })
        ),
    }),
  ],
};

The factory returns a Promise, so @threadplane/langgraph loads on demand, out of the initial bundle.

Note: Threads are optional here

Without a configured threadId, the session creates a thread on the first submit. Persisting that id so conversations survive a page refresh is opt-in — leave it out for the minimal path and add it later. See Persistence.

3
Create a chat component

Now wire up the UI. Call injectAgent() in a component field initializer — read the agent's fields through Angular Signals and call its commands to submit or stop a run.

// chat.component.ts
import { Component, ChangeDetectionStrategy, signal, computed } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { injectAgent } from '@threadplane/angular';
 
@Component({
  selector: 'app-chat',
  standalone: true,
  imports: [FormsModule],
  templateUrl: './chat.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ChatComponent {
  input = signal('');
 
  protected readonly chat = injectAgent();
 
  isStreaming = computed(() => this.chat.status() === 'running');
 
  send() {
    const msg = this.input();
    if (!msg.trim() || this.isStreaming()) return;
    void this.chat.submit(msg);
    this.input.set('');
  }
}
4
Start your LangGraph server

Make sure your LangGraph agent is running at the URL you configured.

langgraph dev
5
Run your app
ng serve

Open http://localhost:4200 and start chatting with your agent.

Follow the first turn

Type “Plan a weekend in Portland” and press Send. The component passes the new message text to submit; it does not replace the transcript. While the backend runs, status() is 'running', which disables another submission, and messages() updates as text arrives. Each message's content is always its display text.

The signal named input holds only the unsent draft. The session owns the observed messages. Keeping them separate lets the user type another draft without changing the answer in progress. This small template renders plain text; use the chat composition for Markdown, tool calls, and the standard controls.

Sequence diagramOne user turn, from request to response
  1. Person → ApplicationAsk for a three-day trip plan.This starts one user turn.
  2. Application → RuntimeSubmit a message on a confirmed thread.The session starts an agent run.
  3. Runtime → Model / toolsPlan, look up information and continue.One turn can contain several model and tool calls.
  4. Runtime → Threadplane → UIStream message and state updates.The response is built incrementally; a chunk is not a new turn.
  5. Runtime → StorageSave state when the backend supports it.LangGraph checkpoints belong to the thread.
  6. Threadplane → ApplicationShow the final answer and settled status.The next user message starts the next turn.
A turn describes the interaction. A run executes the agent. Requests carry commands and events.
Read diagram description

Read top to bottom. A person asks for a trip plan. The application submits their message to a confirmed thread. An agent run can invoke a model and tools more than once. Threadplane observes streamed message and state events and the UI updates as they arrive. Persistence depends on the backend: LangGraph can save checkpoints during execution; the AG-UI protocol alone does not provide storage. When the run settles, the UI shows the answer. The next user message starts another turn; a tool result or streamed token does not.

Typed state via AgentRef

By default, injectAgent() returns an agent typed by the core session contract: state() is plain data, and the fields and commands only LangGraph has are not on the type. Create a typed ref at module scope and pass the same ref to the provider and inject helper to carry the LangGraph session type, with your graph's state shape, through Angular DI:

import { createAgentRef, injectAgent, provideAgent } from '@threadplane/angular';
import { type, type ToolContract } from '@threadplane/core';
import { createSession, type LangGraphSession } from '@threadplane/langgraph';
 
interface TripState {
  day?: number;
  places?: string[];
}
 
type TripSession = LangGraphSession<Record<string, ToolContract>, TripState>;
 
export const TRIP = createAgentRef<TripSession>('trip');
 
// app.config.ts providers
provideAgent(TRIP, {
  createSession: async (context) =>
    createSession({
      ...context,
      apiUrl: 'http://localhost:2024',
      assistantId: 'chat',
      stateType: type<TripState>(),
    }),
});
 
// In a component field initializer or another Angular injection context:
const agent = injectAgent(TRIP); // Agent<TripSession>
agent.state()?.places; // readonly string[] | undefined

state() is the root graph state without messages, and it is undefined until the backend reports one. A run often reports partial state before the graph has written every field, so declare the fields the graph fills in later as optional. type<T>() checks nothing at runtime; pass a Standard Schema, such as a Zod object, as stateType to check each reported state as well.

The optional ref name appears in Angular DI error messages. The ref comes from @threadplane/angular and carries a session type, so the same kind of handle works with any backend's session.

Next steps

Drop-in chat UI

Skip the hand-rolled template — render this agent with <chat [agent]> from @threadplane/angular/chat.

Streaming

Learn about token-by-token updates and stream modes

Persistence

Keep conversations alive across page refreshes

Interrupts

Add human-in-the-loop approval flows

Angular Signals

Deep dive into how Signals power agent

LangGraph Basics

Graphs, nodes, edges, and state for Angular developers

API Reference

Generated reference for @threadplane/langgraph

Looking for something specific?