Skip to main content

Overview

Use withAgent(options, fn) for agentic patterns where an agent orchestrates multiple tools or sub-tasks. Agents are specialized workflow units designed for AI agent architectures.

Signature

Basic Usage

Agent with Tools

Multi-Agent Workflow

With OpenAI Integration

Parameters

string
required
Agent display name for identification in the Keywords AI dashboard
number
Version number for tracking agent iterations
Record<string, any>
Custom metadata to associate with the agent (agent type, model, user context, etc.)

Return Value

Returns a Promise that resolves to the return value of the provided function.

Best Practices

  • Use agents for autonomous decision-making components
  • Nest tools within agents to track tool usage
  • Add association properties to identify agent types and contexts
  • Combine multiple agents in workflows for complex multi-agent systems
  • Agents automatically capture all nested tool calls and LLM interactions