Skip to content

Add token_provider argument#123

Open
KavyaSree2610 wants to merge 3 commits intomainfrom
kkaitepalli/azure-ad-token
Open

Add token_provider argument#123
KavyaSree2610 wants to merge 3 commits intomainfrom
kkaitepalli/azure-ad-token

Conversation

@KavyaSree2610
Copy link
Collaborator

@KavyaSree2610 KavyaSree2610 commented Mar 27, 2026

This PR adds support for Azure AD token-based authentication via a token_provider that can be passed through bots into the OpenAI/Anthropic SDK clients, and extends the browsing toolchain to accept Azure AD tokens at runtime.

Changes:

  • Add token_provider plumbing from MicroBot (and sub-agents) into OpenAIApi/AnthropicApi client construction.
  • Add Azure AD token injection support for the browser tool (Docker) and update its LLM initialization to accept an AD token.
  • Add/extend unit tests and introduce authentication documentation.

@codecov-commenter
Copy link

codecov-commenter commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.38%. Comparing base (973bb5d) to head (f7898f5).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   96.22%   96.38%   +0.15%     
==========================================
  Files          28       28              
  Lines        1219     1245      +26     
==========================================
+ Hits         1173     1200      +27     
+ Misses         46       45       -1     
Flag Coverage Δ
integration 60.16% <67.56%> (+0.43%) ⬆️
ollama_local 55.98% <45.94%> (+0.03%) ⬆️
slow-browser 45.62% <64.86%> (+0.25%) ⬆️
slow-other 66.90% <56.75%> (-0.61%) ⬇️
unit 85.38% <100.00%> (+1.54%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/microbots/MicroBot.py 100.00% <100.00%> (ø)
src/microbots/bot/BrowsingBot.py 100.00% <100.00%> (+5.00%) ⬆️
src/microbots/bot/LogAnalysisBot.py 100.00% <ø> (ø)
src/microbots/bot/ReadingBot.py 100.00% <ø> (ø)
src/microbots/bot/WritingBot.py 100.00% <ø> (ø)
src/microbots/llm/anthropic_api.py 100.00% <100.00%> (ø)
src/microbots/llm/openai_api.py 100.00% <100.00%> (ø)
...obots/tools/tool_definitions/microbot_sub_agent.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

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 support for Azure AD token-based authentication via a token_provider that can be passed through bots into the OpenAI/Anthropic SDK clients, and extends the browsing toolchain to accept Azure AD tokens at runtime.

Changes:

  • Add token_provider plumbing from MicroBot (and sub-agents) into OpenAIApi/AnthropicApi client construction.
  • Add Azure AD token injection support for the browser tool (Docker) and update its LLM initialization to accept an AD token.
  • Add/extend unit tests and introduce authentication documentation.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
test/tools/tool_definitions/test_microbot_sub_agent.py Updates test bot factory to include token_provider.
test/llm/test_openai_api.py Adds init tests for missing auth and token-provider Azure client creation.
test/llm/test_anthropic_api.py Adds init tests for missing auth and token-provider Foundry client creation.
test/bot/test_microbot.py Adds tests for explicit and env-driven token provider behavior.
test/bot/test_browsing_bot.py Adds unit tests for token injection + safer shell quoting.
src/microbots/tools/tool_definitions/microbot_sub_agent.py Passes token_provider to sub-bot creation.
src/microbots/tools/tool_definitions/browser-use/browser.py Builds ChatAzureOpenAI with optional azure_ad_token.
src/microbots/tools/tool_definitions/browser-use.yaml Documents optional API key and runtime token injection.
src/microbots/llm/openai_api.py Adds token_provider option and AzureOpenAI client support.
src/microbots/llm/anthropic_api.py Adds token_provider option and AnthropicFoundry client support.
src/microbots/bot/WritingBot.py Adds token_provider passthrough.
src/microbots/bot/ReadingBot.py Adds token_provider passthrough.
src/microbots/bot/LogAnalysisBot.py Adds token_provider passthrough.
src/microbots/bot/BrowsingBot.py Adds token_provider, safer quoting, and token export before browser run.
src/microbots/MicroBot.py Adds env-driven token provider auto-creation and passes it into LLMs.
requirements.txt Adds azure-identity dependency.
docs/authentication.md Adds auth documentation for API keys vs Azure AD token auth.

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

@KavyaSree2610 KavyaSree2610 marked this pull request as ready for review March 27, 2026 16:42
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.

3 participants