mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING] changed AIFunction to FunctionTool and @ai_function to @tool (#3413)
* changed AIFunction to FunctionTool and @ai_function to @tool * test and mypy fixes * mypy fix * switch function tool to always_require * fix noop * fix github copilot imports * test fixes * fix ollama test * fixes for tests * fix tests * reverted change to always_require and extended timeout * fix test
This commit is contained in:
committed by
GitHub
Unverified
parent
15b43f2abe
commit
a7d924a7d2
@@ -53,7 +53,7 @@ python samples/autogen-migration/orchestrations/04_magentic_one.py
|
||||
|
||||
- **Default behavior differences**: AutoGen's `AssistantAgent` is single-turn by default (`max_tool_iterations=1`), while AF's `ChatAgent` is multi-turn and continues tool execution automatically.
|
||||
- **Thread management**: AF agents are stateless by default. Use `agent.get_new_thread()` and pass it to `run()`/`run_stream()` to maintain conversation state, similar to AutoGen's conversation context.
|
||||
- **Tools**: AutoGen uses `FunctionTool` wrappers; AF uses `@ai_function` decorators with automatic schema inference.
|
||||
- **Tools**: AutoGen uses `FunctionTool` wrappers; AF uses `@tool` decorators with automatic schema inference.
|
||||
- **Orchestration patterns**:
|
||||
- `RoundRobinGroupChat` → `SequentialBuilder` or `WorkflowBuilder`
|
||||
- `SelectorGroupChat` → `GroupChatBuilder` with LLM-based speaker selection
|
||||
|
||||
@@ -103,6 +103,7 @@ async def run_agent_framework_with_cycle() -> None:
|
||||
WorkflowContext,
|
||||
WorkflowOutputEvent,
|
||||
executor,
|
||||
tool,
|
||||
)
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ async def run_agent_framework() -> None:
|
||||
RequestInfoEvent,
|
||||
WorkflowRunState,
|
||||
WorkflowStatusEvent,
|
||||
tool,
|
||||
)
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ async def run_agent_framework() -> None:
|
||||
MagenticBuilder,
|
||||
MagenticFinalResultEvent,
|
||||
MagenticOrchestratorMessageEvent,
|
||||
tool,
|
||||
)
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
|
||||
@@ -46,12 +46,13 @@ async def run_autogen() -> None:
|
||||
|
||||
|
||||
async def run_agent_framework() -> None:
|
||||
"""Agent Framework agent with @ai_function decorator."""
|
||||
from agent_framework import ai_function
|
||||
"""Agent Framework agent with @tool decorator."""
|
||||
from agent_framework import tool
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
# Define tool with @ai_function decorator (automatic schema inference)
|
||||
@ai_function
|
||||
# Define tool with @tool decorator (automatic schema inference)
|
||||
# NOTE: approval_mode="never_require" is for sample brevity. Use "always_require" in production; see samples/getting_started/tools/function_tool_with_approval.py and samples/getting_started/tools/function_tool_with_approval_and_threads.py.
|
||||
@tool(approval_mode="never_require")
|
||||
def get_weather(location: str) -> str:
|
||||
"""Get the weather for a location.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user