diff --git a/python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py b/python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py index c519143be4c5..e18398fa542c 100644 --- a/python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py +++ b/python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py @@ -16,7 +16,7 @@ class HttpToolConfig(BaseModel): """ The name of the tool. """ - description: Optional[str] + description: Optional[str] = None """ A description of the tool. """ @@ -42,7 +42,7 @@ class HttpToolConfig(BaseModel): """ The HTTP method to use, will default to POST if not provided. """ - headers: Optional[dict[str, Any]] + headers: Optional[dict[str, Any]] = None """ A dictionary of headers to send with the request. """ diff --git a/python/packages/autogen-ext/tests/tools/http/test_http_tool.py b/python/packages/autogen-ext/tests/tools/http/test_http_tool.py index 8e50e48ba926..c2a01560862e 100644 --- a/python/packages/autogen-ext/tests/tools/http/test_http_tool.py +++ b/python/packages/autogen-ext/tests/tools/http/test_http_tool.py @@ -4,6 +4,7 @@ import httpx import pytest from autogen_core import CancellationToken, Component, ComponentModel +from autogen_core.tools import StaticStreamWorkbench from autogen_ext.tools.http import HttpTool from pydantic import ValidationError @@ -205,3 +206,32 @@ def test_config_deserialization(test_config: ComponentModel) -> None: assert tool.server_params.scheme == test_config.config["scheme"] assert tool.server_params.method == test_config.config["method"] assert tool.server_params.headers == test_config.config["headers"] + + +@pytest.mark.asyncio +async def test_workbench_from_config_with_missing_headers_field() -> None: + tool = HttpTool( + name="base64_decode", + description="base64 decode a value", + scheme="https", + host="httpbin.org", + port=443, + path="/base64/{value}", + method="GET", + headers=None, + json_schema={ + "type": "object", + "properties": { + "value": {"type": "string", "description": "The base64 value to decode"}, + }, + "required": ["value"], + }, + ) + + workbench = StaticStreamWorkbench(tools=[tool]) + config = workbench.dump_component() + new_workbench = StaticStreamWorkbench.load_component(config, StaticStreamWorkbench) + + tools = await new_workbench.list_tools() + assert len(tools) == 1 + assert tools[0]["name"] == "base64_decode"