Class: Agent<TContext, TOutput>
Defined in: packages/kernl/src/agent.ts:34
Extends
BaseAgent<TContext,TOutput>
Type Parameters
| Type Parameter | Default type |
|---|---|
TContext | UnknownContext |
TOutput extends AgentOutputType | TextOutput |
Implements
AgentConfig<TContext,TOutput>
Constructors
Constructor
new Agent<TContext, TOutput>(config: AgentConfig<TContext, TOutput>): Agent<TContext, TOutput>;Defined in: packages/kernl/src/agent.ts:52
Parameters
| Parameter | Type |
|---|---|
config | AgentConfig<TContext, TOutput> |
Returns
Agent<TContext, TOutput>
Overrides
BaseAgent<TContext, TOutput>.constructorProperties
| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|---|---|
description? | readonly | string | undefined | - | - | AgentConfig.description Agent.description | packages/kernl/src/agent/base.ts:58 |
guardrails | readonly | { input: InputGuardrail[]; output: OutputGuardrail<AgentOutputType>[]; } | undefined | A list of checks that run in parallel to the agent's execution on the input + output for the agent, depending on the configuration. | - | - | packages/kernl/src/agent.ts:45 |
guardrails.input | public | InputGuardrail[] | undefined | - | - | - | packages/kernl/src/agent.ts:46 |
guardrails.output | public | OutputGuardrail<AgentOutputType>[] | undefined | - | - | - | packages/kernl/src/agent.ts:47 |
id | readonly | string | undefined | - | - | AgentConfig.id Agent.id | packages/kernl/src/agent/base.ts:56 |
instructions | readonly | (context: Context<TContext>) => string | Promise<string> | undefined | - | - | AgentConfig.instructions BaseAgent.instructions | packages/kernl/src/agent/base.ts:59 |
kernl? | protected | Kernl | undefined | - | - | Agent.kernl | packages/kernl/src/agent/base.ts:51 |
kind | readonly | "llm" | "llm" | - | BaseAgent.kind | - | packages/kernl/src/agent.ts:41 |
memory | readonly | AgentMemoryConfig | undefined | - | - | AgentConfig.memory Agent.memory | packages/kernl/src/agent/base.ts:64 |
model | readonly | LanguageModel | undefined | - | AgentConfig.model BaseAgent.model | - | packages/kernl/src/agent.ts:42 |
modelSettings | readonly | LanguageModelRequestSettings | undefined | Configures model-specific tuning parameters (e.g. temperature, top_p, etc.) | - | - | packages/kernl/src/agent.ts:43 |
name | readonly | string | undefined | - | - | AgentConfig.name Agent.name | packages/kernl/src/agent/base.ts:57 |
output | readonly | TOutput | undefined | The type of the output that the agent will return. Can be either: - "text" (default): The agent returns a plain string response - A Zod schema: The agent returns structured output validated against the schema When a Zod schema is provided, the output is converted to JSON Schema and sent to the model for native structured output support. The response is then validated against the Zod schema as a safety net. | - | - | packages/kernl/src/agent.ts:49 |
resetToolChoice | readonly | boolean | undefined | Whether to reset the tool choice to the default value after a tool has been called. Defaults to true. This ensures that the agent doesn't enter an infinite loop of tool usage. | - | - | packages/kernl/src/agent.ts:50 |
systools | readonly | BaseToolkit<TContext>[] | undefined | - | - | BaseAgent.systools | packages/kernl/src/agent/base.ts:63 |
toolkits | readonly | BaseToolkit<TContext>[] | undefined | - | - | AgentConfig.toolkits BaseAgent.toolkits | packages/kernl/src/agent/base.ts:62 |
Accessors
memories
Get Signature
get memories(): {
create: (params: AgentMemoryCreate) => Promise<MemoryRecord>;
list: (params?: Omit<MemoryListOptions, "filter"> & {
collection?: string;
limit?: number;
}) => Promise<MemoryRecord[]>;
search: (params: Omit<MemorySearchQuery, "filter"> & {
filter?: Omit<MemoryFilter, "scope"> & {
scope?: Omit<Partial<MemoryScope>, "agentId">;
};
}) => Promise<SearchHit<IndexMemoryRecord>[]>;
update: (params: AgentMemoryUpdate) => Promise<MemoryRecord>;
};Defined in: packages/kernl/src/agent/base.ts:158
Memory management scoped to this agent.
Returns
{
create: (params: AgentMemoryCreate) => Promise<MemoryRecord>;
list: (params?: Omit<MemoryListOptions, "filter"> & {
collection?: string;
limit?: number;
}) => Promise<MemoryRecord[]>;
search: (params: Omit<MemorySearchQuery, "filter"> & {
filter?: Omit<MemoryFilter, "scope"> & {
scope?: Omit<Partial<MemoryScope>, "agentId">;
};
}) => Promise<SearchHit<IndexMemoryRecord>[]>;
update: (params: AgentMemoryUpdate) => Promise<MemoryRecord>;
}| Name | Type | Defined in |
|---|---|---|
create() | (params: AgentMemoryCreate) => Promise<MemoryRecord> | packages/kernl/src/agent/base.ts:183 |
list() | (params?: Omit<MemoryListOptions, "filter"> & { collection?: string; limit?: number; }) => Promise<MemoryRecord[]> | packages/kernl/src/agent/base.ts:169 |
search() | (params: Omit<MemorySearchQuery, "filter"> & { filter?: Omit<MemoryFilter, "scope"> & { scope?: Omit<Partial<MemoryScope>, "agentId">; }; }) => Promise<SearchHit<IndexMemoryRecord>[]> | packages/kernl/src/agent/base.ts:210 |
update() | (params: AgentMemoryUpdate) => Promise<MemoryRecord> | packages/kernl/src/agent/base.ts:200 |
Inherited from
BaseAgent.memoriesthreads
Get Signature
get threads(): {
create: (params: Omit<ThreadCreateParams, "agentId" | "model">) => Promise<Thread>;
delete: (tid: string) => Promise<void>;
get: (tid: string, options?: ThreadGetOptions) => Promise<Thread | null>;
history: (tid: string, params?: ThreadHistoryParams) => Promise<ThreadEvent[]>;
list: (params: Omit<ThreadsListParams, "agentId">) => Promise<CursorPage<Thread, ThreadsListParams>>;
update: (tid: string, patch: ThreadUpdateParams) => Promise<Thread | null>;
};Defined in: packages/kernl/src/agent.ts:210
Thread management scoped to this agent.
Convenience wrapper around kernl.threads that automatically filters to this agent's threads.
Returns
{
create: (params: Omit<ThreadCreateParams, "agentId" | "model">) => Promise<Thread>;
delete: (tid: string) => Promise<void>;
get: (tid: string, options?: ThreadGetOptions) => Promise<Thread | null>;
history: (tid: string, params?: ThreadHistoryParams) => Promise<ThreadEvent[]>;
list: (params: Omit<ThreadsListParams, "agentId">) => Promise<CursorPage<Thread, ThreadsListParams>>;
update: (tid: string, patch: ThreadUpdateParams) => Promise<Thread | null>;
}| Name | Type | Defined in |
|---|---|---|
create() | (params: Omit<ThreadCreateParams, "agentId" | "model">) => Promise<Thread> | packages/kernl/src/agent.ts:228 |
delete() | (tid: string) => Promise<void> | packages/kernl/src/agent.ts:225 |
get() | (tid: string, options?: ThreadGetOptions) => Promise<Thread | null> | packages/kernl/src/agent.ts:221 |
history() | (tid: string, params?: ThreadHistoryParams) => Promise<ThreadEvent[]> | packages/kernl/src/agent.ts:226 |
list() | (params: Omit<ThreadsListParams, "agentId">) => Promise<CursorPage<Thread, ThreadsListParams>> | packages/kernl/src/agent.ts:223 |
update() | (tid: string, patch: ThreadUpdateParams) => Promise<Thread | null> | packages/kernl/src/agent.ts:237 |
Methods
bind()
bind(kernl: Kernl): void;Defined in: packages/kernl/src/agent/base.ts:92
Bind this agent to a kernl instance. Called by kernl.register().
Parameters
| Parameter | Type |
|---|---|
kernl | Kernl |
Returns
void
Inherited from
BaseAgent.bindemit()
emit<K>(event: K, ...args: AgentHookEvents<TContext, TOutput>[K]): boolean;Defined in: packages/kernl/src/agent/base.ts:107
Emit a lifecycle event to agent and kernl listeners.
Type Parameters
| Type Parameter |
|---|
K extends keyof AgentHookEvents<TContext, TOutput> |
Parameters
| Parameter | Type |
|---|---|
event | K |
...args | AgentHookEvents<TContext, TOutput>[K] |
Returns
boolean
Inherited from
BaseAgent.emitoff()
off<K>(event: K, listener: (...args: AgentHookEvents<TContext, TOutput>[K]) => void): this;Defined in: packages/shared/dist/emitter.d.ts:26
Type Parameters
| Type Parameter |
|---|
K extends keyof AgentHookEvents<TContext, TOutput> |
Parameters
| Parameter | Type |
|---|---|
event | K |
listener | (...args: AgentHookEvents<TContext, TOutput>[K]) => void |
Returns
this
Inherited from
BaseAgent.offon()
on<K>(event: K, listener: (...args: AgentHookEvents<TContext, TOutput>[K]) => void): this;Defined in: packages/shared/dist/emitter.d.ts:25
Type Parameters
| Type Parameter |
|---|
K extends keyof AgentHookEvents<TContext, TOutput> |
Parameters
| Parameter | Type |
|---|---|
event | K |
listener | (...args: AgentHookEvents<TContext, TOutput>[K]) => void |
Returns
this
Inherited from
BaseAgent.ononce()
once<K>(event: K, listener: (...args: AgentHookEvents<TContext, TOutput>[K]) => void): this;Defined in: packages/shared/dist/emitter.d.ts:27
Type Parameters
| Type Parameter |
|---|
K extends keyof AgentHookEvents<TContext, TOutput> |
Parameters
| Parameter | Type |
|---|---|
event | K |
listener | (...args: AgentHookEvents<TContext, TOutput>[K]) => void |
Returns
this
Inherited from
BaseAgent.oncerun()
run(input:
| string
| LanguageModelItem[], options?: ThreadExecuteOptions<TContext>): Promise<ThreadExecuteResult<ResolvedAgentResponse<TOutput>>>;Defined in: packages/kernl/src/agent.ts:70
Blocking execution - spawns or resumes thread and waits for completion
Parameters
| Parameter | Type |
|---|---|
input | | string | LanguageModelItem[] |
options? | ThreadExecuteOptions<TContext> |
Returns
Promise<ThreadExecuteResult<ResolvedAgentResponse<TOutput>>>
Throws
If the specified thread is already running (concurrent execution not allowed)
Throws
If the agent is not bound to a kernl instance
stream()
stream(input:
| string
| LanguageModelItem[], options?: ThreadExecuteOptions<TContext>): AsyncIterable<ThreadStreamEvent>;Defined in: packages/kernl/src/agent.ts:141
Streaming execution - spawns or resumes thread and returns async iterator
NOTE: streaming probably won't make sense in scheduling contexts so spawnStream etc. won't make sense
Parameters
| Parameter | Type |
|---|---|
input | | string | LanguageModelItem[] |
options? | ThreadExecuteOptions<TContext> |
Returns
AsyncIterable<ThreadStreamEvent>
Throws
If the specified thread is already running (concurrent execution not allowed)
Throws
If the agent is not bound to a kernl instance
tool()
tool(id: string): Tool<TContext> | undefined;Defined in: packages/kernl/src/agent/base.ts:119
Get a specific tool by ID from systools and toolkits.
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Tool<TContext> | undefined
Inherited from
BaseAgent.tooltools()
tools(context: Context<TContext>): Promise<Tool<TContext>[]>;Defined in: packages/kernl/src/agent/base.ts:136
Get all tools available from systools and toolkits for the given context.
Parameters
| Parameter | Type |
|---|---|
context | Context<TContext> |
Returns
Promise<Tool<TContext>[]>
Inherited from
BaseAgent.tools