Skip to content

Commit eeac05d

Browse files
Move prompt and greeting docs to vendor config
Update AgentKit examples and reference docs to configure prompts, greetings, failure messages, and max history on LLM or MLLM vendor options instead of the top-level Agent fields. Mark the Agent-level helpers as compatibility shims and keep examples aligned with the serialized request shape.
1 parent a95214e commit eeac05d

10 files changed

Lines changed: 133 additions & 103 deletions

File tree

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ def start_conversation() -> str:
5858

5959
agent = Agent(
6060
name=f"conversation-{int(time.time())}",
61-
instructions=AGENT_PROMPT,
62-
greeting=GREETING,
63-
failure_message="Please wait a moment.",
64-
max_history=50,
6561
turn_detection={
6662
"config": {
6763
"speech_threshold": 0.5,
@@ -96,9 +92,10 @@ def start_conversation() -> str:
9692
).with_llm(
9793
OpenAI(
9894
model="gpt-4o-mini",
95+
system_messages=[{"role": "system", "content": AGENT_PROMPT}],
9996
greeting_message=GREETING,
10097
failure_message="Please wait a moment.",
101-
max_history=15,
98+
max_history=50,
10299
params={
103100
"max_tokens": 1024,
104101
"temperature": 0.7,
@@ -134,10 +131,7 @@ def start_conversation() -> str:
134131
Use the same `Agent` builder shape, but provide credentials explicitly when you want vendor-managed billing and routing instead of Agora-managed models.
135132

136133
```python
137-
agent = Agent(
138-
instructions=AGENT_PROMPT,
139-
greeting=GREETING,
140-
).with_stt(
134+
agent = Agent().with_stt(
141135
DeepgramSTT(
142136
api_key=os.environ["DEEPGRAM_API_KEY"],
143137
model="nova-3",
@@ -147,6 +141,8 @@ agent = Agent(
147141
OpenAI(
148142
api_key=os.environ["OPENAI_API_KEY"],
149143
model="gpt-4o-mini",
144+
system_messages=[{"role": "system", "content": AGENT_PROMPT}],
145+
greeting_message=GREETING,
150146
max_tokens=1024,
151147
temperature=0.7,
152148
top_p=0.95,

docs/concepts/agent.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,27 @@ The `Agent` class is a fluent builder for configuring AI agent properties. It co
1212

1313
<!-- snippet: executable -->
1414
```python
15-
from agora_agent import Agent
16-
17-
agent = Agent(
18-
name='support-assistant',
19-
instructions='You are a helpful voice assistant.',
20-
greeting='Hello! How can I help you?',
21-
failure_message='Sorry, something went wrong.',
22-
max_history=20,
15+
from agora_agent import Agent, OpenAI
16+
17+
agent = Agent(name='support-assistant').with_llm(
18+
OpenAI(
19+
api_key='your-openai-key',
20+
model='gpt-4o-mini',
21+
system_messages=[{'role': 'system', 'content': 'You are a helpful voice assistant.'}],
22+
greeting_message='Hello! How can I help you?',
23+
failure_message='Sorry, something went wrong.',
24+
max_history=20,
25+
)
2326
)
2427
```
2528

2629
| Parameter | Type | Required | Description |
2730
|---|---|---|---|
2831
| `name` | `str` | No | Agent display name (used as session name if not overridden) |
29-
| `instructions` | `str` | No | System prompt for the LLM |
30-
| `greeting` | `str` | No | Message spoken when the agent joins |
31-
| `failure_message` | `str` | No | Message spoken on error |
32-
| `max_history` | `int` | No | Maximum conversation history length |
32+
| `instructions` | `str` | No | Deprecated. Use LLM vendor `system_messages` instead. |
33+
| `greeting` | `str` | No | Deprecated. Use LLM/MLLM vendor `greeting_message` instead. |
34+
| `failure_message` | `str` | No | Deprecated. Use LLM/MLLM vendor `failure_message` instead. |
35+
| `max_history` | `int` | No | Deprecated. Use LLM vendor `max_history` instead. |
3336
| `turn_detection` | `TurnDetectionConfig` | No | Turn detection settings |
3437
| `sal` | `SalConfig` | No | SAL (Speech Activity Level) configuration |
3538
| `advanced_features` | `Dict[str, Any]` | No | Advanced features (e.g., `{'enable_rtm': True}`) |
@@ -57,15 +60,15 @@ Each `with_*` method returns a **new** `Agent` instance — the original is unch
5760

5861
| Method | Accepts | Purpose |
5962
|---|---|---|
60-
| `with_instructions(text)` | `str` | Override the system prompt |
61-
| `with_greeting(text)` | `str` | Override the greeting message |
63+
| `with_instructions(text)` | `str` | Deprecated. Use LLM vendor `system_messages` instead. |
64+
| `with_greeting(text)` | `str` | Deprecated. Use LLM/MLLM vendor `greeting_message` instead. |
6265
| `with_name(name)` | `str` | Override the agent name |
6366
| `with_turn_detection(config)` | `TurnDetectionConfig` | Override cascading-flow SOS/EOS detection; use `with_interruption()` for interruption behavior |
6467
| `with_sal(config)` | `SalConfig` | Set SAL configuration |
6568
| `with_advanced_features(features)` | `Dict[str, Any]` | Set advanced features |
6669
| `with_parameters(parameters)` | `SessionParams` | Set session parameters |
67-
| `with_failure_message(message)` | `str` | Set failure message |
68-
| `with_max_history(max_history)` | `int` | Set max history length |
70+
| `with_failure_message(message)` | `str` | Deprecated. Use LLM/MLLM vendor `failure_message` instead. |
71+
| `with_max_history(max_history)` | `int` | Deprecated. Use LLM vendor `max_history` instead. |
6972
| `with_geofence(geofence)` | `GeofenceConfig` | Set geofence configuration |
7073
| `with_labels(labels)` | `Dict[str, str]` | Set custom labels |
7174
| `with_rtc(rtc)` | `RtcConfig` | Set RTC configuration |
@@ -79,8 +82,12 @@ from agora_agent import Agent
7982
from agora_agent import OpenAI, ElevenLabsTTS, DeepgramSTT
8083

8184
agent = (
82-
Agent(name='my-agent', instructions='You are a helpful assistant.')
83-
.with_llm(OpenAI(api_key='your-openai-key', model='gpt-4o-mini'))
85+
Agent(name='my-agent')
86+
.with_llm(OpenAI(
87+
api_key='your-openai-key',
88+
model='gpt-4o-mini',
89+
system_messages=[{'role': 'system', 'content': 'You are a helpful assistant.'}],
90+
))
8491
.with_tts(ElevenLabsTTS(key='your-elevenlabs-key', model_id='eleven_flash_v2_5', voice_id='your-voice-id'))
8592
.with_stt(DeepgramSTT(api_key='your-deepgram-key', language='en-US'))
8693
)
@@ -97,8 +104,12 @@ from agora_agent import Agent, Agora, Area, OpenAI, ElevenLabsTTS, DeepgramSTT
97104
client = Agora(area=Area.US, app_id='your-app-id', app_certificate='your-app-certificate')
98105

99106
base = (
100-
Agent(instructions='You are a helpful assistant.')
101-
.with_llm(OpenAI(api_key='your-openai-key', model='gpt-4o-mini'))
107+
Agent()
108+
.with_llm(OpenAI(
109+
api_key='your-openai-key',
110+
model='gpt-4o-mini',
111+
system_messages=[{'role': 'system', 'content': 'You are a helpful assistant.'}],
112+
))
102113
.with_tts(ElevenLabsTTS(key='your-elevenlabs-key', model_id='eleven_flash_v2_5', voice_id='your-voice-id'))
103114
.with_stt(DeepgramSTT(api_key='your-deepgram-key', language='en-US'))
104115
)

docs/concepts/session.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ from agora_agent import Agent, Agora, Area, OpenAI, ElevenLabsTTS, DeepgramSTT
4040
client = Agora(area=Area.US, app_id='your-app-id', app_certificate='your-app-certificate')
4141

4242
agent = (
43-
Agent(name='my-agent', instructions='You are helpful.')
44-
.with_llm(OpenAI(api_key='your-openai-key', model='gpt-4o-mini'))
43+
Agent(name='my-agent')
44+
.with_llm(OpenAI(
45+
api_key='your-openai-key',
46+
model='gpt-4o-mini',
47+
system_messages=[{'role': 'system', 'content': 'You are helpful.'}],
48+
))
4549
.with_tts(ElevenLabsTTS(key='your-elevenlabs-key', model_id='eleven_flash_v2_5', voice_id='your-voice-id'))
4650
.with_stt(DeepgramSTT(api_key='your-deepgram-key', language='en-US'))
4751
)

docs/getting-started/authentication.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ client = Agora(
2020
)
2121

2222
agent = (
23-
Agent(instructions="Be concise.")
23+
Agent()
2424
.with_stt(DeepgramSTT(model="nova-3"))
25-
.with_llm(OpenAI(model="gpt-4o-mini"))
25+
.with_llm(OpenAI(
26+
model="gpt-4o-mini",
27+
system_messages=[{"role": "system", "content": "Be concise."}],
28+
))
2629
.with_tts(MiniMaxTTS(model="speech_2_6_turbo", voice_id="English_captivating_female1"))
2730
)
2831

docs/getting-started/quick-start.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def main() -> None:
2727
)
2828

2929
agent = (
30-
Agent(
31-
name="support-assistant",
32-
instructions="You are a concise support voice assistant.",
33-
greeting="Hello! How can I help you today?",
34-
max_history=10,
35-
)
30+
Agent(name="support-assistant")
3631
.with_stt(DeepgramSTT(model="nova-3", language="en"))
37-
.with_llm(OpenAI(model="gpt-4o-mini"))
32+
.with_llm(OpenAI(
33+
model="gpt-4o-mini",
34+
system_messages=[{"role": "system", "content": "You are a concise support voice assistant."}],
35+
greeting_message="Hello! How can I help you today?",
36+
max_history=10,
37+
))
3838
.with_tts(MiniMaxTTS(model="speech_2_6_turbo", voice_id="English_captivating_female1"))
3939
)
4040

docs/guides/agent-builder-features.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ For string values with a finite set of options (e.g. `data_channel`, `sal_mode`,
1818
| `advanced_features` | `with_advanced_features(features)` | Enable MLLM, RTM, SAL, tools |
1919
| `tools` | `with_tools(enabled=True)` | Enable MCP tool invocation |
2020
| `parameters` | `with_parameters(params)` | Silence config, farewell config, data channel |
21-
| `failure_message` | `with_failure_message(msg)` | Message spoken when LLM fails |
22-
| `max_history` | `with_max_history(n)` | Max conversation turns in LLM context |
21+
| `failure_message` | LLM/MLLM vendor option | Message spoken when LLM fails |
22+
| `max_history` | LLM vendor option | Max conversation turns in LLM context |
2323
| `geofence` | `with_geofence(config)` | Restrict backend server regions |
2424
| `labels` | `with_labels(labels)` | Custom key-value labels (returned in callbacks) |
2525
| `rtc` | `with_rtc(config)` | RTC media encryption |
@@ -45,14 +45,17 @@ from agora_agent import (
4545
agent = (
4646
Agent(
4747
name='sal-assistant',
48-
instructions='You are a helpful assistant.',
4948
advanced_features=AdvancedFeatures(enable_sal=True),
5049
)
5150
.with_sal(SalConfig(
5251
sal_mode=SalModeValues.LOCKING,
5352
sample_urls={'primary-speaker': 'https://example.com/voiceprint.pcm'},
5453
))
55-
.with_llm(OpenAI(api_key='your-key', model='gpt-4o-mini'))
54+
.with_llm(OpenAI(
55+
api_key='your-key',
56+
model='gpt-4o-mini',
57+
system_messages=[{'role': 'system', 'content': 'You are a helpful assistant.'}],
58+
))
5659
.with_tts(ElevenLabsTTS(key='your-key', model_id='eleven_flash_v2_5', voice_id='your-voice-id', sample_rate=24000))
5760
.with_stt(DeepgramSTT(api_key='your-key', model='nova-2', language='en-US'))
5861
)
@@ -114,23 +117,14 @@ agent = (
114117
## Failure Message and Max History
115118

116119
```python
117-
agent = (
118-
Agent(
119-
name='assistant',
120-
failure_message='Sorry, I encountered an error. Please try again.',
121-
max_history=20,
122-
)
123-
.with_llm(OpenAI(api_key='...', model='gpt-4o-mini'))
124-
.with_tts(ElevenLabsTTS(key='...', model_id='...', voice_id='...', sample_rate=24000))
125-
.with_stt(DeepgramSTT(api_key='...', model='nova-2'))
126-
)
127-
128-
# Or via builder methods
129120
agent = (
130121
Agent()
131-
.with_failure_message('Something went wrong.')
132-
.with_max_history(15)
133-
.with_llm(OpenAI(api_key='...', model='gpt-4o-mini'))
122+
.with_llm(OpenAI(
123+
api_key='...',
124+
model='gpt-4o-mini',
125+
failure_message='Something went wrong.',
126+
max_history=15,
127+
))
134128
.with_tts(ElevenLabsTTS(key='...', model_id='...', voice_id='...', sample_rate=24000))
135129
.with_stt(DeepgramSTT(api_key='...', model='nova-2'))
136130
)
@@ -245,13 +239,12 @@ Read back configuration via properties:
245239
from agora_agent import Agent, GeofenceConfig, GeofenceArea
246240

247241
agent = (
248-
Agent(max_history=20)
242+
Agent()
249243
.with_geofence(GeofenceConfig(area=GeofenceArea.EUROPE))
250244
.with_labels({'env': 'staging'})
251245
)
252246

253247
agent.name # str | None
254-
agent.max_history # 20
255248
agent.geofence # GeofenceConfig(area='EUROPE')
256249
agent.labels # {'env': 'staging'}
257250
agent.sal # SalConfig | None
@@ -293,14 +286,15 @@ client = Agora(
293286
)
294287

295288
agent = (
296-
Agent(
297-
name='full-featured-assistant',
298-
instructions='You are a helpful voice assistant.',
299-
greeting='Hello! How can I help?',
289+
Agent(name='full-featured-assistant')
290+
.with_llm(OpenAI(
291+
api_key='your-key',
292+
model='gpt-4o-mini',
293+
system_messages=[{'role': 'system', 'content': 'You are a helpful voice assistant.'}],
294+
greeting_message='Hello! How can I help?',
300295
failure_message='Sorry, I had trouble processing that.',
301296
max_history=20,
302-
)
303-
.with_llm(OpenAI(api_key='your-key', model='gpt-4o-mini'))
297+
))
304298
.with_tts(ElevenLabsTTS(key='your-key', model_id='eleven_flash_v2_5', voice_id='your-voice-id', sample_rate=24000))
305299
.with_stt(DeepgramSTT(api_key='your-key', model='nova-2', language='en-US'))
306300
.with_advanced_features(AdvancedFeatures(enable_rtm=True))

docs/guides/avatars.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ client = Agora(
5454
)
5555

5656
agent = (
57-
Agent(name='avatar-agent', instructions='You are a helpful assistant with a visual avatar.')
58-
.with_llm(OpenAI(api_key='your-openai-key', model='gpt-4o-mini'))
57+
Agent(name='avatar-agent')
58+
.with_llm(OpenAI(
59+
api_key='your-openai-key',
60+
model='gpt-4o-mini',
61+
system_messages=[{'role': 'system', 'content': 'You are a helpful assistant with a visual avatar.'}],
62+
))
5963
.with_tts(ElevenLabsTTS(
6064
key='your-elevenlabs-key',
6165
model_id='eleven_flash_v2_5',
@@ -100,8 +104,12 @@ Akool requires a TTS vendor configured at 16000 Hz:
100104
from agora_agent import ElevenLabsTTS, AkoolAvatar
101105

102106
agent = (
103-
Agent(name='akool-agent', instructions='You are a helpful assistant.')
104-
.with_llm(OpenAI(api_key='your-openai-key', model='gpt-4o-mini'))
107+
Agent(name='akool-agent')
108+
.with_llm(OpenAI(
109+
api_key='your-openai-key',
110+
model='gpt-4o-mini',
111+
system_messages=[{'role': 'system', 'content': 'You are a helpful assistant.'}],
112+
))
105113
.with_tts(ElevenLabsTTS(
106114
key='your-elevenlabs-key',
107115
model_id='eleven_flash_v2_5',
@@ -124,8 +132,12 @@ This example shows what happens when the TTS sample rate does not match the avat
124132
```python
125133
# This raises ValueError at build time
126134
agent = (
127-
Agent(name='broken-agent', instructions='You are a helpful assistant.')
128-
.with_llm(OpenAI(api_key='your-openai-key', model='gpt-4o-mini'))
135+
Agent(name='broken-agent')
136+
.with_llm(OpenAI(
137+
api_key='your-openai-key',
138+
model='gpt-4o-mini',
139+
system_messages=[{'role': 'system', 'content': 'You are a helpful assistant.'}],
140+
))
129141
.with_tts(ElevenLabsTTS(
130142
key='your-elevenlabs-key',
131143
model_id='eleven_flash_v2_5',
@@ -152,7 +164,7 @@ The `with_avatar()` call validates against the currently configured TTS. Always
152164
```python
153165
# Correct order: TTS first, then avatar
154166
agent = (
155-
Agent(name='my-agent', instructions='You are helpful.')
167+
Agent(name='my-agent')
156168
.with_tts(ElevenLabsTTS(key='your-elevenlabs-key', model_id='eleven_flash_v2_5', voice_id='your-voice-id', sample_rate=24000))
157169
.with_avatar(HeyGenAvatar(api_key='your-heygen-key', quality='medium', agora_uid='2'))
158170
)

docs/guides/byok.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ def main() -> None:
3232

3333
# In BYOK mode, each vendor carries its own credentials.
3434
agent = (
35-
Agent(
36-
name="support-assistant",
37-
instructions="You are a concise support voice assistant.",
38-
greeting="Hello! How can I help you today?",
39-
max_history=10,
40-
)
35+
Agent(name="support-assistant")
4136
.with_stt(
4237
DeepgramSTT(
4338
api_key=os.environ["DEEPGRAM_API_KEY"],
@@ -49,6 +44,9 @@ def main() -> None:
4944
OpenAI(
5045
api_key=os.environ["OPENAI_API_KEY"],
5146
model="gpt-4o-mini",
47+
system_messages=[{"role": "system", "content": "You are a concise support voice assistant."}],
48+
greeting_message="Hello! How can I help you today?",
49+
max_history=10,
5250
)
5351
)
5452
.with_tts(

0 commit comments

Comments
 (0)