Agents (LLM Tools)
GenAIScript defines an agent as a tool that runs an inline prompt to accomplish a task. The agent’s LLM is typically augmented with additional tools.
Agent orchestration
GenAIScript does not implement any agentic workflow or decision. It relies entirely on tools support built into the LLMs.
defAgent
The defAgent
function is used to define an agent that can be called by the LLM. It takes a JSON schema to define the input and expects a string output. The LLM autonomously decides to call this agent.
- the agent id will become the tool id
agent_<id>
- the description of the agent will automatically be augmented with information about the available tools
Builtin Agents
Example agent_github
Let’s illustrate this by building a GitHub agent. The agent is a tool that receives a query and executes an LLM prompt with GitHub-related tools.
The definition of the agent looks like this:
and internally it is expanded to the following:
Inside callback, we use runPrompt
to run an LLM query.
- the prompt takes the query argument and tells the LLM how to handle it.
- note the use of
ctx.
for nested prompts
Selecting the Tools and System Prompts
We use the system
parameter to configure the tools exposed to the LLM. In this case, we expose the GitHub tools (system.github_files
, system.github_issues
, …)
This full source of this agent is defined in the system.agent_github system prompt.