Skip to content

AgentConfig

Configuration for the LLM agent loop. Passed to ctx.useAgent().

Source: @durable-streams/darix-runtime

ts
interface AgentConfig {
  systemPrompt: string
  model: string
  tools: AgentTool[]
  streamFn?: StreamFn
  testResponses?: string[] | TestResponseFn
}

Fields

FieldTypeRequiredDescription
systemPromptstringYesSystem prompt sent to the LLM on each step.
modelstringYesModel identifier (e.g. "claude-sonnet-4-5-20250929").
toolsAgentTool[]YesTools available to the LLM. Always include ctx.darixTools first. See AgentTool.
streamFnStreamFnNoCustom streaming function. Overrides the default LLM provider.
testResponsesstring[] | TestResponseFnNoMock LLM responses for testing. When set, no real LLM calls are made.

TestResponseFn

ts
type TestResponseFn = (
  message: string,
  bridge: OutboundBridgeHandle
) => Promise<string | undefined>

A function that receives the current conversation and returns a mock response string, or undefined to end the agent loop.

AgentHandle

Returned by ctx.useAgent(). Also available as ctx.agent.

ts
interface AgentHandle {
  run(input?: string): Promise<AgentRunResult>
}
MethodReturn TypeDescription
run(input?)Promise<AgentRunResult>Execute the agent loop. Runs until the LLM stops or all tool calls complete.

Parameters:

ParameterTypeRequiredDescription
inputstringNoOptional user message appended to the conversation before the agent loop starts.

AgentRunResult

ts
interface AgentRunResult {
  result?: unknown
  writes: ChangeEvent[]
  toolCalls: Array<{ name: string; args: unknown; result: unknown }>
  usage: { tokens: number; duration: number }
}
FieldTypeDescription
resultunknownFinal result value, if any.
writesChangeEvent[]All events written to the entity stream during this run.
toolCallsArray<{ name, args, result }>Record of all tool calls made during this run.
usage{ tokens: number; duration: number }Token count and wall-clock duration in milliseconds.