Support tool config in yaml
This commit is contained in:
@@ -202,3 +202,51 @@ def test_agent_yaml_missing_env_reference_fails(monkeypatch, tmp_path):
|
||||
|
||||
with pytest.raises(ValueError, match="Missing environment variable"):
|
||||
load_settings(argv=["--agent-config", str(file_path)])
|
||||
|
||||
|
||||
def test_agent_yaml_tools_list_is_loaded(monkeypatch, tmp_path):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
file_path = tmp_path / "tools-agent.yaml"
|
||||
_write_yaml(
|
||||
file_path,
|
||||
_full_agent_yaml()
|
||||
+ """
|
||||
|
||||
tools:
|
||||
- current_time
|
||||
- name: weather
|
||||
description: Get weather by city.
|
||||
parameters:
|
||||
type: object
|
||||
properties:
|
||||
city:
|
||||
type: string
|
||||
required: [city]
|
||||
executor: server
|
||||
""",
|
||||
)
|
||||
|
||||
settings = load_settings(argv=["--agent-config", str(file_path)])
|
||||
|
||||
assert isinstance(settings.tools, list)
|
||||
assert settings.tools[0] == "current_time"
|
||||
assert settings.tools[1]["name"] == "weather"
|
||||
assert settings.tools[1]["executor"] == "server"
|
||||
|
||||
|
||||
def test_agent_yaml_tools_must_be_list(monkeypatch, tmp_path):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
file_path = tmp_path / "bad-tools-agent.yaml"
|
||||
_write_yaml(
|
||||
file_path,
|
||||
_full_agent_yaml()
|
||||
+ """
|
||||
|
||||
tools:
|
||||
weather:
|
||||
executor: server
|
||||
""",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="Agent config key 'tools' must be a list"):
|
||||
load_settings(argv=["--agent-config", str(file_path)])
|
||||
|
||||
Reference in New Issue
Block a user