Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ LD_SDK_KEY=your-sdk-key-here
OPENAI_API_KEY=your-openai-key-here
ANTHROPIC_API_KEY=your-anthropic-key-here

# Google ADK. Gemini Developer API is the default; set one of these.
GOOGLE_API_KEY=your-gemini-key-here
# GEMINI_API_KEY=
# GOOGLE_GENAI_API_KEY=
# Vertex is opt-in in the handler (use_vertexai=True). Do not set these for the Gemini path.
# GOOGLE_CLOUD_PROJECT=
# GOOGLE_CLOUD_LOCATION=

# LaunchDarkly endpoints (leave blank to use production defaults)
LD_BASE_URI=
LD_STREAM_URI=
Expand Down
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"packages/openai-agents": "0.2.3",
"packages/openai-messages": "0.2.3",
"packages/langchain-agents": "0.2.3",
"packages/langchain-messages": "0.2.3"
"packages/langchain-messages": "0.2.3",
"packages/google-adk-agents": "0.1.0"
}
13 changes: 13 additions & 0 deletions .sdk_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@
"aiAgentGraph": { "introduced": "0.1" },
"aiTrackMetrics": { "introduced": "0.1" }
}
},
"python-ai-google-adk-agents": {
"name": "Google ADK Agents AI SDK for Python",
"type": "ai-provider",
"path": "packages/google-adk-agents",
"languages": ["Python"],
"aiSdkNames": ["launchdarkly-ai-google-adk-agents"],
"releases": { "tag-prefix": "launchdarkly-ai-google-adk-agents-" },
"features": {
"aiAgentConfig": { "introduced": "0.1" },
"aiAgentGraph": { "introduced": "0.1" },
"aiTrackMetrics": { "introduced": "0.1" }
}
}
}
}
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ graph TD
claude["launchdarkly-ai-claude-agents"]
openai["launchdarkly-ai-openai-agents"]
langchain["launchdarkly-ai-langchain-agents"]
googleAdk["launchdarkly-ai-google-adk-agents"]
newHandler["launchdarkly-ai-new-provider\n(future)"]
end
subgraph tier0 ["Tier 0 — Core"]
Expand All @@ -97,11 +98,13 @@ graph TD
app --> claude
app --> openai
app --> langchain
app --> googleAdk
app --> newHandler
app --> ai
claude --> client
openai --> client
langchain --> client
googleAdk --> client
newHandler --> client
ai --> client
```
Expand All @@ -110,7 +113,7 @@ graph TD

- **Tier 0 — Core** (`launchdarkly-ai-server`): The foundation. Owns all LaunchDarkly integration, telemetry orchestration, shared data types, and the primary entry points (`config()`, `graph()`, `resolve_graph()`). Has no dependency on any other `launchdarkly-ai-*` package.
- **Tier 0 — Convenience barrel** (`launchdarkly-ai-python`): A pure re-export package that makes all of `launchdarkly-ai-server` available under a shorter install name. No new logic — intended as the default install for most Python applications.
- **Tier 1 — Handler packages** (`launchdarkly-ai-claude-agents`, `launchdarkly-ai-claude-messages`, `launchdarkly-ai-openai-agents`, `launchdarkly-ai-openai-messages`, `launchdarkly-ai-langchain-agents`, `launchdarkly-ai-langchain-messages`, …): Each wraps a specific AI provider SDK. Depends on `launchdarkly-ai-server` for shared types and utilities. Must not depend on other Tier 1 packages.
- **Tier 1 — Handler packages** (`launchdarkly-ai-claude-agents`, `launchdarkly-ai-claude-messages`, `launchdarkly-ai-openai-agents`, `launchdarkly-ai-openai-messages`, `launchdarkly-ai-langchain-agents`, `launchdarkly-ai-langchain-messages`, `launchdarkly-ai-google-adk-agents`, …): Each wraps a specific AI provider SDK. Depends on `launchdarkly-ai-server` for shared types and utilities. Must not depend on other Tier 1 packages.
- **Tier 2 — Consumer applications** (e.g. `main.py`, downstream projects): Imports from one or more handler packages and either `launchdarkly-ai-python` or `launchdarkly-ai-server`. Owns tool implementations and orchestration logic. No `launchdarkly-ai-*` package should ever depend on Tier 2 code.

### Rules
Expand Down
41 changes: 41 additions & 0 deletions examples/google_adk_agents_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Example: google_adk_agents() — Google ADK agents handler (wildcard provider).

Gemini Developer API is the default (`GOOGLE_API_KEY`, `GEMINI_API_KEY`, or
`GOOGLE_GENAI_API_KEY`). Vertex is opt-in: pass `use_vertexai=True` plus project
and location, or set `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`.

Usage (via main.py):
python main.py google-adk-agents <flag-key> "<user input>"
"""

from __future__ import annotations

import json

from examples.tools import (
fetch_launchdarkly_documentation,
get_preferences,
search_ld_documentation,
web_search,
)
from examples.utils import new_context, write_output
from launchdarkly_ai_google_adk_agents import google_adk_agents


async def run(key: str, user_input: str) -> None:
response = await google_adk_agents(
key,
user_input,
new_context(),
tool_handlers={
"get-user-preferences": get_preferences,
"search-ld-documentation": search_ld_documentation,
"fetch-ld-documentation": fetch_launchdarkly_documentation,
"fetch-launchdarkly-documentation": fetch_launchdarkly_documentation,
"web-search": web_search,
},
)

print(json.dumps(response, indent=2, default=str))
write_output(response)
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
python main.py claude-agents launch-darkly-documentation-summarizer "What is the LaunchDarkly AI SDK?"
python main.py openai-agents launch-darkly-documentation-summarizer-open-ai-only "What is the LaunchDarkly AI SDK?"
python main.py langchain-agents launch-darkly-documentation-summarizer "What is the LaunchDarkly AI SDK?"
python main.py google-adk-agents launch-darkly-documentation-summarizer "What is the LaunchDarkly AI SDK?"
python main.py langchain-thinking launch-darkly-documentation-summarizer-messages-claude "Reason it out yourself without any tools: what is 17 times 23?"
python main.py native-graph travel-agent-flow "Book me a flight to Paris"
python main.py native-graph-langchain travel-agent-flow "Book me a flight to Paris"
Expand Down Expand Up @@ -56,6 +57,7 @@
"openai-only": "examples.openai_only",
"langchain": "examples.langchain_example",
"langchain-agents": "examples.langchain_agents_example",
"google-adk-agents": "examples.google_adk_agents_example",
"langchain-messages": "examples.langchain_messages_example",
"langchain-thinking": "examples.langchain_thinking",
"native-graph": "examples.native_graph",
Expand Down
17 changes: 17 additions & 0 deletions packages/google-adk-agents/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Google ADK agents

`launchdarkly-ai-google-adk-agents` is a wildcard agent handler for [Google ADK](https://google.github.io/adk-docs/). It serves any `agent` variation that does not have a more specific provider handler registered.

```python
from launchdarkly_ai_google_adk_agents import google_adk_agents

