Overview
AgentLIB is fully typed with TypeScript. This reference documents the core types and interfaces used throughout the library.Model Types
ModelMessage
Represents a single message in a conversation.The role of the message sender.
The text content of the message.
Extended thinking or reasoning content (for models that support extended reasoning).
ID linking this message to a tool call (for
role: 'tool' messages).Array of tool calls requested by the assistant.
ToolCall
Represents a request to execute a tool.Unique identifier for this tool call.
Name of the tool to execute.
Arguments to pass to the tool.
ModelRequest
Request sent to a model provider.Conversation history.
Available tools the model can use.
Whether to stream the response.
ModelResponse
Response from a model provider.The generated message.
Tool calls requested by the model.
Token usage statistics.
Raw response from the provider.
TokenUsage
Token usage statistics.Number of tokens in the prompt.
Number of tokens in the completion.
Total tokens used (prompt + completion).
ModelProvider
Interface that all model providers must implement.Provider name.
Generate a completion.
Stream a completion (optional).
Tool Types
ToolSchema
JSON Schema definition for a tool.Tool name (must be unique).
Human-readable description of what the tool does.
JSON Schema object describing the tool’s parameters.
ToolDefinition
Complete tool definition including execution logic.The tool’s schema.
Function that executes the tool.
Memory Types
MemoryEntry
A single stored memory entry with metadata.Unique entry identifier.
Session this entry belongs to.
Conversation messages in this entry.
Entry metadata.
MemoryMetadata
Metadata associated with a memory entry.When the entry was created.
When the entry was last accessed.
Agent that created this entry.
Arbitrary key/value tags for filtering.
Token count estimate for this entry.
MemoryReadOptions
Options for reading from memory.Maximum number of messages to return.
Only return messages from this session.
Semantic query for vector-based providers.
Filter by metadata tags.
MemoryWriteOptions
Options for writing to memory.Session identifier for this write.
Tags to attach to the entry.
Name of the agent creating this entry.
MemoryProvider
Interface that all memory providers must implement.Provider type identifier.
Load prior conversation history.
Persist messages from a completed run.
Remove all stored memory (optional).
Return raw entries for inspection (optional).
Reasoning Types
ReasoningStrategy
Built-in reasoning strategies.- react: ReAct (Reason + Act) pattern
- planner: Plan-and-execute pattern
- cot: Chain of Thought
- reflect: Self-reflection and refinement
- autonomous: Autonomous agent loop
ReasoningStep
Union type representing any reasoning step.ThoughtStep
The thought content.
Engine that produced this step.
PlanStep
Ordered list of subtasks.
ToolCallStep
ToolResultStep
Error message if the tool failed.
ReflectionStep
What the engine assessed about its previous output.
Whether the answer needs revision.
ResponseStep
ReasoningEngine
Interface for custom reasoning engines.Engine name.
Execute the reasoning loop and return final output.
ReasoningContext
Runtime context passed to reasoning engines.The enclosing execution context.
The configured model provider.
All registered tools.
Agent policy constraints.
System prompt (if set).
Append a step to state.steps and emit an event.
Execute a tool by name and record the result.
Execution Types
ExecutionState
Internal runtime state during agent execution.All reasoning steps taken.
Full conversation history.
All tool calls and their results.
Cumulative token usage.
When execution started.
When execution finished.
ExecutionContext
Context object passed to tools and middleware.User input for this run.
User-defined typed state.
Internal runtime state (do not mutate).
Active session ID for this run.
Memory provider scoped to this run.
Cancel the current execution.
Emit a custom event.
Middleware Types
MiddlewareScope
Execution lifecycle points where middleware can hook in.Middleware
Middleware definition.Middleware name (for debugging).
Scopes this middleware applies to. If not specified, applies to all scopes.
Middleware execution function.
MiddlewareContext
Context passed to middleware functions.Current scope.
Execution context.
Tool-specific context (present when scope is
tool:*).Policy Types
AgentPolicy
Constraints applied to agent execution.Maximum reasoning steps allowed.
Maximum cost (in USD) allowed.
Execution timeout in milliseconds.
Whitelist of allowed tool names.
Maximum total tokens allowed.
Maximum number of tools to execute in parallel.
Configuration Types
AgentConfig
Configuration for creating an agent.Agent name.
Agent description.
Model provider to use.
Tools available to the agent.
Memory provider for conversation history.
Reasoning strategy or custom engine.
Middleware to apply.
Policy constraints.
System prompt.
Initial custom state.
RunOptions
Options for running an agent.User input.
Override custom state for this run.
Abort signal for cancellation.
Session identifier for memory scoping. Defaults to a random UUID.
RunResult
Result from an agent run.Final text output.
Complete execution state including steps and token usage.