Skip to content

fix(langgraph-api): restore full message union in generated schemas - #2601

Open
Ali Tariq (valkrypton) wants to merge 1 commit into
langchain-ai:mainfrom
valkrypton:fix/2574-studio-chat-tab-message-schema
Open

fix(langgraph-api): restore full message union in generated schemas#2601
Ali Tariq (valkrypton) wants to merge 1 commit into
langchain-ai:mainfrom
valkrypton:fix/2574-studio-chat-tab-message-schema

Conversation

@valkrypton

Copy link
Copy Markdown

langchain v1 made BaseMessage generic, which broke three assumptions in the static schema generator and left the messages channel as a degenerate oneOf: [RemoveMessage]. Studio matches this schema to detect messages graphs, so its Chat tab was greyed out for every v1 graph, including a vanilla MessagesAnnotation one.

  • The inheritance map was keyed by a stringified base type. Generic subclasses keep their own type-param names in the extends clause while the one non-generic subclass gets the base's defaults substituted in, so RemoveMessage was the only member that matched at lookup time. Key on the base name with generic arguments erased. The erasure is not anchored on a trailing >, because long instantiations are already "..."-truncated by typeToString before they reach us.
  • Only RemoveMessage is imported by value in the reducer code, so no other subclass declaration entered the per-graph program and the hierarchy walker never discovered them. Reference them in the template.
  • Expanding those subclasses then hit $InferToolCalls<TStructure>, a deferred conditional type the generator cannot model, which aborted the whole schema. Leave such properties unconstrained instead, as already done for any/unknown.
  • Emit the message definitions under bare names, since consumers match them by name. Limited to this hierarchy: erasing arguments globally collides (Record<string,any> and Record<string,string>), and those carried their arguments on v0 too.

Verified against a v0-line baseline: the messages ref and its union are now identical to what v0 emitted.

Fixes #2574

langchain v1 made `BaseMessage` generic, which broke three assumptions in
the static schema generator and left the `messages` channel as a
degenerate `oneOf: [RemoveMessage]`. Studio matches this schema to detect
messages graphs, so its Chat tab was greyed out for every v1 graph,
including a vanilla `MessagesAnnotation` one.

- The inheritance map was keyed by a stringified base type. Generic
  subclasses keep their own type-param names in the extends clause while
  the one non-generic subclass gets the base's defaults substituted in,
  so `RemoveMessage` was the only member that matched at lookup time.
  Key on the base name with generic arguments erased. The erasure is not
  anchored on a trailing `>`, because long instantiations are already
  "..."-truncated by `typeToString` before they reach us.
- Only `RemoveMessage` is imported by value in the reducer code, so no
  other subclass declaration entered the per-graph program and the
  hierarchy walker never discovered them. Reference them in the template.
- Expanding those subclasses then hit `$InferToolCalls<TStructure>`, a
  deferred conditional type the generator cannot model, which aborted
  the whole schema. Leave such properties unconstrained instead, as
  already done for `any`/`unknown`.
- Emit the message definitions under bare names, since consumers match
  them by name. Limited to this hierarchy: erasing arguments globally
  collides (`Record<string,any>` and `Record<string,string>`), and those
  carried their arguments on v0 too.

Verified against a v0-line baseline: the `messages` ref and its union are
now identical to what v0 emitted.

Fixes langchain-ai#2574

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 248854d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@langchain/langgraph-api Patch
@langchain/langgraph-cli Patch
@langchain/langgraph-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@langchain/langgraph-checkpoint

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint@2601

@langchain/langgraph-checkpoint-mongodb

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-mongodb@2601

@langchain/langgraph-checkpoint-postgres

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-postgres@2601

@langchain/langgraph-checkpoint-redis

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-redis@2601

@langchain/langgraph-checkpoint-sqlite

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-sqlite@2601

@langchain/langgraph-checkpoint-validation

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-validation@2601

create-langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/create-langgraph@2601

@langchain/langgraph-api

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-api@2601

@langchain/langgraph-cli

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cli@2601

@langchain/langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph@2601

@langchain/langgraph-cua

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cua@2601

@langchain/langgraph-supervisor

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-supervisor@2601

@langchain/langgraph-swarm

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-swarm@2601

@langchain/langgraph-ui

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-ui@2601

@langchain/langgraph-sdk

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-sdk@2601

@langchain/angular

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/angular@2601

@langchain/react

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/react@2601

@langchain/svelte

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/svelte@2601

@langchain/vue

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/vue@2601

commit: 248854d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio Chat tab greyed out: static schema for messages is degenerate (oneOf:[RemoveMessage]) on langchain v1

1 participant