/launchdarkly:toolsfrom launchdarkly
Guides you through creating tool definitions (function calling) for AI agents, attaching them to LaunchDarkly config variations, and verifying they work.
Ships in launchdarkly. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You're using a skill that will guide you through adding capabilities to your agents through tools (function calling). Your job is to identify what your agent needs to do, create tool definitions, attach them to variations, and verify they work.
This skill requires the remotely hosted LaunchDarkly MCP server to be configured in your environment.
Required MCP tools:
create-ai-tool -- create a new tool definition with a schemaupdate-agent-config with resource: "variation" -- attach tools to a config variationget-agent-configs -- verify tools are attached to the variationOptional MCP tools:
get-ai-tools -- browse existing tools in the project; with toolKey, inspect one tool's schemaWhat should the agent be able to do?
If the user asks to check existing tools first, or you have no codebase context about what tools exist, follow this exact order:
get-ai-tools -- explore what existscreate-ai-tool -- create the new tool (with a key different from existing ones)update-agent-config with resource: "variation" -- attach itget-agent-configs -- verifyCall get-ai-tools as your first tool call before any creation. Never stop after listing alone -- always proceed through all four steps.
Use create-ai-tool with:
key -- unique identifier for the tooldescription -- clear description (the LLM uses this to decide when to call the tool)schema -- raw JSON Schema (do NOT use the OpenAI function calling wrapper):{
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search query"},
"limit": {"type": "integer", "default": 10}
},
"required": ["query"]
}
Use update-agent-config with resource: "variation" to attach tools. Pass only the tools field (plus projectKey, configKey, variationKey, and confirm). Do not bundle instructions, messages, model, or parameters into this PATCH unless the user has explicitly asked you to also update those fields. Those fields may have been edited in the LaunchDarkly UI since the variation was created, and including them in a tool-attachment PATCH will silently clobber the UI edits.
{
"projectKey": "my-project",
"configKey": "support-chatbot",
"resource": "variation",
"variationKey": "default",
"tools": [
{"key": "search-knowledge-base", "version": 1}
],
"confirm": true
}
If you observe a UI-clear bug where attaching tools wipes other fields, do not work around it by re-sending those fields from the previous get-agent-configs response — that masks the bug and can resurrect stale values that the user has since edited. Report the bug instead.
get-ai-tools to confirm the tool exists with a valid schemaget-agent-configs to confirm the tool is attached to the variation (check tools in the variation's output)Report results:
LaunchDarkly stores each tool's schema and attaches it to the variation. Your application supplies the function that runs when the model calls the tool. With the AI SDK (launchdarkly-ai-server for Python, @launchdarkly/ai-node for Node.js) and a provider handler package, that function is all you write. The handler converts the schemas to the provider's format, runs the tool loop, and records a $ld:ai:tool_call event for every call. You don't convert schemas, write a loop, or call a tracker.
Pass the functions as tool_handlers (Python) or toolHandlers (Node.js), keyed by the tool key you created in Step 2:
from launchdarkly_ai_server import config
from launchdarkly_ai_openai_messages import create_openai_messages_handler
def search_knowledge_base(args):
# args is one dict of the arguments the model sent, matching the tool's schema
return kb.search(args["query"], limit=args.get("limit", 10))
result = await config(
key="support-chatbot",
handler=[create_openai_messages_handler()],
tool_handlers={"search-knowledge-base": search_knowledge_base},
).invoke(user_input, {"kind": "user", "key": "user-123"})
import { config } from '@launchdarkly/ai-node';
import { createOpenAIMessagesHandler } from '@launchdarkly/ai-openai-messages';
const result = await config({
key: 'support-chatbot',
handler: [createOpenAIMessagesHandler()],
toolHandlers: {
'search-knowledge-base': async (args) => kb.search(args.query, args.limit ?? 10),
},
}).invoke(userInput, { kind: 'user', key: 'user-123' });
Rules for tool functions:
tool_handlers must equal the tool key on the variation, including case. The handlers offer the model only the variation's tools that have a function, so a tool whose key doesn't match is silently left out of the call.Tool loop exceeded the maximum number of steps (10)). A runaway loop is almost always a prompt or schema bug.To share tools across call sites, put them in a Registry (Registry(handlers=..., tools=...) in Python, new Registry({ handlers, tools }) in Node.js) and pass registry= instead. A call receives only the tools its variation names. Some providers have built-in tools, such as ClaudeWebSearch from launchdarkly-ai-claude-agents. Assign one as the value for a tool key instead of a function, and its calls are tracked the same way.
Only write provider-specific tool code when no handler package covers your provider. Then build a handler with create_handler() / createHandler(). The SDK calls your function with five arguments: the resolved config, the user input, the tool functions, the variables, and the conversation history. The config is a plain dict: config["model"] holds name and parameters, and config["tools"] maps each tool key to {type, name, description, parameters}. Convert those to the provider's shape:
| Provider | Target shape | Where it goes on the call |
|---|---|---|
| OpenAI Chat Completions | {type: "function", function: {name, description, parameters}} | top-level tools=[...] |
| OpenAI Responses API | {type: "function", name, description, parameters} | top-level tools=[...] |
| Anthropic | {name, description, input_schema}, renaming parameters to input_schema | top-level tools=[...] |
| Bedrock Converse | {toolSpec: {name, description, inputSchema: {json: parameters}}} | inside toolConfig.tools=[...] |
Gemini (google-genai) | {function_declarations: [{name, description, parameters}]} (Python) / {functionDeclarations: [...]} (Node) | GenerateContentConfig.tools=[...] |
The tool functions the SDK passes in are already wrapped to record $ld:ai:tool_call, so call them directly. Return the final text and the token usage. Here's a bounded loop against Anthropic:
from anthropic import AsyncAnthropic
from launchdarkly_ai_server import (
compose_history, create_handler, is_function_tool, parse_template, tool_result_string,
)
anthropic_client = AsyncAnthropic()
MAX_STEPS = 5
ANTHROPIC_PARAMS = {"max_tokens", "stop_sequences", "tool_choice", "thinking"}
class ToolLoopLimitError(Exception):
pass
async def call_anthropic(ld_config, user_input, tool_handlers, variables, history):
# Name each tool by its config key, which is also its key in tool_handlers. Offer only tools
# with a function, as the handler packages do; native tools and unmatched keys are skipped.
tools = [
{"name": key, "description": t.get("description", ""), "input_schema": t["parameters"]}
for key, t in (ld_config.get("tools") or {}).items()
if is_function_tool(tool_handlers.get(key), key)
]
# Handler packages fill {{name}} placeholders; custom handlers must do it themselves
rendered = [{**m, "content": parse_template(m["content"], variables)} for m in ld_config.get("messages") or []]
system = "\n".join(m["content"] for m in rendered if m["role"] == "system")
# Agent-mode and UI-created variations often use instructions instead of a system message
system = system or parse_template(ld_config.get("instructions") or "", variables)
# Allowlist, not denylist: any other key on the variation (OpenAI-shaped fields, app knobs)
# makes messages.create fail, and tools come from ld_config["tools"]. anthropic 2.x's API
# rejects temperature, top_p, and top_k anywhere in the request, so this handler drops them;
# remove them from the variation.
params = {
k: v for k, v in (ld_config["model"].get("parameters") or {}).items()
if k in ANTHROPIC_PARAMS
}
max_tokens = params.pop("max_tokens", 1024)
# Config turns (few-shot examples), then history, then the new input
messages = compose_history(
history=history or [],
user_input=user_input,
config_messages=[m for m in rendered if m["role"] != "system"],
)
usage = {"input": 0, "output": 0}
for _ in range(MAX_STEPS):
response = await anthropic_client.messages.create(
model=ld_config["model"]["name"], max_tokens=max_tokens,
system=system, messages=messages, tools=tools, **params,
)
usage["input"] += response.usage.input_tokens
usage["output"] += response.usage.output_tokens
if response.stop_reason != "tool_use":
break
messages.append({"role": "assistant", "content": response.content})
results = []
for block in response.content:
if block.type == "tool_use":
output = await tool_handlers[block.name](block.input)
results.append({"type": "tool_result", "tool_use_id": block.id, "content": tool_result_string(output)})
messages.append({"role": "user", "content": results})
else:
# Not RuntimeError: the app's fallback treats that as LaunchDarkly being unavailable
raise ToolLoopLimitError(f"model still requesting tools after {MAX_STEPS} steps")
text = "".join(b.text for b in response.content if b.type == "text")
return {"output": text, "usage": usage}
anthropic_handler = create_handler(("Anthropic", "messages"), call_anthropic)
LangGraph, CrewAI, and AutoGen often generate schemas from function definitions. You still need to create tools in LaunchDarkly and attach keys to variations so the SDK knows what's available.
| Situation | Action |
|---|---|
| Tool already exists (409) | Use existing or create with different key |
| Schema invalid | Use raw JSON Schema format (type: object, properties, required) |
| Wrong endpoint assumed | The tools use /ai-tools, not /ai-configs/tools |
instructions, messages, model, or parameters into the tool-attachment PATCH. Send tools alone unless the user explicitly asked for a multi-field update — bundled PATCHes silently clobber UI edits to the other fields.configs-create -- Create config before attaching toolsconfigs-variations -- Manage variations with different tool setsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
function-calling, launchdarkly, agent-config, tool-definitions
npx claudepluginhub launchdarkly/ai-tooling --plugin launchdarkly56 skills in this plugin
/agent-graphsCreate and manage agent graphs — directed graphs of configs connected by edges with handoff logic. Use when building multi-agent workflows where configs route to each other./aiconfig-agent-graphsDEPRECATED redirect — this skill was renamed to agent-graphs. Do not use this skill; invoke agent-graphs instead. Kept only so old references to aiconfig-agent-graphs still point users to the new name./aiconfig-ai-metricsDEPRECATED redirect — this skill was renamed to built-in-metrics. Do not use this skill; invoke built-in-metrics instead. Kept only so old references to aiconfig-ai-metrics still point users to the new name.Other plugins' skills for the same job