GraphAI - ToolsAgent
ToolsAgent
GraphAI provides ToolsAgent components that use LLMs to dynamically invoke agents from natural language input.
If you imagine MCP, it’s easier to understand: a ToolsAgent is an agent that allows an LLM to call functions (Agents) by providing the LLM with a tools (function call) schema. Internally, it passes the tools schema to an OpenAI LLM agent, then dynamically calls the appropriate agent(s) within GraphAI based on the tool_calls included in the response.
The process flow is as follows:
GraphData Definition in GraphAI
When using GraphAI, the GraphData definition is essentially the same as with any LLM agent such as OpenAI.
- Pass messages and prompt to the ToolsAgent.
- You can specify the LLM agent via inputs.llmAgent, though openAIAgent is typically used.
- Pass the schema of the available tools in tools.
toolsLlmNode: {
isResult: true,
agent: "toolsAgent",
inputs: {
llmAgent: "openAIAgent",
tools: ":tools",
messages: ":messages",
userInput: {
text: ":prompt",
},
},
}
Here is a sample of the data passed to tools.
The main difference from a standard Tools schema is in the function naming convention:
function names are in the format agentName--functionNameWithinAgent.
This is a GraphAI-specific naming rule used to both uniquely identify functions across multiple agents and specify which agent should be called.
Other than this naming rule, the schema conforms to the standard OpenAI tools schema.
[
{
type: "function",
function: {
name: "googleMapAgent--setCenter",
description: "set center location",
parameters: {
type: "object",
properties: {
lat: {
type: "number",
description: "latitude of center",
},
lng: {
type: "number",
description: "longtitude of center",
},
},
required: ["lat", "lng"],
},
},
},
{
type: "function",
function: {
name: "googleMapAgent--getCenter",
description: "get center location",
parameters: {
type: "object",
properties: {},
},
},
},
]
When you pass a prompt to this GraphData, GraphAI will either: Invoke a function based on the prompt’s content, or Return a regular chat response.
Spec for Agents Invoked by toolsAgent
Agents called from a toolsAgent receive data in the following format:
- namedInputs
- agentName - tool.name(funciton name)
- arg - tool.arguments
- func - tool.name(funciton name)
- data - passthrough from parent
Within the data passed:
- arg contains the arguments generated by the LLM.
- func contains the function name expected within the agent.Even if the agent has only one processing function, func will still be provided. You may ignore it if it is unnecessary.
- For agents with multiple internal operations (e.g., googleMapAgent in the example above), use the func value to determine which operation to execute.
Return value format:
-
result
- content
- data
-
content: Set this to the text that will be passed to the next LLM execution.
-
data: Set this to any data returned after GraphAI execution or received via a callback.
agentFunctionInfo
Set the tools schema in agentFunctionInfo.
sample
Agent for Controlling the Google Maps API in the Browser
Agent for Controlling a Video Player in the Browser
mulmo scriptのvalidator
Agent that uses Exa for web search
Agent that crawls websites on the Node side using Electron
Source code for the ToolsAgent
Implemented in GraphAI
Sample usage

人工知能を活用したアプリケーションやサービスを活用し、内発的動機付けで行動するエンジニア、起業家、社会起業家をサポートするコミュニティーです。 singularitysociety.org Supported by 週刊 Life is beautiful
Discussion