Python: Fix tool normalization and provider sample consolidation (#3953)

* Fix tool normalization and provider samples

- restore callable/single-tool normalization paths and unset tool-choice behavior\n- consolidate and expand chat/provider samples (OpenAI/Azure/Anthropic/Ollama/Bedrock)\n- migrate Bedrock lazy import surface to agent_framework.amazon and move provider samples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* small fix in sample

* Finalize provider, samples, and core cleanup

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix CopilotTool passthrough in agent

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix link

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Eduard van Valkenburg
2026-02-16 16:30:38 +00:00
committed by GitHub
co-authored by Copilot
parent ed113f941c
commit aab621f5eb
99 changed files with 1190 additions and 969 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ Integration with AWS Bedrock for LLM inference.
## Usage
```python
from agent_framework_bedrock import BedrockChatClient
from agent_framework.amazon import BedrockChatClient
client = BedrockChatClient(model_id="anthropic.claude-3-sonnet-20240229-v1:0")
response = await client.get_response("Hello")
@@ -21,5 +21,5 @@ response = await client.get_response("Hello")
## Import Path
```python
from agent_framework_bedrock import BedrockChatClient
from agent_framework.amazon import BedrockChatClient
```
+1 -1
View File
@@ -12,7 +12,7 @@ The Bedrock integration enables Microsoft Agent Framework applications to call A
### Basic Usage Example
See the [Bedrock sample script](samples/bedrock_sample.py) for a runnable end-to-end script that:
See the [Bedrock sample](../../samples/02-agents/providers/amazon/bedrock_chat_client.py) for a runnable end-to-end script that:
- Loads credentials from the `BEDROCK_*` environment variables
- Instantiates `BedrockChatClient`
@@ -260,7 +260,7 @@ class BedrockChatClient(
Examples:
.. code-block:: python
from agent_framework.bedrock import BedrockChatClient
from agent_framework.amazon import BedrockChatClient
# Basic usage with default credentials
client = BedrockChatClient(model_id="<model name>")
@@ -1,45 +0,0 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import logging
from agent_framework import Agent, tool
from agent_framework_bedrock import BedrockChatClient
@tool(approval_mode="never_require")
def get_weather(city: str) -> dict[str, str]:
"""Return a mock forecast for the requested city."""
normalized = city.strip() or "New York"
return {"city": normalized, "forecast": "72F and sunny"}
async def main() -> None:
"""Run the Bedrock sample agent, invoke the weather tool, and log the response."""
agent = Agent(
client=BedrockChatClient(),
instructions="You are a concise travel assistant.",
name="BedrockWeatherAgent",
tool_choice="auto",
tools=[get_weather],
)
response = await agent.run("Use the weather tool to check the forecast for new york.")
logging.info("\nAssistant reply:", response.text or "<no text returned>")
logging.info("\nConversation transcript:")
for message in response.messages:
for idx, content in enumerate(message.contents, start=1):
match content.type:
case "text":
logging.info(f" {idx}. text -> {content.text}")
case "function_call":
logging.info(f" {idx}. function_call ({content.name}) -> {content.arguments}")
case "function_result":
logging.info(f" {idx}. function_result ({content.call_id}) -> {content.result}")
case _:
logging.info(f" {idx}. {content.type}")
if __name__ == "__main__":
asyncio.run(main())