You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* updated for the new options setup
* updated some guidance and changed AgentRunResponse to AgentResponse
* added toc
* fixes
* added version
* linting
* fixed openai
Copy file name to clipboardExpand all lines: agent-framework/migration-guide/from-autogen/index.md
+24-15Lines changed: 24 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -221,33 +221,39 @@ def get_time() -> str:
221
221
client = OpenAIChatClient(model_id="gpt-5")
222
222
223
223
asyncdefexample():
224
-
# Direct creation
224
+
# Direct creation with default options
225
225
agent = ChatAgent(
226
226
name="assistant",
227
227
chat_client=client,
228
228
instructions="You are a helpful assistant.",
229
-
tools=[get_weather] # Multi-turn by default
229
+
tools=[get_weather], # Multi-turn by default
230
+
default_options={
231
+
"temperature": 0.7,
232
+
"max_tokens": 1000,
233
+
}
230
234
)
231
235
232
236
# Factory method (more convenient)
233
237
agent = client.create_agent(
234
238
name="assistant",
235
239
instructions="You are a helpful assistant.",
236
-
tools=[get_weather]
240
+
tools=[get_weather],
241
+
default_options={"temperature": 0.7}
237
242
)
238
243
239
-
# Execution with runtime tool configuration
244
+
# Execution with runtime tool and options configuration
240
245
result =await agent.run(
241
246
"What's the weather?",
242
-
tools=[get_time], # Can add tools at runtime
243
-
tool_choice="auto"
247
+
tools=[get_time], # Can add tools at runtime (keyword arg)
248
+
options={"tool_choice": "auto"} # Other options go in options dict
244
249
)
245
250
```
246
251
247
252
**Key Differences:**
248
253
249
254
-**Default behavior**: `ChatAgent` automatically iterates through tool calls, while `AssistantAgent` requires explicit `max_tool_iterations` setting
250
-
-**Runtime configuration**: `ChatAgent.run()` accepts `tools` and `tool_choice` parameters for per-invocation customization
255
+
-**Runtime configuration**: `ChatAgent.run()` accepts `tools` as a keyword argument and other options via the `options` dict parameter for per-invocation customization
256
+
-**Options system**: Agent Framework uses TypedDict-based options (e.g., `OpenAIChatOptions`) for type safety and IDE autocomplete. Options are passed via `default_options` at construction and `options` at runtime
-**State management**: `ChatAgent` is stateless and doesn't maintain conversation history between invocations, unlike `AssistantAgent` which maintains conversation history as part of its state
253
259
@@ -340,18 +346,21 @@ async for event in agent.run_stream(task="Hello"):
340
346
```python
341
347
# Assume we have client, agent, and tools from previous examples
342
348
asyncdefstreaming_example():
343
-
# Chat client streaming
344
-
asyncfor chunk in client.get_streaming_response("Hello", tools=tools):
349
+
# Chat client streaming - tools go in options dict
350
+
asyncfor chunk in client.get_streaming_response(
351
+
"Hello",
352
+
options={"tools": tools}
353
+
):
345
354
if chunk.text:
346
355
print(chunk.text, end="")
347
356
348
-
# Agent streaming
349
-
asyncfor chunk in agent.run_stream("Hello"):
357
+
# Agent streaming - tools can be keyword arg on agents
358
+
asyncfor chunk in agent.run_stream("Hello", tools=tools):
350
359
if chunk.text:
351
360
print(chunk.text, end="", flush=True)
352
361
```
353
362
354
-
Tip: In Agent Framework, both clients and agents yield the same update shape; you can read `chunk.text` in either case.
363
+
Tip: In Agent Framework, both clients and agents yield the same update shape; you can read `chunk.text` in either case. Note that for chat clients, `tools` goes in the `options` dict, while for agents, `tools` remains a direct keyword argument.
355
364
356
365
### Message Types and Creation
357
366
@@ -1345,7 +1354,7 @@ Agent Framework provides built-in request-response capabilities where any execut
**Solution**: Simplified options in Agent Framework
772
+
**Solution**: Simplified TypedDict-based options in Agent Framework
773
773
774
-
Agent Framework allows the passing of all parameters directly to the relevant methods, so that you don't have to import anything extra, or create any options objects, unless you want to. Internally, it uses a `ChatOptions` object for `ChatClients` and `ChatAgents`, which you can also create and pass in if you want to. This is also created in a `ChatAgent` to hold the options and can be overridden per call.
774
+
Agent Framework uses a TypedDict-based options system for `ChatClients` and `ChatAgents`. Options are passed via a single `options` parameter as a typed dictionary, with provider-specific TypedDict classes (like `OpenAIChatOptions`) for full IDE autocomplete and type checking.
775
775
776
776
```python
777
-
agent =...
777
+
from agent_framework.openai import OpenAIChatClient
> The above is specific to a `ChatAgent`, because other agents might have different options, they should all accepts `messages` as a parameter, since that is defined in the `AgentProtocol`.
802
+
> The `tools` and `instructions` parameters remain as direct keyword arguments on agent creation and `run()` methods, and are not passed via the `options` dictionary. See the [Typed Options Upgrade Guide](../../support/upgrade/typed-options-guide-python.md) for detailed migration patterns.
0 commit comments