AgentsAgentBase

set_global_data

View as MarkdownOpen in Claude

Merge data into the global data dictionary available to the AI throughout the conversation. This method merges rather than replaces, so multiple callers (skills, dynamic config callbacks, etc.) can each contribute keys without overwriting each other.

This method is thread-safe. Concurrent calls from different threads or async contexts are serialized via an internal lock.

Parameters

data
dict[str, Any]Required

Dictionary of key/value pairs to merge into global data. Values can be any JSON-serializable type.

Returns

AgentBase — Returns self for method chaining.

Example

1from signalwire import AgentBase
2
3agent = AgentBase(name="support", route="/support")
4agent.set_prompt_text("You are a helpful assistant.")
5agent.set_global_data({
6 "company_name": "Acme Corp",
7 "support_hours": "9am-5pm EST",
8 "user_tier": "standard"
9})
10agent.serve()