Configuration Methods
Chainable - Configure agent behavior
.useLLM()
- Provider & model.systemPrompt()
- System instructions.withTemplate()
- Template loading.debug()
- Debug logging
The AgentForceAgent
class is the core component of the AgentForce ADK, providing a fluent API for configuring and executing AI agents with various LLM providers, tools, skills, and MCP (Model Context Protocol) integrations.
The constructor accepts an AgentConfig object with the following properties:
name
(string): Required - Unique identifier for the agenttools?
(ToolType[]): Optional array of built-in tools available to the agentskills?
(string[]): Optional array of skill file paths to auto-loadmcps?
(string[]): Optional array of MCP server names (local and remote)mcpConfig?
(string): Optional path to agent-specific MCP configurationassetPath?
(string): Optional base path for agent assets and resourceslogger?
(AgentForceLogger): Optional custom logger instance.useLLM()
Chainable
Optional
.systemPrompt()
Chainable
Optional
.withTemplate()
Chainable
Optional
.debug()
Chainable
Optional
.addMCP()
Chainable
Optional
.prompt()
Chainable
Required
.task()
Chainable
Optional
.getResponse()
Terminal • Async
Optional
.output()
Terminal • Async
Optional
.saveToFile()
Terminal • Async
Optional
Configuration Methods
Chainable - Configure agent behavior
.useLLM()
- Provider & model.systemPrompt()
- System instructions.withTemplate()
- Template loading.debug()
- Debug loggingExtension Methods
Chainable - Extend capabilities
.addMCP()
- MCP server integrationTask Methods
Chainable - Define work
.prompt()
- Main user prompt.task()
- Sequential tasksExecution Methods
Terminal - Get results
.getResponse()
- Raw response.output()
- Formatted output.saveToFile()
- File outputimport { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "MyAgent" }) .useLLM("ollama", "phi4-mini:latest") .systemPrompt("You are a helpful TypeScript expert") .prompt("Explain the key benefits of TypeScript over JavaScript");
const response = await agent.getResponse();console.log(response);
import { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "DocsAgent", mcps: ["filesystem", "agentforce-adk-docs"] // Local and remote MCP servers}) .addMCP({ name: "custom-docs", type: "sse", url: "https://gitmcp.io/your-org/your-repo" }) .useLLM("openrouter", "z-ai/glm-4.5v") .systemPrompt("You are a documentation expert with access to code and docs") .prompt("Analyze the codebase structure and create API documentation");
const documentation = await agent.output("md");
import { AgentForceAgent, type AgentConfig } from '@agentforce/adk';
const config: AgentConfig = { name: "FullStackAgent", tools: ["fs_read_file", "fs_write_file", "web_fetch"], skills: ["full-stack-development", "api-design"], assetPath: "./agent-assets"};
const agent = new AgentForceAgent(config) .useLLM("google", "gemini-2.5-pro") .systemPrompt("You are a full-stack development expert") .withTemplate("./templates/project-setup.hbs", { projectName: "MyApp", framework: "Next.js" });
const projectPlan = await agent.saveToFile("project-plan.md");
The AgentForceAgent follows a fluent API pattern where most methods return this
for chaining:
// All these methods are chainableconst agent = new AgentForceAgent({ name: "ChainedAgent" }) .useLLM("ollama", "gpt-oss") // Configure provider .addMCP("filesystem") // Add MCP capability .systemPrompt("You are an expert...") // Set behavior .withTemplate("./template.hbs", data) // Load template .prompt("Analyze this code...") // Set task .debug(); // Enable debugging
// Terminal methods end the chain and executeconst result = await agent.output("json"); // Execute and get result
All methods include built-in error handling that maintains the fluent API:
try { const agent = new AgentForceAgent({ name: "SafeAgent" }) .useLLM("ollama", "gpt-oss") .addMCP("filesystem") .systemPrompt("You are a helpful assistant") .prompt("Help me with this task") .debug();
const response = await agent.output("text"); console.log("Success:", response);} catch (error) { console.error("Agent Error:", error.message); // Handle provider errors, MCP connection issues, etc.}