Skip to content
PricingBlog
✨ Markdown

AgentConfig

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

Source: @electric-ax/agents-runtime

ts
interface AgentConfig {
  systemPrompt: string
  model: string | Model<any>
  provider?: KnownProvider
  tools: AgentTool[]
  streamFn?: StreamFn
  getApiKey?: (
    provider: string
  ) => Promise<string | undefined> | string | undefined
  onPayload?: SimpleStreamOptions["onPayload"]
  testResponses?: string[] | TestResponseFn
}

Fields

FieldTypeRequiredDescription
systemPromptstringYesSystem prompt sent to the LLM on each step.
modelstring | Model<any>YesModel identifier (e.g. "claude-sonnet-4-5-20250929") or a resolved model object.
providerKnownProviderNoProvider to use when model is a string. Defaults to "anthropic".
toolsAgentTool[]YesTools available to the LLM. Spread ctx.electricTools when your runtime host provides runtime-level tools. See AgentTool.
streamFnStreamFnNoOptional streaming callback passed to the underlying agent.
getApiKey(provider) => string | Promise<string> | undefinedNoOptional API-key resolver passed through to the model layer.
onPayloadSimpleStreamOptions["onPayload"]NoOptional callback for raw streaming payloads from the model layer.
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 trigger message and an outbound bridge, then returns a mock response string. Returning undefined emits no automatic text response.

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
resultunknownOptional final result from the underlying agent adapter.
writesChangeEvent[]Currently returned as an empty array placeholder.
toolCallsArray<{ name, args, result }>Currently returned as an empty array placeholder.
usage{ tokens: number; duration: number }Currently returned as { tokens: 0, duration: 0 } until usage aggregation is wired in.