Typesafe graph.invoke? #124

Closed
opened 2026-02-15 17:16:01 -05:00 by yindo · 3 comments
Owner

Originally created by @austinm911 on GitHub (Oct 24, 2024).

As far as I can tell, is there not a way to make the invoke method typesafe with the options argument await graph.invoke({ key1: value })?

Expected Output

const StateAnnotation = Annotation.Root({
	messages: Annotation<string[]>({
		reducer: (x, y) => x.concat(y),
	}),
})

// Define a new graph
const workflow = new StateGraph(StateAnnotation)

const app = workflow.compile()

const result = await app.invoke({ keyDoesNotExist: 'hi' }) // type error here
Originally created by @austinm911 on GitHub (Oct 24, 2024). As far as I can tell, is there not a way to make the invoke method typesafe with the options argument `await graph.invoke({ key1: value })`? ## Expected Output ```ts const StateAnnotation = Annotation.Root({ messages: Annotation<string[]>({ reducer: (x, y) => x.concat(y), }), }) // Define a new graph const workflow = new StateGraph(StateAnnotation) const app = workflow.compile() const result = await app.invoke({ keyDoesNotExist: 'hi' }) // type error here ```
yindo closed this issue 2026-02-15 17:16:01 -05:00
Author
Owner

@jacoblee93 commented on GitHub (Oct 25, 2024):

Yeah this would be awesome to add - have a lot of work to do in general on inputs/outputs. Thanks for flagging!

@jacoblee93 commented on GitHub (Oct 25, 2024): Yeah this would be awesome to add - have a lot of work to do in general on inputs/outputs. Thanks for flagging!
Author
Owner

@anushak18 commented on GitHub (Nov 1, 2024):

Hi! I am a 4th year student at the University of Toronto studying Computer Science. I’m working with my teammates @khushiDesai, @ashvini8, and @ssumaiyaahmed, who are also 4th year students studying Computer Science at UofT. We would like to take on this issue of making the invoke method typesafe.

@anushak18 commented on GitHub (Nov 1, 2024): Hi! I am a 4th year student at the University of Toronto studying Computer Science. I’m working with my teammates @khushiDesai, @ashvini8, and @ssumaiyaahmed, who are also 4th year students studying Computer Science at UofT. We would like to take on this issue of making the invoke method typesafe.
Author
Owner

@jacoblee93 commented on GitHub (Nov 1, 2024):

I think it will be a bit tricky to get right but would love your help!

Thanks for offering @anushak18.

@jacoblee93 commented on GitHub (Nov 1, 2024): I think it will be a bit tricky to get right but would love your help! Thanks for offering @anushak18.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#124