Skip to main content

Agent

import { BrowserModelsAgent } from '@soverius-ai/browser-models/agent';
OptionTypeDefault
modelsRecord<string, Engine>required
defaultModelkey of modelsrequired
agentIdstring–
descriptionstring'An agent running on a model in the browser'
localTools(LocalTool | LocalToolSource)[][]
maxStepsnumber (model calls per run)5
repairHooksee Tools → Repair–

Model selection​

No automatic fallback. Unknown ids fail the run with RUN_ERROR.

agent.selectModel('qwen'); // all following runs, also on clones
agent.selectedModel; // 'qwen'
agent.modelIds; // ['nano', 'qwen']
agent.engine('qwen'); // the Engine

// per run
agent.runAgent({ forwardedProps: { soverius: { model: 'nano' } } });

Events​

SourceAG-UI events
runRUN_STARTED, RUN_FINISHED, RUN_ERROR
textTEXT_MESSAGE_START, _CONTENT, _END
<think> blocksREASONING_START, REASONING_MESSAGE_START, _CONTENT, _END, REASONING_END
tool callsTOOL_CALL_START, _ARGS, _END, TOOL_CALL_RESULT (local tools)
repairsCUSTOM soverius.tool_repair { toolCallId, raw, steps }
correctionsMESSAGES_SNAPSHOT when repair changed streamed arguments
tool sourcesCUSTOM soverius.tool_source_error { message }
model loadingACTIVITY_SNAPSHOT soverius.model, see Model loading
stoppedRUN_ERROR with code: 'abort' (agent.abortRun())

Tool calls stream while the model writes them, see Tools.

Model loading​

Every run calls engine.load() first. While the engine reports progress, the run emits ACTIVITY_SNAPSHOT events (one per whole percent). Already loaded: no events.

import { MODEL_ACTIVITY } from '@soverius-ai/browser-models'; // 'soverius.model'
import { z } from 'zod';

// event.content; progress is 0–1
const modelActivity = z.object({
engineId: z.string(),
status: z.enum(['loading', 'ready']),
progress: z.number(),
});

Devtools​

const stop = agent.connectDevtools();
// window.postMessage({ source: 'soverius-ai/devtools', agentId, event }, '/')

No-op without window (SSR). agentId is 'default' when the agent has none.

FrameworkDevtools
AngularwithDevtools()
ReactuseDevtools(agent, enabled?)
VueuseDevtools(agent, enabled?)