Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HttpToolConfig(BaseModel):
"""
The name of the tool.
"""
description: Optional[str]
description: Optional[str] = None
"""
A description of the tool.
"""
Expand All @@ -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.
"""
Expand Down
30 changes: 30 additions & 0 deletions python/packages/autogen-ext/tests/tools/http/test_http_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"