[GH-ISSUE #14] Question: missing Command object when updating graph state from tools #4

Closed
opened 2026-02-16 06:16:46 -05:00 by yindo · 2 comments
Owner

Originally created by @bianbianzhu on GitHub (Aug 20, 2025).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/14

Background

The current implementation of writeTodos tool:

export const writeTodos = tool(
  (input, config: ToolRunnableConfig) => {
    return {
      update: {
        todos: input.todos,
        messages: [
          new ToolMessage({
            content: `Updated todo list to ${JSON.stringify(input.todos)}`,
            tool_call_id: config.toolCall?.id as string,
          }),
        ],
      },
    };
  },
  { /* ... */ }
);
  • The state seems to be updated correctly 🤔.
  • The tool function dose not return a command object.
  • This is not in the official doc.

Question

  • Is this a valid shorthand or it is recommanded to have the command object plz?

The expected way (AFAIK):

// …inside your tool function:
return new Command({
  update: {
    todos: input.todos,
    messages: [
      new ToolMessage({
        content: `Updated todo list to ${JSON.stringify(input.todos)}`,
        tool_call_id: config.toolCall?.id as string,
      }),
    ],
  },
});
Originally created by @bianbianzhu on GitHub (Aug 20, 2025). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/14 ## Background The current implementation of `writeTodos` tool: ```typescript export const writeTodos = tool( (input, config: ToolRunnableConfig) => { return { update: { todos: input.todos, messages: [ new ToolMessage({ content: `Updated todo list to ${JSON.stringify(input.todos)}`, tool_call_id: config.toolCall?.id as string, }), ], }, }; }, { /* ... */ } ); ``` - The state seems to be updated correctly 🤔. - The tool function dose not return a `command` object. - This is not in the official doc. ## Question - Is this a valid shorthand or it is recommanded to have the `command` object plz? --- The expected way (AFAIK): ```typescript // …inside your tool function: return new Command({ update: { todos: input.todos, messages: [ new ToolMessage({ content: `Updated todo list to ${JSON.stringify(input.todos)}`, tool_call_id: config.toolCall?.id as string, }), ], }, }); ```
yindo closed this issue 2026-02-16 06:16:46 -05:00
Author
Owner

@Palashio commented on GitHub (Aug 20, 2025):

good catch! this isn't intended and needs to be fixed.

@Palashio commented on GitHub (Aug 20, 2025): good catch! this isn't intended and needs to be fixed.
Author
Owner

@Palashio commented on GitHub (Aug 22, 2025):

thanks for fixing this!

@Palashio commented on GitHub (Aug 22, 2025): thanks for fixing this!
yindo changed title from Question: missing Command object when updating graph state from tools to [GH-ISSUE #14] Question: missing Command object when updating graph state from tools 2026-06-05 17:20:53 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#4