Skip to content

fix: parse model.parameters.tools as list#160

Open
jsonbailey wants to merge 1 commit intomainfrom
jb/aic-1935/list-tools-format
Open

fix: parse model.parameters.tools as list#160
jsonbailey wants to merge 1 commit intomainfrom
jb/aic-1935/list-tools-format

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented May 1, 2026

Summary

  • model.parameters.tools wire format is a list of LDTool objects; root-level tools is a dict keyed by tool name. Previously _resolve_tools checked for a dict in both paths, so the model params fallback always returned None.
  • Fixes _resolve_tools to check isinstance(tools_list, list) for the model params path and iterate it to build the tools dict.
  • Removes the _parse_tools and _parse_tools_from_list helpers, inlining the logic. No warnings are emitted — data from the LD API is trusted to be our shape, matching the JS SDK approach.
  • Updates test fixtures and adds/renames tests to cover list format, dict format rejection, and silent skipping of nameless entries.

Test plan

  • uv run pytest tests/test_tools.py — all 11 tools tests pass
  • uv run pytest — all 154 tests pass
  • uv run mypy src/ldai — no type errors

🤖 Generated with Claude Code


Note

Medium Risk
Changes how tool definitions are parsed from AI config flag variations, which can affect which tools are available at runtime for completions/agents. Scope is small and covered by updated/added unit tests for accepted and rejected wire formats.

Overview
Fixes tool resolution so model.parameters.tools is parsed from the correct list wire format (building a name-keyed dict), while keeping root-level tools as the higher-priority dict format.

Removes the shared _parse_tools helper and inlines parsing logic, and updates tests/fixtures to validate list parsing, dict rejection for model params, and skipping malformed list entries.

Reviewed by Cursor Bugbot for commit 05e9c78. Bugbot is set up for automated code reviews on this repo. Configure here.

The wire format for tools at model.parameters.tools is a list of LDTool
objects, while root-level tools is a dict keyed by tool name. Previously
_resolve_tools treated both as dicts, causing the model params fallback
path to always return None.

Removes helper functions and inlines logic into _resolve_tools with no
warnings, matching the JS implementation approach of trusting the data
shape from the LD API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey marked this pull request as ready for review May 1, 2026 20:58
@jsonbailey jsonbailey requested a review from a team as a code owner May 1, 2026 20:58
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 05e9c78. Configure here.

return None
tools: Dict[str, LDTool] = {}
for tool_name, tool_dict in tools_data.items():
if isinstance(tool_dict, dict):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent data dropping in inlined parsing logic lacks logging

Low Severity

The removed _parse_tools helper previously logged warnings when discarding malformed tool entries (e.g., non-dict values). That same parsing logic is now inlined into _resolve_tools at lines 63 and 85, where entries failing isinstance checks are silently skipped without any warning or debug log. The rule requires log messages when flag variation data is silently dropped because it doesn't match the expected type. Although _resolve_tools is exempted for navigation type-checks (e.g. if not isinstance(model, dict): return None), the entry-level iteration and filtering on lines 63 and 85 is data-validation/parsing work — the same logic that _parse_tools performed with warnings.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: Flag silent data dropping in parsing helpers — warn/log on malformed input

Reviewed by Cursor Bugbot for commit 05e9c78. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant