How to call a tool directly in a subgraph?

How to call a tool directly?

I have a StateGraph with some subgraphs (react agents). Inside one agent, I need to ask a customer to perform OAuth. We have a custom chat app, and the customer will see a button inside the chat labeled “Connect Google account.”After performing authorization, we have to continue the graph execution (tool calling).

The problem is that the customer can ask another question and ignore oauth button, but if we use an interrupt mechanism, we will have an incomplete tool call inside a message history, which causes improper execution.

But without an interrupt mechanism, I don’t know how to continue performing a task.

How to call a tool inside the OAuth webhook processing?

I believe you have 2 options here:
1. Delete the AI Message (you can use RemoveMessage for this) - because the LLM providers will not accept a human message immediately following an AI message with a tool call

  1. Return a dummy ToolMessage (i.e. a ToolMessage with content like “human did not approve”) and then put the human message after that