Skip to content

LLM Agents

An agent is a special kind of tool that uses an inline prompt and tools to solve a task.

Usage

We want to build a script that can investigate the most recent run failures in a GitHub repository using GitHub Actions. To do so, we probably will need to the following agents:

  • query the GitHub API, agent_github
  • compute some git diff to determine which changes broken the build, agent_git
  • read or search files agent_fs
github-investigator.genai.mts
script({
tools: ["agent_fs", "agent_git", "agent_github", ...],
...
})

Each of these agent is capable of calling an LLM with a specific set of tools to accomplish a task.

The full script source code is available below:

github-investigator.genai.mts
script({
tools: ["agent_fs", "agent_git", "agent_github", "agent_interpreter"],
parameters: {
workflow: { type: "string" }, // Workflow name
failure_run_id: { type: "number" }, // ID of the failed run
success_run_id: { type: "number" }, // ID of the successful run
branch: { type: "string" }, // Branch name
},
})
const {
workflow = "latest failed",
failure_run_id = "latest",
branch = await git.defaultBranch(),
} = env.vars
$`Investigate the status of the ${workflow} workflow and identify the root cause of the failure of run ${failure_run_id} in branch ${branch}.
- Correlate the failure with the relevant commits, pull requests or issues.
- Compare the source code between the failed run and the last successful run before that run.
In your report, include html links to the relevant runs, commits, pull requests or issues.
`

To split or not to split

You could try to load all the tools in the same LLM call and run the task as a single LLM conversation. Results may vary.

github-investigator.genai.mts
script({
tools: ["fs", "git", "github", ...],
...
})