I am able to setup assistant config for a single graph but haven’t found a way to:
- Set default value to the values in JS. I can see how to do that with the Pythin Configuration class but JS uses the same signature as state. When I return a default value for the annotation, I don’t see it in the LangGraph UI
- Set config per subgraph. Is this a missing feature? I can see how to set it for supervisors in Python but can’t find it in supervisors for JS.
Hacked my way through it.
Instead of Annotation, use zod. With zod, you can set default values and langraph_nodes
import { MessagesZodState } from "@langchain/langgraph";
import { z } from "zod";
import "@langchain/langgraph/zod";
new StateGraph(MessagesZodState.extend({
classification: z.enum(["task_creation", "general", "invalid"]),
}), z.object({
prompt: z.string().default("You are a helpful assistant that can help with tasks."),
model: z.enum(["gpt-4o", "gpt-4o-mini"]).default("gpt-4o").langgraph.metadata({ langgraph_nodes: ["task_creation"] }),
}))
I also see approaches sometimes where an configuration = ensureConfig(config) function is added. The ensureConfig then initializes a valid config from the runnableconfig and sets defaults if values are missing.