setGlobalData

View as MarkdownOpen in Claude

Merge key-value pairs into the global_data object available to the AI throughout the conversation. Matches Python’s set_global_data, which calls .update() on the internal dict — existing keys are preserved; incoming keys overwrite on collision. Skills and other callers can each contribute keys without clobbering one another.

Despite the set prefix, this method merges rather than replaces. There is no built-in “clear” method; construct a new agent if you need an empty global_data object.

Parameters

data
Record<string, unknown>Required

Object of key/value pairs. Values can be any JSON-serializable type.

Returns

AgentBase — Returns this for method chaining.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'support', route: '/support' });
4agent.setPromptText('You are a helpful assistant.');
5agent.setGlobalData({
6 company_name: 'Acme Corp',
7 support_hours: '9am-5pm EST',
8 user_tier: 'standard',
9});
10await agent.serve();