For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
        • Agent
        • AgentSession
        • Infrastructure
        • Plugins
        • runApp
        • RunContext
        • Signals
        • tool / FunctionTool
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • StopResponse
  • Constructor
  • ToolError
  • Constructor
  • AgentHandoff
  • Properties
  • handoff()
  • ChatContext
  • Properties
  • append
AgentsLiveWire

Signals

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

tool / FunctionTool

Next
Built with

LiveWire provides error and signal classes that tool handlers can throw or return to control agent behavior.

StopResponse

Extends Error. When thrown inside a tool handler, signals that the tool should not trigger another LLM reply. Use this when the tool’s side effect is the final action and no further conversation is needed.

1import { tool, StopResponse } from '@signalwire/sdk/livewire';
2
3const endCall = tool({
4 description: 'End the current call.',
5 parameters: { reason: { type: 'string' } },
6 execute: (params) => {
7 // Perform cleanup...
8 throw new StopResponse(`Call ended: ${params.reason}`);
9 },
10});

Constructor

1new StopResponse(message?: string)
message
stringDefaults to "StopResponse"

Optional error message. Defaults to "StopResponse".


ToolError

Extends Error. Signals a tool execution failure. Throw this when a tool encounters a problem that should be reported back to the LLM so it can communicate the issue to the user or retry.

1import { tool, ToolError } from '@signalwire/sdk/livewire';
2
3const transferFunds = tool<{ amount: number; toAccount: string }>({
4 description: 'Transfer funds to another account.',
5 parameters: {
6 amount: { type: 'number' },
7 toAccount: { type: 'string' },
8 },
9 execute: (params) => {
10 if (params.amount <= 0) {
11 throw new ToolError('Amount must be positive.');
12 }
13 return `Transferred $${params.amount} to ${params.toAccount}.`;
14 },
15});

Constructor

1new ToolError(message: string)
message
stringRequired

Error message describing what went wrong. This is sent back to the LLM.


AgentHandoff

A signal class for handing off a conversation to a different agent in multi-agent scenarios. Created via the handoff() helper function.

1import { Agent, handoff, tool } from '@signalwire/sdk/livewire';
2
3const billingAgent = new Agent({
4 instructions: 'You handle billing questions.',
5});
6
7const transferToBilling = handoff({
8 agent: billingAgent,
9 returns: 'Transferred to billing department.',
10});

Properties

agent
Agent

The target Agent for the handoff.

returns
string | undefined

Optional return message for the handoff.

handoff()

1function handoff(options: { agent: Agent; returns?: string }): AgentHandoff

Factory function that creates an AgentHandoff instance.

agent
AgentRequired

The target agent to hand off to.

returns
string | undefined

Optional return value for the handoff.


ChatContext

A minimal class mirroring the LiveKit ChatContext. Stores an in-memory list of chat messages. On SignalWire, the platform manages conversation history for the active call — this class exists so that existing livekit-agents code that references ChatContext compiles without errors, and so callers can stage messages in prewarm code.

1import { llm } from '@signalwire/sdk/livewire';
2
3const chat = new llm.ChatContext();
4chat.append({ role: 'system', text: 'You are a helpful agent.' });

Properties

messages
Array<Record<string, string>>

Appended chat messages. Each entry is stored as { role, content }.

append

1append(options: { role?: string; text?: string }): this

Append a message to messages. The stored entry uses content (not text) as the body key — text is renamed to match the on-wire message shape.

role
stringDefaults to "user"

The message role ("user", "assistant", "system", etc.).

text
stringDefaults to ""

The message content.