From 8a95a7fa0274027c39bb2897eee1325a5e56bb40 Mon Sep 17 00:00:00 2001 From: panshularora Date: Tue, 11 Aug 2026 08:26:46 +0530 Subject: [PATCH 1/3] test: pass coerce_tool_configs().tool_configs into resolver (fixes vacuous test) --- .../tests/pytest/unit/agents/tools/test_resolver.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py b/sdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py index 2d4afd5d0a..2d7e7b3a18 100644 --- a/sdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py +++ b/sdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py @@ -295,8 +295,15 @@ async def resolve(self, tools): async def test_a_bare_tool_name_string_is_ignored_too(): - # `coerce_tool_config` turns a bare string into a BuiltinToolConfig. - resolved = await ToolResolver().resolve(coerce_tool_configs(["read"])) + # `coerce_tool_configs` turns a bare string into a BuiltinToolConfig. + # Pass `.tool_configs` — the parse result itself is not a sequence of configs + # (iterating the pydantic model yields field tuples, so resolve would not see + # the coerced BuiltinToolConfig and would pass for the wrong reason). + parsed = coerce_tool_configs(["read"]) + assert len(parsed.tool_configs) == 1 + assert isinstance(parsed.tool_configs[0], BuiltinToolConfig) + + resolved = await ToolResolver().resolve(parsed.tool_configs) assert resolved.tool_specs == [] From b7c1e5b8877c0b0dc21339efde3d192a68db0500 Mon Sep 17 00:00:00 2001 From: panshularora Date: Tue, 11 Aug 2026 08:26:48 +0530 Subject: [PATCH 2/3] test: parse JSON examples recursively for builtin type drift check --- .../test_agenta_builtins_reference_files.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py b/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py index b0aca3fbd3..46ccccccd1 100644 --- a/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py +++ b/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py @@ -10,9 +10,10 @@ from __future__ import annotations +import json import re from pathlib import Path -from typing import get_args +from typing import Any, get_args import pytest @@ -165,13 +166,26 @@ def test_config_schema_names_every_tool_type_discriminator(): assert not missing, f"config-schema.md does not document tool type(s): {missing}" +def _contains_builtin_type(value: Any) -> bool: + """Recursively detect any object with ``type == "builtin"`` (whitespace-safe).""" + if isinstance(value, dict): + if value.get("type") == "builtin": + return True + return any(_contains_builtin_type(item) for item in value.values()) + if isinstance(value, list): + return any(_contains_builtin_type(item) for item in value) + return False + + def test_no_json_example_writes_a_builtin_tool_entry(): # The `builtin` arm survives only as legacy dual-read. The authoring agent copies these # examples verbatim, so an example that still writes one would keep producing configs the # resolver has to ignore. + # Parse each fenced JSON block so whitespace variants like `"type":"builtin"` still fail. content = _file("references/config-schema.md").content for block in re.findall(r"```json\n(.*?)```", content, flags=re.DOTALL): - assert '"type": "builtin"' not in block, ( + data = json.loads(block) + assert not _contains_builtin_type(data), ( "a JSON example in config-schema.md still writes a builtin tool entry" ) From f2c52b02c31efb9e3d0141d07a3c8a53ccc2fb96 Mon Sep 17 00:00:00 2001 From: panshularora Date: Tue, 11 Aug 2026 09:50:44 +0530 Subject: [PATCH 3/3] test: require JSON fences so builtin drift check cannot pass vacuously --- .../unit/agents/test_agenta_builtins_reference_files.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py b/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py index 46ccccccd1..37153b2923 100644 --- a/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py +++ b/sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py @@ -182,8 +182,15 @@ def test_no_json_example_writes_a_builtin_tool_entry(): # examples verbatim, so an example that still writes one would keep producing configs the # resolver has to ignore. # Parse each fenced JSON block so whitespace variants like `"type":"builtin"` still fail. + # Match indented / spaced fences and require at least one block so the test cannot pass vacuously. content = _file("references/config-schema.md").content - for block in re.findall(r"```json\n(.*?)```", content, flags=re.DOTALL): + blocks = re.findall( + r"^[ \t]*```json[ \t]*\r?\n(.*?)^[ \t]*```", + content, + flags=re.DOTALL | re.IGNORECASE | re.MULTILINE, + ) + assert blocks, "config-schema.md must contain a fenced JSON example" + for block in blocks: data = json.loads(block) assert not _contains_builtin_type(data), ( "a JSON example in config-schema.md still writes a builtin tool entry"