openclaw - ✅(Solved) Fix msteams: add OpenClaw User-Agent header to Microsoft backend HTTP calls [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#51568Fetched 2026-04-08 01:09:32
View on GitHub
Comments
1
Participants
2
Timeline
15
Reactions
0
Author
Participants
Timeline (top)
referenced ×8cross-referenced ×3closed ×1commented ×1

Fix Action

Fixed

PR fix notes

PR #51570: Add OpenClaw User-Agent header to all outbound HTTP requests

Description (problem / solution / changelog)

Summary

  • Problem: Outbound HTTP requests to Microsoft Graph and Teams APIs lack identifying User-Agent headers, making it difficult to track OpenClaw usage and debug integration issues.
  • Why it matters: User-Agent headers are standard HTTP practice for identifying clients; they enable better observability, debugging, and usage tracking across Microsoft services.
  • What changed:
    • Added buildUserAgent() function that constructs OpenClaw/<version> headers from the MSTeams runtime
    • Injected User-Agent headers into all Graph API calls (graph.ts, graph-upload.ts, attachments/graph.ts)
    • Injected User-Agent headers into file consent uploads (file-consent.ts)
    • Extended CloudAdapter subclass to inject User-Agent into all ConnectorClient instances (both inbound webhook replies and proactive messages)
    • Added comprehensive unit tests for User-Agent generation and header injection
  • What did NOT change: No changes to authentication, token handling, or API contracts; User-Agent is purely informational.

Closes #51568

Change Type

  • Feature
  • Refactor required for the fix

Scope

  • Integrations
  • API / contracts

Linked Issue/PR

  • Closes (if applicable, update with actual issue number)

User-visible / Behavior Changes

None. User-Agent headers are transparent to end users; they only appear in HTTP request metadata visible to Microsoft services and network logs.

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No (same calls, just with additional header)
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • N/A (header injection is transparent)

Steps

  1. Run unit tests: npm test -- user-agent.test.ts graph.user-agent.test.ts
  2. Verify tests pass and User-Agent header is correctly formatted as OpenClaw/<version>
  3. Verify caller-provided User-Agent headers can override the default (tested in graph.user-agent.test.ts)

Expected

  • buildUserAgent() returns OpenClaw/2026.3.19 (or current runtime version)
  • All Graph API calls include User-Agent: OpenClaw/<version> header
  • All ConnectorClient instances created by CloudAdapter include the User-Agent header
  • Custom User-Agent headers from callers are respected and not overridden

Actual

  • All tests pass
  • User-Agent header is consistently injected across all outbound requests
  • Fallback to OpenClaw/unknown when runtime is not initialized

Evidence

  • Failing test/log before + passing after
    • Added user-agent.test.ts with 3 test cases covering normal operation, version reflection, and error handling
    • Added graph.user-agent.test.ts with 2 test cases covering default User-Agent injection and caller override behavior
    • All tests pass with the implementation

Human Verification

  • Verified scenarios:

    • User-Agent header is correctly formatted as OpenClaw/<version>
    • Header is injected into Graph API calls (GET, POST, PUT)
    • Header is injected into ConnectorClient creation for both inbound and proactive messages
    • Caller-provided headers override the default User-Agent
    • Runtime initialization errors gracefully fall back to unknown version
  • Edge cases checked:

    • MSTeams runtime not initialized (throws error → fallback to unknown)
    • Custom User-Agent headers from callers are preserved
    • Header propagation works with both createConnectorClient and createConnectorClientWithIdentity
  • What you did NOT verify:

    • End-to-end integration with actual Microsoft Teams/Graph services (covered by existing integration tests)
    • Performance impact (negligible—single string concatenation)

Compatibility / Migration

  • Backward compatible? Yes (purely additive; no breaking changes)
  • Config/env changes? No
  • Migration

https://claude.ai/code/session_019xsguY8tjCjHwwvUu8zxjj

Changed files

  • extensions/msteams/src/attachments/graph.ts (modified, +4/-2)
  • extensions/msteams/src/file-consent.ts (modified, +3/-0)
  • extensions/msteams/src/graph-upload.ts (modified, +7/-2)
  • extensions/msteams/src/graph.ts (modified, +2/-0)
  • extensions/msteams/src/graph.user-agent.test.ts (added, +50/-0)
  • extensions/msteams/src/sdk.ts (modified, +33/-1)
  • extensions/msteams/src/user-agent.test.ts (added, +39/-0)
  • extensions/msteams/src/user-agent.ts (added, +15/-0)
RAW_BUFFERClick to expand / collapse

The Teams plugin doesn't currently identify itself in outbound HTTP requests to Microsoft services. Adding an OpenClaw/<version> User-Agent header lets Microsoft attribute API traffic to OpenClaw, giving visibility into overall usage across their platform.

Scope: All outbound HTTP calls from the Teams plugin:

  • Graph API calls (fetch, upload, attachments)
  • Bot Framework SDK connector client (webhook replies + proactive messages)
  • File consent uploads

Version sourced from PluginRuntime.version.

extent analysis

Fix Plan

To add the OpenClaw/<version> User-Agent header to outbound HTTP requests, follow these steps:

  • Identify the version from PluginRuntime.version.
  • Modify the HTTP client to include the User-Agent header in requests.
  • Implement the change for all outbound HTTP calls:
    • Graph API calls
    • Bot Framework SDK connector client
    • File consent uploads

Example Code

import requests

# Get the version from PluginRuntime
version = PluginRuntime.version

# Define the User-Agent header
user_agent = f"OpenClaw/{version}"

# Example for Graph API calls
def fetch_graph_api(url):
    headers = {"User-Agent": user_agent}
    response = requests.get(url, headers=headers)
    return response

# Example for Bot Framework SDK connector client
def send_webhook_reply(url, data):
    headers = {"User-Agent": user_agent}
    response = requests.post(url, json=data, headers=headers)
    return response

# Example for file consent uploads
def upload_file(url, file):
    headers = {"User-Agent": user_agent}
    response = requests.post(url, files={"file": file}, headers=headers)
    return response

Verification

To verify the fix, inspect the HTTP requests sent by the Teams plugin using tools like Wireshark or the browser's developer tools. The OpenClaw/<version> User-Agent header should be present in all outbound HTTP requests.

Extra Tips

  • Ensure the PluginRuntime.version is correctly updated and reflected in the User-Agent header.
  • Consider logging the User-Agent header for debugging and monitoring purposes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING