update_instructions

View as MarkdownOpen in Claude

Update the agent’s system prompt mid-session. The new instructions take effect immediately for subsequent LLM turns.

Parameters

instructions
strRequired

The new system prompt text.

Returns

None

Example

1from signalwire.livewire import Agent, AgentSession, AgentServer, JobContext, function_tool, run_app
2
3@function_tool
4def escalate() -> str:
5 """Escalate to a senior agent."""
6 return "Escalating now."
7
8server = AgentServer()
9
10@server.rtc_session()
11async def entrypoint(ctx: JobContext):
12 await ctx.connect()
13 agent = Agent(
14 instructions="You are a junior support agent. Help with basic questions.",
15 tools=[escalate],
16 )
17 session = AgentSession()
18 await agent.update_instructions("You are now a senior support agent. Handle complex issues.")
19 await session.start(agent, room=ctx.room)
20
21run_app(server)