launchdarkly-ai-claude-agents
Anthropic Claude handler for launchdarkly-ai-server using the Claude Agent SDK (claude-agent-sdk). Runs an agentic query loop with native MCP tool support.
provides_for: ['Anthropic', 'agent'] — matches flag variations where provider.name is "Anthropic" and meta.mode is "agent".
Installation
pip install launchdarkly-ai-server launchdarkly-ai-claude-agents
Set ANTHROPIC_API_KEY in your environment (the Anthropic SDK reads it automatically).
Usage
With config()
import asyncio
from launchdarkly_ai_server import config, shutdown
from launchdarkly_ai_claude_agents import create_claude_agents_handler
async def main():
result = await config(
key="my-ai-config-flag",
handler=create_claude_agents_handler(),
tool_handlers={"search": lambda q: "..."},
).invoke("What is feature flagging?", {"kind": "user", "key": "user-123"})
print(result.response)
await shutdown()
asyncio.run(main())
Convenience wrapper
import asyncio
from launchdarkly_ai_claude_agents import claude_agents
async def main():
user_input = "What is feature flagging?"
result = await claude_agents(
user_input,
{"kind": "user", "key": "user-123"},
{"key": "my-ai-config-flag"},
variables={"user_input": user_input},
)
print(result.response)
asyncio.run(main())
Agent graphs — claude_graph()
Runs a LaunchDarkly agent graph with the Claude agent handler pre-bound. Equivalent to calling the base graph() with handlers=[create_claude_agents_handler()]. See the core client docs for the full graph() API.
import asyncio
from launchdarkly_ai_claude_agents import claude_graph
async def main():
result = await claude_graph("support-graph").invoke(
"I was double charged",
{"kind": "user", "key": "user-123"},
)
print(result["response"])
asyncio.run(main())
Native graph adapter — to_claude_agents()
Converts a resolve_graph() result into a framework-native Claude sub-agent tree (post-order traversal: leaves → root). Each child node is wrapped as an in-process MCP tool; the root runs a single query() with its children accessible as sub-agent tools. No cloud-registered agents required.
import asyncio
from launchdarkly_ai_server import resolve_graph
from launchdarkly_ai_claude_agents import to_claude_agents
async def main():
ctx = {"kind": "user", "key": "user-123"}
result = await to_claude_agents(
resolve_graph("support-graph", context=ctx),
{"tool_handlers": registry.tools, "context": ctx},
).invoke("I was double charged")
print(result["response"])
asyncio.run(main())
How It Works
- Uses the system prompt and conversation history defined in your LaunchDarkly flag config.
- Template placeholders (
{{variable}}) in the prompt are substituted usingvariablesbefore the call. - If tools are defined in the flag config, the Claude Agent SDK handles all tool dispatch and the agentic loop automatically — no extra wiring needed.
- Emits an OTel span and LaunchDarkly telemetry for every call.
Built-in Claude Tools
This package exports NativeTool sentinels for Claude Code built-in capabilities. Place them as values in tool_handlers to enable the corresponding native Claude tool without writing a handler function:
| Export | Claude SDK tool name |
|---|---|
ClaudeBash |
Bash |
ClaudeRead |
Read |
ClaudeEdit |
Edit |
ClaudeWrite |
Write |
ClaudeGlob |
Glob |
ClaudeGrep |
Grep |
ClaudeWebFetch |
WebFetch |
ClaudeWebSearch |
WebSearch |
ClaudeTodoWrite |
TodoWrite |
ClaudeNotebookEdit |
NotebookEdit |
from launchdarkly_ai_claude_agents import ClaudeWebSearch, create_claude_agents_handler
from launchdarkly_ai_server import config
result = await config(
key="my-ai-config-flag",
tool_handlers={"web-search": ClaudeWebSearch},
handler=[create_claude_agents_handler()],
).invoke("What are the latest LD release notes?", {"kind": "user", "key": "user-123"})
Environment Variables
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY |
Anthropic API key (read automatically by the Anthropic SDK) |
LD_SDK_KEY |
LaunchDarkly server-side SDK key |
LD_SERVICE_NAME |
OTel service.name resource attribute (default: python-sdk) |
LD_ENVIRONMENT |
deployment.environment attribute attached to telemetry |
OTEL_EXPORTER_OTLP_ENDPOINT |
OTLP endpoint override (default: LaunchDarkly Observability backend) |
Metadata
Release files for launchdarkly-ai-claude-agents 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| launchdarkly_ai_claude_agents-0.2.6.tar.gz | 56.8 kB | Without provenance | Details for launchdarkly_ai_claude_agents-0.2.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| launchdarkly_ai_claude_agents-0.2.6-py3-none-any.whl | Python 3 | none | any | Details for launchdarkly_ai_claude_agents-0.2.6-py3-none-any.whl |
Total release size: 85.1 kB
Release files / launchdarkly_ai_claude_agents-0.2.6.tar.gz
| Download URL | launchdarkly_ai_claude_agents-0.2.6.tar.gz |
|---|---|
| Size | 56.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68f82efc045fbc3af304368e262514dc573e8be3cd8c15db78e95256af52361a
|
|
BLAKE2b-256 checksum How to use checksums |
bd592af6b244c649bd1ad9c9616c27ff4e984e35e3c8111be503c25b15779e8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / launchdarkly_ai_claude_agents-0.2.6-py3-none-any.whl
| Download URL | launchdarkly_ai_claude_agents-0.2.6-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c111df476ec4960f418127425c8dcd44798fc07562bac047c577feb31f501dc
|
|
BLAKE2b-256 checksum How to use checksums |
44bf54d0966114993c0f65a581f8480a836575fb1e8e665e1454d615b35ef6f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for launchdarkly-ai-claude-agents 0.2.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.