Skip to content

feat: add root-level tools map with customParameters to AI Config types#141

Merged
jsonbailey merged 8 commits intomainfrom
jb/aic-1935/custom-tool-params
Apr 27, 2026
Merged

feat: add root-level tools map with customParameters to AI Config types#141
jsonbailey merged 8 commits intomainfrom
jb/aic-1935/custom-tool-params

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented Apr 20, 2026

Summary

  • Adds AITool frozen dataclass with name, type?, parameters?, and custom_parameters? fields
  • Adds tools: Optional[Dict[str, AITool]] to AICompletionConfig, AICompletionConfigDefault, AIAgentConfig, and AIAgentConfigDefault
  • Adds _parse_tools() helper in client.py that parses the root-level tools map from flag variations
  • Updates _completion_config and __evaluate_agent to parse and propagate tools, falling back to default.tools when absent
  • Exports AITool from ldai.__init__
  • Adds tests/test_tools.py with 6 tests covering tools in completion config, agent config, default fallback, and serialization

Background

The LaunchDarkly backend now includes a root-level tools map (sibling to model) in AI Config flag variations. This is separate from model.parameters.tools[] which is the raw array passable to LLM providers as-is. LLM providers reject unknown properties, so customParameters cannot live inside model.parameters.tools[] — hence the split.

Wire format:

{
  "tools": {
    "web-search-tool": {
      "name": "web-search-tool",
      "type": "function",
      "parameters": { ... },
      "customParameters": { "some-custom-parameter": "some-custom-value" }
    }
  }
}

customParameters is camelCase in the wire format; the Python model uses custom_parameters (snake_case) and serializes back to camelCase in to_dict().

Note

Supersedes PR #106 (devin/1773277027-add-tool-instructions-examples) which had the wrong structure (list instead of map, wrong fields key/version/instructions/examples).

Test plan

  • poetry run pytest — all existing tests pass, 6 new tests for tools coverage
  • Verify AITool.to_dict() serializes custom_parameters as customParameters

🤖 Generated with Claude Code


Note

Medium Risk
Medium risk because it changes the public AI config data model and flag-variation parsing for completion_config/agent_config, which could affect downstream consumers and serialization expectations.

Overview
Adds first-class support for a root-level tools map in AI Config flag variations by introducing the LDTool model (including customParameters wire-format support) and wiring it into AICompletionConfig* and AIAgentConfig*.

Updates LDAIClient evaluation to parse variation['tools'] via _parse_tools() and expose it on returned configs, and exports LDTool from ldai. Adds a focused test suite covering parsing behavior (tools present vs absent) and LDTool.to_dict() camelCase serialization/omissions.

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

@jsonbailey jsonbailey marked this pull request as ready for review April 24, 2026 22:19
@jsonbailey jsonbailey requested a review from a team as a code owner April 24, 2026 22:19
Comment thread packages/sdk/server-ai/src/ldai/__init__.py Outdated
Adds AITool dataclass and tools map (keyed by tool name) to completion
and agent config types. The root-level tools map is distinct from
model.parameters.tools[] which remains passable to LLM providers as-is.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-1935/custom-tool-params branch from 826f6bb to 6661d5f Compare April 24, 2026 22:25
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread packages/sdk/server-ai/src/ldai/client.py Outdated
Comment thread packages/sdk/server-ai/src/ldai/client.py Outdated
jsonbailey and others added 3 commits April 27, 2026 09:09
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread packages/sdk/server-ai/src/ldai/client.py Outdated
jsonbailey and others added 2 commits April 27, 2026 09:26
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ites

The variation call already incorporates the default via default_dict;
applying a second-level default here is incorrect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

There are 2 total unresolved issues (including 1 from previous review).

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 ccc744e. Configure here.

Comment thread packages/sdk/server-ai/src/ldai/client.py Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey merged commit f17c535 into main Apr 27, 2026
46 checks passed
@jsonbailey jsonbailey deleted the jb/aic-1935/custom-tool-params branch April 27, 2026 15:48
@github-actions github-actions Bot mentioned this pull request Apr 27, 2026
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.

2 participants