def get_tool_call()

in databao/executors/frontend/messages.py [0:0]


def get_tool_call(messages: list[BaseMessage], tool_message: ToolMessage) -> ToolCall | None:
    """Returns the tool call which caused the ToolMessage."""
    for message in reversed(messages):
        if isinstance(message, AIMessage):
            for tool_call in message.tool_calls:
                if tool_call["id"] == tool_message.tool_call_id:
                    return tool_call
    return None