Skip to content
Open
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 @@ -9,6 +9,14 @@ AI_GATEWAY_API_KEY=your-vercel-ai-gateway-key-here
# Python LiteLLM runs in-process and uses the provider keys above; no
# LITELLM_BASE_URL or proxy API key is required.

# 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
34 changes: 34 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ on:
- packages/langchain-agents
- packages/langchain-messages
- packages/opencode-agents
- packages/google-adk-agents
- packages/vercel-agents
- packages/vercel-messages
dry_run:
Expand Down Expand Up @@ -73,6 +74,8 @@ jobs:
package-langchain-messages-tag-name: ${{ steps.release.outputs['packages/langchain-messages--tag_name'] }}
package-opencode-agents-released: ${{ steps.release.outputs['packages/opencode-agents--release_created'] }}
package-opencode-agents-tag-name: ${{ steps.release.outputs['packages/opencode-agents--tag_name'] }}
package-google-adk-agents-released: ${{ steps.release.outputs['packages/google-adk-agents--release_created'] }}
package-google-adk-agents-tag-name: ${{ steps.release.outputs['packages/google-adk-agents--tag_name'] }}
package-vercel-agents-released: ${{ steps.release.outputs['packages/vercel-agents--release_created'] }}
package-vercel-agents-tag-name: ${{ steps.release.outputs['packages/vercel-agents--tag_name'] }}
package-vercel-messages-released: ${{ steps.release.outputs['packages/vercel-messages--release_created'] }}
Expand Down Expand Up @@ -424,6 +427,37 @@ jobs:
password: ${{ env.PYPI_AUTH_TOKEN }}
packages-dir: packages/opencode-agents/dist/

