Skip to content

Add Anthropic GCP WIF support#6153

Merged
suhaibmujahid merged 1 commit into
mozilla:masterfrom
suhaibmujahid:wif-anthropic-auth
Jun 12, 2026
Merged

Add Anthropic GCP WIF support#6153
suhaibmujahid merged 1 commit into
mozilla:masterfrom
suhaibmujahid:wif-anthropic-auth

Conversation

@suhaibmujahid

Copy link
Copy Markdown
Member

Introduce GCP Workload Identity Federation support for Anthropic by adding an anthropic_wif module that fetches Google-signed OIDC identity tokens, writes them to a private file, and keeps them refreshed on a background thread (atomic writes, configurable refresh interval). Runtime now calls anthropic_wif.configure() before agent startup to wire token file into ANTHROPIC_IDENTITY_TOKEN_FILE; configure is a no-op when federation is not enabled or when ANTHROPIC_API_KEY is set.

Resolves #6150

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Google Cloud Workload Identity Federation (WIF) support for Anthropic authentication in hackbot-runtime, allowing long-running agents to authenticate without a static ANTHROPIC_API_KEY by continuously refreshing a Google-signed OIDC identity token on disk and pointing ANTHROPIC_IDENTITY_TOKEN_FILE at it.

Changes:

  • Add google-auth dependency to support fetching GCP identity tokens.
  • Introduce hackbot_runtime.anthropic_wif to fetch/write/refresh the identity token file on a background thread.
  • Invoke Anthropic WIF configuration during runtime startup (both sync and async entrypoints).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
libs/hackbot-runtime/pyproject.toml Adds google-auth dependency needed for GCP identity token retrieval.
libs/hackbot-runtime/hackbot_runtime/runtime.py Calls WIF configuration during startup to set ANTHROPIC_IDENTITY_TOKEN_FILE for downstream SDK/CLI usage.
libs/hackbot-runtime/hackbot_runtime/anthropic_wif.py Implements WIF enablement checks, identity token fetch, atomic file writes, and periodic refresh loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/hackbot-runtime/hackbot_runtime/runtime.py Outdated
Comment thread libs/hackbot-runtime/hackbot_runtime/runtime.py
Comment thread libs/hackbot-runtime/hackbot_runtime/runtime.py
Comment thread libs/hackbot-runtime/hackbot_runtime/anthropic_wif.py
Comment thread libs/hackbot-runtime/hackbot_runtime/anthropic_wif.py
Comment thread libs/hackbot-runtime/hackbot_runtime/anthropic_wif.py
Introduce GCP Workload Identity Federation support for Anthropic by adding an anthropic_wif module that fetches Google-signed OIDC identity tokens, writes them to a private file, and keeps them refreshed on a background thread (atomic writes, configurable refresh interval). Runtime now calls anthropic_wif.configure() before agent startup to wire token file into ANTHROPIC_IDENTITY_TOKEN_FILE; configure is a no-op when federation is not enabled or when ANTHROPIC_API_KEY is set. Also add google-auth to dependencies.
@suhaibmujahid suhaibmujahid marked this pull request as ready for review June 12, 2026 12:56
@suhaibmujahid suhaibmujahid requested a review from marco-c June 12, 2026 12:56
@suhaibmujahid suhaibmujahid enabled auto-merge (squash) June 12, 2026 13:05
@suhaibmujahid suhaibmujahid merged commit 57470da into mozilla:master Jun 12, 2026
6 checks passed
@suhaibmujahid suhaibmujahid deleted the wif-anthropic-auth branch June 12, 2026 17:21
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.

Use WIF for Anthropic API authentication when running Hackbot agents on GCP

3 participants