ClinkClang
clinkclang-docs
Agents
Last updated: 1/27/2025

The Agent Core is a flexible system that enables integration with various AI providers and frameworks while managing conversation flow and tool usage.

Creating an Agent

To create a new agent, use the Agent class with a configuration object.

const agent = new Agent({
  providerName: "openai", // or "claude", "huggingface", "deepseek"
  modelName: "gpt-4",
  apiKey: "your-api-key",
  // Optional parameters
  temperature?: number,
  systemPrompt?: string,
  maxTokens?: number,
  version?: string,
  tools?: Tool[],
  structure?: {
    strict?: boolean,
    maxRetries?: number,
    debug?: boolean
  },
  outputSchema?: Schema,
  retries?: number,
  strategy?: StrategyName
});

Configuration Options

ParameterTypeRequiredDescription
providerNameProviderNameYesAI provider to use (“openai”, “claude”, “huggingface”, “deepseek”)
modelNamestringYesName of the model to use
apiKeystringYesAPI key for the selected provider
temperaturenumberNoControls randomness in responses
systemPromptstringNoInitial system prompt for the conversation
maxTokensnumberNoMaximum tokens in response
versionstringNoProvider API version (if applicable)
toolsToolNoArray of tools available to the agent
structureobjectNoConfiguration for structured output
outputSchemaSchemaNoSchema for validating outputs
retriesnumberNoNumber of retries for failed requests
strategyStrategyNameNoStrategy to use (“react” or “reflexion”)

Providers

The Agent Core supports multiple AI providers through a provider interface. Each provider implements the Base class:

abstract class Base {
  protected config: ModelConfig;

  constructor(config: ModelConfig) {
    this.config = config;
  }

  abstract generateResponse(
    messages: Message[],
    tools?: any[] 
  ): Promise<ModelResponse>;
}

Supported Providers

Currently supported providers:

  • OpenAI
  • Claude
  • DeepSeek

Adding a New Provider

To add a new provider:

  1. Create a new provider class that extends the Base class
  2. Implement the required generateResponse method
  3. Add the provider name to the ProviderName type
export class CustomProvider extends Base {
  async generateResponse(
    messages: Message[],
    tools?: any[]
  ): Promise<ModelResponse> {
    // Implementation here
  }
}

Tools

Tools can be added to extend the agent’s capabilities. Each tool must implement the Tool interface:

interface Tool {
  name: string;
  description: string;
  parameters: z.ZodObject<any>;
  execute: (args: any) => Promise<any>;
}

Tools are automatically described to the model in a formatted way:

Tool Name: [name]
Description: [description]
Parameters: {param1: type, param2: type}
Usage: toolCall: toolName({"param": "value"})

Strategies

The Agent Core can support diffeerent reasoning strategies for processing (defaulting to ReAct):

  • ReAct: Reasoning and Acting framework

The framework can be specified in the agent configuration using the strategy parameter.

Usage Example

// Create an agent with OpenAI
const agent = new Agent({
  providerName: "openai",
  modelName: "gpt-4",
  apiKey: process.env.OPENAI_API_KEY,
  tools: [myCustomTool],
  strategy: "react"
});

// Generate a response
const response = await agent.generate("What's the weather like?");

For more examples, check the packages/examples directory.

pnpm dlx clinkclang@latest add agent-examples