AgentsAgentBase

update_global_data

View as MarkdownOpen in Claude

Update the global data with new values. Functionally identical to set_global_data() — both merge the provided dictionary into the existing global data.

Parameters

data
dict[str, Any]Required

Dictionary of key/value pairs to merge into global data.

Returns

AgentBase — Returns self for method chaining.

Example

1from signalwire import AgentBase
2from signalwire.core.function_result import FunctionResult
3
4agent = AgentBase(name="support", route="/support")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(description="Authenticate the caller")
8def authenticate(args, raw_data=None):
9 user = {"name": "Alice", "tier": "gold"} # Replace with your user lookup
10 agent.update_global_data({
11 "authenticated": True,
12 "user_name": user["name"],
13 "user_tier": user["tier"]
14 })
15 return FunctionResult(f"Welcome back, {user['name']}.")
16
17agent.serve()