Skip to content

Feat: Configurable Client Labels in adk-js#454

Open
AmaadMartin wants to merge 6 commits into
google:mainfrom
AmaadMartin:feat/configurable-client-labels
Open

Feat: Configurable Client Labels in adk-js#454
AmaadMartin wants to merge 6 commits into
google:mainfrom
AmaadMartin:feat/configurable-client-labels

Conversation

@AmaadMartin

Copy link
Copy Markdown
Collaborator

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

  • Related: # (No specific issue link provided, parity feature with adk-python)

2. Or, if no issue exists, describe the change:

Problem:
Developers need to be able to configure custom client labels dynamically for HTTP requests made by the ADK JS library for tracking, debugging, and evaluation (parity with adk-python). We also need to extract cleaner browser info from User Agent strings instead of sending full raw UA.

Solution:

  • Implemented runWithClientLabel and updated getClientLabels to support context-propagated labels using AsyncLocalStorage in Node.js.
  • Provided a browser-safe shim for AsyncLocalStorage in core/src/utils/async_hooks_shim.ts.
  • Configured esbuild in core/build.js to alias node:async_hooks to the shim when building for browser platform with bundle option.
  • Implemented parseUserAgent in core/src/utils/client_labels.ts to extract Browser/Version from UA.
  • Exported new utilities in core/src/common.ts.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary of passed npm test results:

 RUN  v3.2.6 /usr/local/google/home/amaadmartin/Workspace/Agentspaces/feat-configurable-client-labels/adk-js

 Test Files  2 passed (2)
      Tests  24 passed (24)
   Start at  15:45:00
   Duration  10.32s

Passed tests include:

  • client_labels tests (17 tests) covering default labels, UA parsing, context propagation, and error cases for empty labels.
  • BaseLlm tests (7 tests) including a new test verifying that context client label is included in tracking headers when run within runWithClientLabel.

Manual End-to-End (E2E) Tests:

  • I have manually tested my changes end-to-end.
    Verified via integration tests that BaseLlm correctly retrieves and includes the context-propagated client label in HTTP headers (x-goog-api-client and user-agent) when executed within runWithClientLabel.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

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.

1 participant