fix(langgraph-api): restore full message union in generated schemas - #2601
Open
Ali Tariq (valkrypton) wants to merge 1 commit into
Open
fix(langgraph-api): restore full message union in generated schemas#2601Ali Tariq (valkrypton) wants to merge 1 commit into
Ali Tariq (valkrypton) wants to merge 1 commit into
Conversation
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 detectedLatest commit: 248854d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
@langchain/langgraph-checkpoint
@langchain/langgraph-checkpoint-mongodb
@langchain/langgraph-checkpoint-postgres
@langchain/langgraph-checkpoint-redis
@langchain/langgraph-checkpoint-sqlite
@langchain/langgraph-checkpoint-validation
create-langgraph
@langchain/langgraph-api
@langchain/langgraph-cli
@langchain/langgraph
@langchain/langgraph-cua
@langchain/langgraph-supervisor
@langchain/langgraph-swarm
@langchain/langgraph-ui
@langchain/langgraph-sdk
@langchain/angular
@langchain/react
@langchain/svelte
@langchain/vue
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
langchain v1 made
BaseMessagegeneric, which broke three assumptions in the static schema generator and left themessageschannel as a degenerateoneOf: [RemoveMessage]. Studio matches this schema to detect messages graphs, so its Chat tab was greyed out for every v1 graph, including a vanillaMessagesAnnotationone.RemoveMessagewas 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 bytypeToStringbefore they reach us.RemoveMessageis 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.$InferToolCalls<TStructure>, a deferred conditional type the generator cannot model, which aborted the whole schema. Leave such properties unconstrained instead, as already done forany/unknown.Record<string,any>andRecord<string,string>), and those carried their arguments on v0 too.Verified against a v0-line baseline: the
messagesref and its union are now identical to what v0 emitted.Fixes #2574