Agent ✅
The Agent
class is the foundation for creating AI agents in Kastrax. It provides methods for generating responses, streaming interactions, and handling voice capabilities.
Importing ✅
import { Agent } from "@kastrax/core/agent";
Constructor ✅
Creates a new Agent instance with the specified configuration.
constructor(config: AgentConfig<TAgentId, TTools, TMetrics>)
Parameters
name:
string
Unique identifier for the agent.
instructions:
string | ({ runtimeContext: RuntimeContext }) => string | Promise<string>
Instructions that guide the agent's behavior. Can be a static string or a function that returns a string.
model:
KastraxLanguageModel | ({ runtimeContext: RuntimeContext }) => KastraxLanguageModel | Promise<KastraxLanguageModel>
The language model to use for generating responses. Can be a model instance or a function that returns a model.
tools?:
ToolsInput | ({ runtimeContext: RuntimeContext }) => ToolsInput | Promise<ToolsInput>
Tools that the agent can use. Can be a static object or a function that returns tools.
defaultGenerateOptions?:
AgentGenerateOptions
Default options to use when calling generate().
defaultStreamOptions?:
AgentStreamOptions
Default options to use when calling stream().
evals?:
Record<string, Metric>
Evaluation metrics for assessing agent performance.
memory?:
KastraxMemory
Memory system for the agent to store and retrieve information.
voice?:
CompositeVoice
Voice capabilities for speech-to-text and text-to-speech functionality.
Last updated on