Skip to content

AgentForceAgent


AgentForceAgent Main Class Agents

Technical documentation for the AgentForceAgent class structure and API.

/**
* Represents an AI agent within the AgentForce framework.
* This class provides the core functionality for creating and managing AI agents,
* including configuration of name, type, AI provider, and model.
*
* @class AgentForceAgent
*/
import {
debug,
useLLM,
serve,
systemPrompt,
prompt,
output,
run,
execute,
saveToFile,
getResponse,
withTemplate,
task,
} from "./agent/mod";
import type {
AgentConfig,
ProviderType,
OutputType,
AgentForceLogger,
ModelConfig,
} from "./types";
import { defaultLogger } from "./logger";
constructor(config: AgentConfig)

Parameters:

  • config: AgentConfig - Configuration object containing agent initialization settings

Description: Constructs the AgentForceAgent class with the provided configuration. Initializes the agent’s name, tools, skills, and logger from the config object.

private name: string;
private agentSystemPrompt: string = "You are an AI agent created by AgentForceZone. You can perform various tasks based on the methods provided.";
private userPrompt: string = "";
private template: string = "";
private tools: string[] = [];
private skills: string[] = [];
private taskList: {description: string, result: string | null}[] = [];
private chatHistory: {role: string, content: string}[] = [];
private logger: AgentForceLogger;
private provider: string = "ollama";
private model: string = "gemma3:4b";
private modelConfig?: ModelConfig;
protected getName(): string
protected getTools(): string[]
protected getSkills(): string[]
protected getUserPrompt(): string
protected getSystemPrompt(): string
protected getTemplate(): string
protected getModel(): string
protected getProvider(): string
protected getModelConfig(): ModelConfig | undefined
protected getChatHistory(): {role: string, content: string}[]
protected getLogger(): AgentForceLogger
protected getTaskList(): {description: string, result: string | null}[]
protected setUserPrompt(prompt: string): void
protected setSystemPrompt(prompt: string): void
protected setTemplate(template: string): void
protected setModel(model: string): void
protected setProvider(provider: string): void
protected setModelConfig(config?: ModelConfig): void
protected setTaskList(taskList: {description: string, result: string | null}[]): void
protected pushToChatHistory(role: string, content: string): void
protected clearTaskList(): void
protected execute(userPrompt?: string): Promise<string>

Returns AgentForceAgent instance for method chaining:

debug(): AgentForceAgent
useLLM(provider?: ProviderType, model?: string, modelConfig?: ModelConfig): AgentForceAgent
systemPrompt(prompt: string): AgentForceAgent
prompt(userPrompt: string): AgentForceAgent
withTemplate(templatePath: string, templateData?: Record<string, unknown>): AgentForceAgent
task(taskDescription: string): AgentForceAgent
run(): Promise<AgentForceAgent>

Execute the agent and return results (ends the chain):

serve(host?: string, port?: number): Promise<void>
output(outputType: OutputType): Promise<string | object>
getResponse(): Promise<string>
saveToFile(fileName: string): Promise<string>

All public methods are bound to their respective implementations from the ./agent/mod module:

// Chainable methods
debug: () => AgentForceAgent = debug.bind(this);
useLLM: (provider?: ProviderType, model?: string, modelConfig?: ModelConfig) => AgentForceAgent = useLLM.bind(this);
systemPrompt: (prompt: string) => AgentForceAgent = systemPrompt.bind(this);
prompt: (userPrompt: string) => AgentForceAgent = prompt.bind(this);
withTemplate: (templatePath: string, templateData?: Record<string, unknown>) => AgentForceAgent = withTemplate.bind(this);
task: (taskDescription: string) => AgentForceAgent = task.bind(this);
run: () => Promise<AgentForceAgent> = run.bind(this);
// Execute methods
serve: (host?: string, port?: number) => Promise<void> = serve.bind(this);
output: (outputType: OutputType) => Promise<string | object> = output.bind(this);
getResponse: () => Promise<string> = getResponse.bind(this);
saveToFile: (fileName: string) => Promise<string> = saveToFile.bind(this);