release-google-adk-agents:
runs-on: ubuntu-latest
needs: ['release-please']
permissions:
contents: read
id-token: write
attestations: write
if: ${{ needs.release-please.outputs.package-google-adk-agents-released == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/ci
with:
workspace_path: packages/google-adk-agents
- uses: ./.github/actions/build
with:
workspace_path: packages/google-adk-agents
- name: Attest build provenance
uses: actions/attest@v4
with:
subject-path: 'packages/google-adk-agents/dist/*'
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
name: 'Get PyPI token'
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
password: ${{ env.PYPI_AUTH_TOKEN }}
packages-dir: packages/google-adk-agents/dist/

release-vercel-agents:
runs-on: ubuntu-latest
needs: ['release-please']
Expand Down
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"packages/vercel-messages": "0.1.0",
"packages/vercel-agents": "0.1.0",
"packages/litellm-messages": "0.1.0",
"packages/litellm-agents": "0.1.0"
"packages/litellm-agents": "0.1.0",
"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 @@ -115,6 +115,19 @@
"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" }
}
},
"python-ai-vercel-messages": {
"name": "Vercel Messages AI SDK for Python",
"type": "ai-provider",
Expand Down
10 changes: 7 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ graph TD
opencode["launchdarkly-ai-opencode-agents"]
vercel["launchdarkly-ai-vercel-agents"]
litellm["launchdarkly-ai-litellm-agents"]
googleAdk["launchdarkly-ai-google-adk-agents"]
newHandler["launchdarkly-ai-new-provider\n(future)"]
end
subgraph tier0 ["Tier 0 — Core"]
Expand All @@ -113,13 +114,15 @@ graph TD
app --> openai
app --> langchain
app --> opencode
app --> googleAdk
app --> newHandler
app --> ai
claude --> client
openai --> client
langchain --> client
opencode --> client
vercel --> client
googleAdk --> client
newHandler --> client
ai --> client
```
Expand All @@ -128,7 +131,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`, `launchdarkly-ai-litellm-agents`, `launchdarkly-ai-litellm-messages`, `launchdarkly-ai-opencode-agents`, `launchdarkly-ai-vercel-agents`, `launchdarkly-ai-vercel-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. The OpenCode handler reduces caller-supplied session events and does not depend on an OpenCode SDK.
- **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-litellm-agents`, `launchdarkly-ai-litellm-messages`, `launchdarkly-ai-opencode-agents`, `launchdarkly-ai-vercel-agents`, `launchdarkly-ai-vercel-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. The OpenCode handler reduces caller-supplied session events and does not depend on an OpenCode SDK.
- **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 Expand Up @@ -679,7 +682,7 @@ def my_provider(

For example, `claude_agents(config_key, user_input, context)` is equivalent to `config(key=config_key, handler=create_claude_agents_handler()).invoke(user_input, context)`.

The naming convention matches the package suffix: `claude_agents`, `claude_messages`, `openai_agents`, `openai_messages`, `langchain_agents`, `langchain_messages`, `litellm_agents`, `litellm_messages`, `vercel_agents`, `vercel_messages`.
The naming convention matches the package suffix: `claude_agents`, `claude_messages`, `openai_agents`, `openai_messages`, `langchain_agents`, `langchain_messages`, `litellm_agents`, `litellm_messages`, `vercel_agents`, `vercel_messages`, `google_adk_agents`.

### Graph Export (optional)

Expand All @@ -690,7 +693,7 @@ def claude_graph(key: str, **options) -> GraphInstance:
return graph(key, handlers=[create_claude_agents_handler()], **options)
```

Naming convention: `claude_graph`, `openai_graph`, `langchain_graph`, `litellm_graph`, `vercel_graph`.
Naming convention: `claude_graph`, `openai_graph`, `langchain_graph`, `litellm_graph`, `vercel_graph`, `google_adk_graph`.

### Native Graph Adapter (optional)

Expand All @@ -702,6 +705,7 @@ Current adapters:
- `to_lang_graph(def_coro, opts)` — exported from `launchdarkly_ai_langchain_agents`
- `to_litellm_agents(def_coro, opts)` — exported from `launchdarkly_ai_litellm_agents`
- `to_vercel_agents(def_coro, opts)` — exported from `launchdarkly_ai_vercel_agents`
- `to_adk_agents(def_coro, opts)` — exported from `launchdarkly_ai_google_adk_agents`

---

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Tier 0 — Core Client (launchdarkly-ai-server)
| [`launchdarkly-ai-litellm-agents`](packages/litellm-agents/README.md) | `*` (any) | `agent` | OpenAI Agents SDK with LiteLLM models |
| [`launchdarkly-ai-vercel-messages`](packages/vercel-messages/README.md) | `*` (any) | `messages` | Vercel AI SDK with AI Gateway routing |
| [`launchdarkly-ai-vercel-agents`](packages/vercel-agents/README.md) | `*` (any) | `agent` | Native Vercel `ai.Agent` loop and graph adapter |
| [`launchdarkly-ai-google-adk-agents`](packages/google-adk-agents/README.md) | Google | `agent` | Google ADK agent loop and graph adapter |

## Quick Start

Expand Down Expand Up @@ -160,6 +161,7 @@ asyncio.run(main())
| `litellm_agents` | `launchdarkly-ai-litellm-agents` | `openai-agents[litellm]` | OpenAI Agents via LiteLLM |
| `vercel_messages` | `launchdarkly-ai-vercel-messages` | `ai` | Vercel AI SDK stream runtime |
| `vercel_agents` | `launchdarkly-ai-vercel-agents` | `ai` | Native Vercel `ai.Agent` |
| `google_adk_agents` | `launchdarkly-ai-google-adk-agents` | `google-adk` | Google ADK agent loop |

---

Expand Down Expand Up @@ -631,6 +633,7 @@ uv run python main.py [example] [flag-key] [user-input]
| `vercel-messages` | `uv run python main.py vercel-messages` | Vercel AI SDK messages handler via AI Gateway |
| `vercel-direct` | `uv run python main.py vercel-direct` | Vercel messages handler with a constructed OpenAI model (no Gateway) |
| `native-graph-vercel` | `uv run python main.py native-graph-vercel` | Framework-native Vercel `ai.Agent` graph runner |
| `google-adk-agents` | `uv run python main.py google-adk-agents` | Google ADK agent handler |

**Examples:**

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 @@ -18,6 +18,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 vercel-messages launch-darkly-documentation-summarizer-messages "What is the LaunchDarkly AI SDK?"
python main.py vercel-direct launch-darkly-documentation-summarizer-messages-openai "What is the LaunchDarkly AI SDK?"
Expand Down Expand Up @@ -63,6 +64,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",
"litellm": "examples.litellm_example",
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,25 @@
"""LaunchDarkly AI SDK integration for Google ADK agents.

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

from launchdarkly_ai_server import register_ai_sdk_package

from ._version import PACKAGE_NAME, __version__
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(PACKAGE_NAME, __version__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""This package's identity, as sent with ``$ld:ai:sdk:info`` and ``$ld:ai:sdk:usage``."""

PACKAGE_NAME = "launchdarkly-ai-google-adk-agents"
__version__ = "0.1.0" # x-release-please-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Graph convenience wrapper for the Google ADK agents handler."""

from __future__ import annotations

from typing import Any

from launchdarkly_ai_server import _graph, report_usage

from ._version import PACKAGE_NAME, __version__
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 | None = None,
**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()``.
"""
report_usage("google-adk-agents.googleAdkGraph", PACKAGE_NAME, __version__)
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,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graph wrapper drops API key

Medium Severity

google_adk_graph forwards Vertex and model options to the handler factory but never takes api_key. A caller who passes api_key sends it to _graph, which only accepts handlers, tool_handlers, registry, and graph_judge, so the call raises TypeError instead of authenticating Gemini.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0f347aa. Configure here.

Loading
Loading