response = await google_adk_agents(key, user_input, context, tool_handlers=tools)
```

Gemini Developer API is the default. Set `GOOGLE_API_KEY`, `GEMINI_API_KEY`, or `GOOGLE_GENAI_API_KEY`. Vertex is explicit: `create_google_adk_agents_handler(use_vertexai=True, project=..., location=...)`. A Gemini credential is never sent on the Vertex path, and a failed call is not retried on the other transport.

Non-Gemini models use ADK's `LiteLlm` adapter (`pip install 'google-adk[extensions]'`). The model id is `{provider}/{model}` unless the configured name already contains a slash. Pass `model=` to supply your own ADK model and skip both constructors.

`google-adk` is not declared on this package. Release 2.9.2 caps `opentelemetry-sdk<=1.42.1`, which conflicts with this workspace's exporter. Install ADK in the application environment.

`to_adk_agents(graph)` compiles a LaunchDarkly agent graph into an ADK `Workflow`. `google_adk_graph(key)` pre-wires this handler for `graph()`.
20 changes: 20 additions & 0 deletions packages/google-adk-agents/agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Agent Guide — `launchdarkly-ai-google-adk-agents`

Wildcard agent handler (`provides_for = ("*", "agent")`) for Google ADK. An exact provider handler still wins when both are registered.

Gemini Developer API is the default. Vertex is opt-in (`use_vertexai=True`) and requires project and location at factory time. Do not send an API key in Vertex mode, and do not fall back from one transport to the other.

Python non-Gemini models go through ADK's `google.adk.models.lite_llm.LiteLlm` as `provider/model`. That is ADK's adapter, not `launchdarkly-ai-litellm`. TypeScript `@google/adk` 2.1 has no equivalent; inject `model` or the handler throws.

`google-adk` is imported lazily and is not a workspace dependency, because 2.9.2 caps `opentelemetry-sdk`. Install it in the app environment (`google-adk[extensions]` when you need LiteLLM).

## File map

| File | Responsibility |
|---|---|
| `handler.py` | Factory, session seeding, `LaunchDarklyTelemetryPlugin`, run and stream |
| `spans.py` | `invoke_agent` / `chat {model}` / `execute_tool {name}` |
| `graph.py` | `google_adk_graph()` |
| `native_graph.py` | `to_adk_agents()` |

Span calls go through the `spans` module attribute so tests can patch them. Tool spans are abandoned from a `finally` (`abandon_open_spans` does not call `fail_span`). `gen_ai.system` is `google_adk`. `gen_ai.provider.name` is the serving provider; Google, Gemini, and Vertex normalize to `gcp.gemini`.
36 changes: 36 additions & 0 deletions packages/google-adk-agents/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[project]
name = "launchdarkly-ai-google-adk-agents"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"launchdarkly-ai-server",
"opentelemetry-api>=1.25",
]
# google-adk[extensions]>=2.9.2 is the runtime dependency. It is intentionally
# not declared yet: 2.9.2 caps opentelemetry-sdk<=1.42.1, which the workspace
# cannot solve next to opentelemetry-exporter-otlp-proto-http>=1.43.
description = "Google ADK agent handler for LaunchDarkly AI SDK"
readme = "README.md"
license = "Apache-2.0"
authors = [{name = "LaunchDarkly", email = "team@launchdarkly.com"}]
keywords = ["launchdarkly", "ai", "google-adk", "agents"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries",
]

[project.urls]
Homepage = "https://github.com/launchdarkly/python-ai-sdk"
Repository = "https://github.com/launchdarkly/python-ai-sdk"
"Bug Tracker" = "https://github.com/launchdarkly/python-ai-sdk/issues"

[build-system]
requires = ["hatchling>=1.32,<2"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/launchdarkly_ai_google_adk_agents"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""LaunchDarkly AI SDK integration for Google ADK agents.

See https://launchdarkly.com/docs for usage.
"""

__version__ = "0.1.0" # x-release-please-version

from launchdarkly_ai_server import register_ai_sdk_package

from .graph import google_adk_graph
from .handler import (
create_google_adk_agents_handler,
google_adk_agents,
history_contents,
)
from .native_graph import to_adk_agents

__all__ = [
"create_google_adk_agents_handler",
"google_adk_agents",
"google_adk_graph",
"history_contents",
"to_adk_agents",
]

register_ai_sdk_package("launchdarkly-ai-google-adk-agents", __version__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Graph convenience wrapper for the Google ADK agents handler."""

from __future__ import annotations

from typing import Any

from launchdarkly_ai_server import graph

from .handler import create_google_adk_agents_handler


def google_adk_graph(
key: str,
*,
use_vertexai: bool = False,
project: str | None = None,
location: str | None = None,
model: Any = None,
capture_content: bool = False,
**options: Any,
) -> Any:
"""Runs an agent graph with one wildcard ADK handler pre-bound.

``handlers`` passed by the caller is ignored. Auth and model options go to the
handler factory, not to ``graph()``.
"""
options.pop("handlers", None)
return graph(
key,
handlers=[
create_google_adk_agents_handler(
use_vertexai=use_vertexai,
project=project,
location=location,
model=model,
capture_content=capture_content,
)
],
**options,
)
Loading
Loading