Skip to main content
Every agent’s run function receives a Task object as its second argument. The task is your agent’s interface to the Guild runtime.
async function run(input: Input, task: Task<Tools>): Promise<Output> {
  // Use task.llm, task.env, task.ui, task.guild, and task.tools
}

Available services

task.llm — Language model calls

Make LLM calls from your agent:
const result = await task.llm.generateText({
  prompt: "Summarize this text...",
})
// result.text contains the model's response
The provider and model are configured at the workspace level. You don’t need to specify them — the runtime resolves them automatically. task.llm is always available.

task.env — Docker environments

Create and manage Docker containers for code execution:
await task.env.create({ baseImage: "node:20" })
const result = await task.env.exec({ command: "npm test" })
await task.env.destroy()
task.env is always available. See environmentTools if you need LLM-accessible Docker tools.

task.tools — Invoke tools directly

Call any tool in your agent’s tool set by name:
const pr = await task.tools.github_pulls_get({
  owner: "myorg",
  repo: "myrepo",
  pull_number: 123,
})
Tool names follow the pattern {service}_{operation} — for example, github_issues_get, github_pulls_list, env_create. See Tool sets for all available tools. task.tools is always available and contains all tools declared in your agent’s tools object.

task.ui — User interaction

Send messages and prompt users for input:
import { progressLogNotifyEvent } from "@guildai/agents-sdk"

// Send a progress update (non-blocking)
await task.ui?.notify(progressLogNotifyEvent("Processing files..."))

// Ask the user a question (blocks until response)
const response = await task.ui?.prompt({
  type: "text",
  text: "Which language should I use?",
})
task.ui is available when your agent includes userInterfaceTools.

task.console — Debug logging

Log messages for debugging and diagnostics:
task.console.log("Processing item", itemId)
task.console is always available. To give an LLM access to debug logging, include consoleTools in your agent’s tools.

task.guild — Platform operations

Search for agents and request credentials:
const agents = await task.guild?.search_agent({
  keywords: ["calculator"],
})

await task.guild?.credentials_request({
  service: "linear",
})
task.guild is available when your agent includes guildTools.

Progress logging

Progress logs give users real-time feedback during long-running operations. They appear inline without requiring user interaction.
import { progressLogNotifyEvent } from "@guildai/agents-sdk"

await task.ui?.notify(progressLogNotifyEvent("Creating coding environment..."))
await task.env.create({ baseImage: "node:20" })

await task.ui?.notify(progressLogNotifyEvent("Running tests..."))
const result = await task.env.exec({ command: "npm test" })
Best practices:
  • Use present continuous tense: “Creating…”, “Running…”, “Writing…”
  • Keep messages to one line
  • Be specific: “Writing 3 files…” rather than “Processing…”
  • Log at meaningful milestones, not on every iteration

Service availability

ServiceWhen available
task.llmAlways
task.envAlways
task.toolsAlways (contains your declared tools)
task.consoleAlways
task.uiRequires userInterfaceTools in tools
task.guildRequires guildTools in tools