[5662] test(sdk): fix two builtin-tool tests that don't exercise what they claim - #5680
[5662] test(sdk): fix two builtin-tool tests that don't exercise what they claim#5680Yuvakunaal wants to merge 3 commits into
Conversation
…laim test_a_bare_tool_name_string_is_ignored_too passed coerce_tool_configs's pydantic ToolConfigParseResult straight into resolve(), which iterates it as (field, value) tuples instead of the coerced BuiltinToolConfig — the empty tool_specs result was true for the wrong reason. It now asserts on .tool_configs directly before resolving. test_no_json_example_writes_a_builtin_tool_entry used a raw substring check that any whitespace variant like "type":"builtin" slips past. It now json.loads each fenced block and recursively walks it for any type == "builtin" entry, failing loudly on invalid JSON too. Closes Agenta-AI#5662
|
@Yuvakunaal is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes strengthen two SDK unit tests. JSON examples are parsed and recursively checked for builtin tool entries. The resolver test separately validates bare tool-name coercion before resolution. ChangesBuilt-in tool test validation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Strengthens two existing SDK unit tests in the built-ins area so they actually validate the intended behavior (tool config coercion and JSON example validation), preventing vacuous passes and whitespace-sensitive false negatives.
Changes:
- Fixes the resolver test to assert
coerce_tool_configs(["read"])produces the expectedBuiltinToolConfig, and then resolves the extractedtool_configslist. - Replaces a brittle substring check in the reference-file test with
json.loadsplus a recursive scan for any object withtype == "builtin".
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py | Ensures the coercion path is exercised by asserting parsed tool configs before resolving. |
| sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py | Makes the “no builtin tool entries in JSON examples” check robust by parsing JSON and scanning structurally. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b0e898ca-84cc-4ec7-9260-210d5cf12df3
📒 Files selected for processing (2)
sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.pysdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py
…test CodeRabbit caught it: re.findall could return an empty list, and the loop would then silently validate nothing while still passing. Assert at least one block is found before iterating.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
sdks/python/oss/tests/pytest/unit/agents/test_agenta_builtins_reference_files.py:195
- The failure output here can be hard to act on because
config-schema.mdcontains multiple JSON fenced blocks (see_CONFIG_SCHEMA_REFERENCEinagenta_builtins.py). If one block is invalid JSON or still contains a builtin tool entry, the assertion doesn’t identify which block failed, making debugging slower.
Consider enumerating the blocks and including the index (and total) in both the JSONDecodeError assertion and the builtin-entry assertion message.
f"config-schema.md has a json fence that is not valid JSON: {exc}"
) from exc
assert not _contains_builtin_tool_entry(parsed), (
"a JSON example in config-schema.md still writes a builtin tool entry"
)
Closes #5662
Summary
Two unit tests in the SDK tests from the built-ins directory pass but don't actually test what they are supposed to be testing.
test_a_bare_tool_name_string_is_ignored_too (
test_resolver.py) invokedToolResolver().resolve(coerce_tool_configs(["read"])).coerce_tool_configsreturns a
ToolConfigParseResultpydantic model rather than a list ofconfigs, thus iterating over it inside
resolve()will yield pairs(field, value)rather than the actualBuiltinToolConfigobjects.resolve()will quietly accept this wrong input and returntool_specs == []which is indeed correct, but this doesn't mean that thecoercion path was actually taken. It now first asserts
coerce_tool_configs(["read"]).tool_configs == [BuiltinToolConfig(name="read")],and only then resolves that list.
test_no_json_example_writes_a_builtin_tool_entry
(
test_agenta_builtins_reference_files.py) was checking that'"type": "builtin"' not in blockas an unprocessed string. However, anyvariant with whitespace, like
"type":"builtin", would pass silently.It now
json.loadss each block and recursively walks dicts and listsfor any object with
type == "builtin", and fails loudly if a blockisn't even valid JSON.
Testing
Verified locally
run-tests.py): 2382 passed, 4 skipped, 10 xfailed.The single unit test failure (
test_cli_stream_terminal_only_on_empty_request)and the 97 acceptance test errors are pre-existing and totally
unrelated – confirmed by stashing this change and re-running against
an unmodified
main, yielding the same results. The acceptance errorsrequire a live
AGENTA_API_URL.issue: corrupted the expected value in the resolver assertion and
verified pytest fails with a proper diff, then reverted it. For the
JSON example check, verified that the new algorithm correctly catches
the no-space
"type":"builtin"case where the old substring checkwould silently miss it.
ruff formatandruff check: clean.Added or updated tests
N/A — this PR only strengthens two existing tests, no new tests added.
QA follow-up
N/A — test-only change, no user-visible behavior.
Demo
N/A — not a UI change.
AI assistance disclosure
Written with Claude Sonnet 5 via Claude Code (CLI), standard interactive
reasoning (no extended/deep-thinking budget configured for this session).
Session: read the actual source (
ToolConfigParseResult,BuiltinToolConfig,the reference-file regex extraction) to verify both bugs independently rather
than trust the issue text alone, found and reused an existing idiomatic
assertion pattern already in the codebase (
test_parsing.py) for the firstfix, implemented both rewrites, ran the targeted files and the full SDK suite,
then did the sanity checks described above before handing off for commit/push.
Checklist
Contributor Resources