Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
088955a
Add new AI content types and image tool support
Copilot Dec 19, 2025
2a5115b
Add Python content types for tool calls/results and image generation …
Copilot Dec 19, 2025
fcd391e
Address review feedback for tool content and samples
Copilot Dec 19, 2025
510a02d
Tighten image generation typing and sample tools list
Copilot Dec 19, 2025
2f4fa2b
Align image generation output typing
Copilot Dec 19, 2025
fa4424c
Handle MCP naming, image options mapping, and connector tool content
Copilot Dec 19, 2025
a2baea2
Allow MCP call in function approval request
Copilot Dec 19, 2025
382e668
Remove raw image_generation tool remapping
Copilot Dec 19, 2025
f105119
Restore Anthropic tool_use to function calls unless code execution
Copilot Dec 19, 2025
f899704
Fix lint issues for hosted file docstring and MCP parsing
Copilot Dec 19, 2025
2c18f74
Import ChatResponse types in Anthropic client
Copilot Dec 22, 2025
33bbfd1
Fix Anthropics citation type imports and MCP typing for handoff/tools
Copilot Dec 22, 2025
df2b783
Skip lightning tests without agentlightning and fix function call import
Copilot Dec 22, 2025
f5494b8
fix lint on lab package
eavanvalkenburg Dec 22, 2025
6ba2354
rebuilt anthropic parsing
eavanvalkenburg Dec 22, 2025
ff58948
redid anthropic parsing
eavanvalkenburg Dec 22, 2025
65d6277
typo
eavanvalkenburg Dec 22, 2025
f3fe05d
updated parsing and added missing docstrings
eavanvalkenburg Jan 5, 2026
9f68597
fix tests
eavanvalkenburg Jan 5, 2026
2327db9
mypy fixes
eavanvalkenburg Jan 5, 2026
c421bd1
second mypy fix
eavanvalkenburg Jan 5, 2026
aa92e9b
add new class to other samples
eavanvalkenburg Jan 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
247 changes: 216 additions & 31 deletions python/packages/anthropic/agent_framework_anthropic/_chat_client.py

Large diffs are not rendered by default.

49 changes: 43 additions & 6 deletions python/packages/core/agent_framework/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Generic,
Literal,
Protocol,
TypedDict,
TypeVar,
cast,
get_args,
Expand Down Expand Up @@ -73,6 +74,7 @@
"FunctionInvocationConfiguration",
"HostedCodeInterpreterTool",
"HostedFileSearchTool",
"HostedImageGenerationTool",
"HostedMCPSpecificApproval",
"HostedMCPTool",
"HostedWebSearchTool",
Expand Down Expand Up @@ -324,6 +326,41 @@ def __init__(
super().__init__(**args)


class HostedImageGenerationToolOptions(TypedDict, total=False):
"""Options for HostedImageGenerationTool."""

count: int
image_size: str
media_type: str
model_id: str
response_format: Literal["uri", "data", "hosted"]
streaming_count: int


class HostedImageGenerationTool(BaseTool):
"""Represents a hosted tool that can be specified to an AI service to enable it to perform image generation."""

def __init__(
self,
*,
options: HostedImageGenerationToolOptions | None = None,
description: str | None = None,
additional_properties: dict[str, Any] | None = None,
**kwargs: Any,
):
"""Initialize a HostedImageGenerationTool."""
if "name" in kwargs:
raise ValueError("The 'name' argument is reserved for the HostedImageGenerationTool and cannot be set.")

self.options = options
super().__init__(
name="image_generation",
description=description or "",
additional_properties=additional_properties,
**kwargs,
)


class HostedMCPSpecificApproval(TypedDict, total=False):
"""Represents the specific mode for a hosted tool.

Expand Down Expand Up @@ -1419,14 +1456,11 @@ async def _auto_invoke_function(
Raises:
KeyError: If the requested function is not found in the tool map.
"""
from ._types import (
FunctionResultContent,
)

# Note: The scenarios for approval_mode="always_require", declaration_only, and
# terminate_on_unknown_calls are all handled in _try_execute_function_calls before
# this function is called. This function only handles the actual execution of approved,
# non-declaration-only functions.
from ._types import FunctionCallContent, FunctionResultContent

tool: AIFunction[BaseModel, Any] | None = None
if function_call_content.type == "function_call":
Expand All @@ -1444,11 +1478,14 @@ async def _auto_invoke_function(
else:
# Note: Unapproved tools (approved=False) are handled in _replace_approval_contents_with_results
# and never reach this function, so we only handle approved=True cases here.
tool = tool_map.get(function_call_content.function_call.name)
inner_call = function_call_content.function_call
if not isinstance(inner_call, FunctionCallContent):
return function_call_content
tool = tool_map.get(inner_call.name)
if tool is None:
# we assume it is a hosted tool
return function_call_content
function_call_content = function_call_content.function_call
function_call_content = inner_call

parsed_args: dict[str, Any] = dict(function_call_content.parse_arguments() or {})

Expand Down
Loading
Loading