Skip to content

Commit 89dba9f

Browse files
committed
fixes
1 parent fecc945 commit 89dba9f

3 files changed

Lines changed: 38 additions & 25 deletions

File tree

agent-framework/user-guide/agents/agent-types/openai-assistants-agent.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,19 @@ async def thread_example():
295295
instructions="You are a helpful assistant.",
296296
) as agent:
297297
# Create a persistent thread for conversation context
298-
async with AgentThread() as thread:
299-
# First interaction
300-
result1 = await agent.run("My name is Alice", thread=thread)
301-
print(f"Agent: {result1.text}")
302-
303-
# Second interaction - agent remembers the context
304-
result2 = await agent.run("What's my name?", thread=thread)
305-
print(f"Agent: {result2.text}") # Should remember "Alice"
298+
thread = agent.get_new_thread()
299+
300+
# First interaction
301+
first_query = "My name is Alice"
302+
print(f"User: {first_query}")
303+
first_result = await agent.run(first_query, thread=thread)
304+
print(f"Agent: {first_result.text}")
305+
306+
# Second interaction - agent remembers the context
307+
second_query = "What's my name?"
308+
print(f"User: {second_query}")
309+
second_result = await agent.run(second_query, thread=thread)
310+
print(f"Agent: {second_result.text}") # Should remember "Alice"
306311
```
307312

308313
### Working with Existing Assistants

agent-framework/user-guide/agents/agent-types/openai-chat-completion-agent.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,24 @@ Maintain conversation context across multiple interactions:
209209
from agent_framework import AgentThread
210210

211211
async def thread_example():
212-
agent = OpenAIChatClient().create_agent(
212+
async with OpenAIChatClient().create_agent(
213213
name="Assistant",
214214
instructions="You are a helpful assistant.",
215-
)
215+
) as agent:
216+
# Create a persistent thread for conversation context
217+
thread = agent.get_new_thread()
216218

217-
# Create a persistent thread for conversation context
218-
async with AgentThread() as thread:
219219
# First interaction
220-
result1 = await agent.run("My name is Alice", thread=thread)
221-
print(f"Agent: {result1.text}")
220+
first_query = "My name is Alice"
221+
print(f"User: {first_query}")
222+
first_result = await agent.run(first_query, thread=thread)
223+
print(f"Agent: {first_result.text}")
222224

223225
# Second interaction - agent remembers the context
224-
result2 = await agent.run("What's my name?", thread=thread)
225-
print(f"Agent: {result2.text}") # Should remember "Alice"
226+
second_query = "What's my name?"
227+
print(f"User: {second_query}")
228+
second_result = await agent.run(second_query, thread=thread)
229+
print(f"Agent: {second_result.text}") # Should remember "Alice"
226230
```
227231

228232
### Streaming Responses

agent-framework/user-guide/agents/agent-types/openai-responses-agent.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async def tools_example():
250250

251251
### Code Interpreter
252252

253-
Enable your assistant to execute Python code:
253+
Enable your agent to execute Python code:
254254

255255
```python
256256
from agent_framework import HostedCodeInterpreterTool
@@ -314,20 +314,24 @@ Maintain conversation context across multiple interactions:
314314
from agent_framework import AgentThread
315315

316316
async def thread_example():
317-
agent = OpenAIResponsesClient().create_agent(
317+
async with OpenAIResponsesClient().create_agent(
318318
name="Assistant",
319319
instructions="You are a helpful assistant.",
320-
)
320+
) as agent:
321+
# Create a persistent thread for conversation context
322+
thread = agent.get_new_thread()
321323

322-
# Create a persistent thread for conversation context
323-
async with AgentThread() as thread:
324324
# First interaction
325-
result1 = await agent.run("My name is Alice", thread=thread)
326-
print(f"Agent: {result1.text}")
325+
first_query = "My name is Alice"
326+
print(f"User: {first_query}")
327+
first_result = await agent.run(first_query, thread=thread)
328+
print(f"Agent: {first_result.text}")
327329

328330
# Second interaction - agent remembers the context
329-
result2 = await agent.run("What's my name?", thread=thread)
330-
print(f"Agent: {result2.text}") # Should remember "Alice"
331+
second_query = "What's my name?"
332+
print(f"User: {second_query}")
333+
second_result = await agent.run(second_query, thread=thread)
334+
print(f"Agent: {second_result.text}") # Should remember "Alice"
331335
```
332336

333337
### File Search

0 commit comments

Comments
 (0)