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
14 changes: 14 additions & 0 deletions MIGRATION_A365.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ pip uninstall -y microsoft-agents-a365-observability-extensions-agent-framework
pip install microsoft-opentelemetry
```

> If you use the hosting middleware (`BaggageMiddleware`,
> `ObservabilityHostingManager`, etc.), install the `hosting` extra,
> which pulls in `microsoft-agents-activity` and
> `microsoft-agents-hosting-core`:
>
> ```bash
> pip install "microsoft-opentelemetry[hosting]"
> ```
>
> If those packages are not installed, importing from
> `microsoft.opentelemetry.a365.hosting` logs an error with the install
> command but does not crash; the middleware will fail at runtime when
> invoked.

## Step 2 — Rewrite Import Paths

The old packages used `microsoft_agents_a365.*` namespace.
Expand Down
2 changes: 2 additions & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ pytest>=8.0
pytest-asyncio>=0.23.0
pytest-cov>=5.0
black>=24.0
microsoft-agents-activity
microsoft-agents-hosting-core
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ dependencies = [
"opentelemetry-resource-detector-azure<1.0.0,>=0.1.5",
"wrapt>=1.0",
"opentelemetry-util-genai==0.3b0",
"microsoft-agents-activity>=0.9.0",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Add [project.optional-dependencies] extras group

The PR description mentions moving microsoft-agents-activity and microsoft-agents-hosting-core into an optional
extra, but the diff shows no [project.optional-dependencies] section in pyproject.toml. The deps are removed from
core dependencies and added to dev_requirements.txt, which only helps developers/CI — end users have no standard way
to discover or install the hosting dependencies.

Suggestion: Add an extras group so users can do pip install microsoft-opentelemetry[hosting]:

[project.optional-dependencies]
hosting = [
"microsoft-agents-activity>=0.9.0",
"microsoft-agents-hosting-core>=0.9.0",
]

This follows the standard Python packaging convention for optional feature groups and makes the install path
discoverable via PyPI metadata. The dev_requirements.txt entry can remain for CI, or be replaced with pip install -e
.[hosting] in the dev setup.

Without this, users must rely on runtime error messages to discover which packages to install manually.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@nikhilNava Your comment has been addressed. PTAL when you have a moment. Thanks!

"microsoft-agents-hosting-core>=0.9.0",
"aiohttp>=3.8.0",
"PyJWT",
"requests"
Expand All @@ -59,6 +57,10 @@ agent-framework = [
openai-agents = [
"openai-agents>=0.0.7",
]
hosting = [
"microsoft-agents-activity>=0.9.0",
"microsoft-agents-hosting-core>=0.9.0",
]
test = [
"pytest>=8.0",
"pytest-cov>=5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@

from __future__ import annotations

import logging
from collections.abc import Awaitable, Callable

from microsoft_agents.activity import ActivityEventNames, ActivityTypes
from microsoft_agents.hosting.core.turn_context import TurnContext
try:
from microsoft_agents.activity import ActivityEventNames, ActivityTypes
from microsoft_agents.hosting.core.turn_context import TurnContext
except ImportError:
logging.getLogger(__name__).error(
"microsoft.opentelemetry.a365.hosting requires the agents SDK. Install the "
"packages with `pip install microsoft-opentelemetry[hosting]`.",
)

from microsoft.opentelemetry.a365.core.middleware.baggage_builder import BaggageBuilder

from microsoft.opentelemetry.a365.hosting.scope_helpers.populate_baggage import populate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import logging
from dataclasses import dataclass

from microsoft_agents.hosting.core.middleware_set import MiddlewareSet
try:
from microsoft_agents.hosting.core.middleware_set import MiddlewareSet
except ImportError:
logging.getLogger(__name__).error(
"microsoft.opentelemetry.a365.hosting requires the agents SDK. Install the "
"packages with `pip install microsoft-opentelemetry[hosting]`.",
)

from microsoft.opentelemetry.a365.hosting.middleware.baggage_middleware import BaggageMiddleware
from microsoft.opentelemetry.a365.hosting.middleware.output_logging_middleware import OutputLoggingMiddleware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
import logging
from collections.abc import Awaitable, Callable

from microsoft_agents.activity import Activity
from microsoft_agents.hosting.core.turn_context import TurnContext
try:
from microsoft_agents.activity import Activity
from microsoft_agents.hosting.core.turn_context import TurnContext
except ImportError:
logging.getLogger(__name__).error(
"microsoft.opentelemetry.a365.hosting requires the agents SDK. Install the "
"packages with `pip install microsoft-opentelemetry[hosting]`.",
)

from microsoft.opentelemetry.a365.core.agent_details import AgentDetails
from microsoft.opentelemetry.a365.constants import (
CHANNEL_LINK_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@

from __future__ import annotations

import logging
from collections.abc import Iterator
from typing import Any

from microsoft_agents.hosting.core.turn_context import TurnContext
try:
from microsoft_agents.hosting.core.turn_context import TurnContext
except ImportError:
logging.getLogger(__name__).error(
"microsoft.opentelemetry.a365.hosting requires the agents SDK. Install the "
"packages with `pip install microsoft-opentelemetry[hosting]`.",
)

from microsoft.opentelemetry.a365.core.middleware.baggage_builder import BaggageBuilder

from microsoft.opentelemetry.a365.hosting.scope_helpers.utils import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from __future__ import annotations

import logging
import json
from collections.abc import Iterator
from typing import Any

from microsoft_agents.activity import Activity
try:
from microsoft_agents.activity import Activity
except ImportError:
logging.getLogger(__name__).error(
"microsoft.opentelemetry.a365.hosting requires the agents SDK. Install the "
"packages with `pip install microsoft-opentelemetry[hosting]`.",
)

from microsoft.opentelemetry.a365.constants import (
CHANNEL_LINK_KEY,
CHANNEL_NAME_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
from dataclasses import dataclass
from threading import Lock

from microsoft_agents.hosting.core.app.oauth.authorization import Authorization
from microsoft_agents.hosting.core.turn_context import TurnContext
try:
from microsoft_agents.hosting.core.app.oauth.authorization import Authorization
from microsoft_agents.hosting.core.turn_context import TurnContext
except ImportError:
logging.getLogger(__name__).error(
"microsoft.opentelemetry.a365.hosting requires the agents SDK. Install the "
"packages with `pip install microsoft-opentelemetry[hosting]`.",
)

logger = logging.getLogger(__name__)

Expand Down
7 changes: 6 additions & 1 deletion tests/a365/hosting/middleware/test_baggage_middleware.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import pytest

pytest.importorskip("microsoft_agents.activity")
pytest.importorskip("microsoft_agents.hosting.core")

# pylint: disable=wrong-import-position
import json
from typing import Any
from unittest.mock import MagicMock

import pytest
from microsoft_agents.activity import (
Activity,
ActivityEventNames,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import pytest

pytest.importorskip("microsoft_agents.activity")
pytest.importorskip("microsoft_agents.hosting.core")

# pylint: disable=wrong-import-position
from unittest.mock import MagicMock

import pytest
from microsoft.opentelemetry.a365.hosting.middleware.baggage_middleware import (
BaggageMiddleware,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import pytest

pytest.importorskip("microsoft_agents.activity")
pytest.importorskip("microsoft_agents.hosting.core")

# pylint: disable=wrong-import-position
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from microsoft_agents.activity import (
Activity,
ChannelAccount,
Expand Down
6 changes: 6 additions & 0 deletions tests/a365/hosting/scope_helpers/test_populate_baggage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import pytest

pytest.importorskip("microsoft_agents.activity")
pytest.importorskip("microsoft_agents.hosting.core")

# pylint: disable=wrong-import-position
from unittest.mock import MagicMock

from microsoft_agents.activity import Activity, ChannelAccount, ConversationAccount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import pytest

pytest.importorskip("microsoft_agents.activity")
pytest.importorskip("microsoft_agents.hosting.core")

# pylint: disable=wrong-import-position
import os
from unittest.mock import MagicMock

import pytest
from microsoft_agents.activity import Activity, ChannelAccount, ConversationAccount
from microsoft_agents.hosting.core import TurnContext
from microsoft.opentelemetry.a365.core.agent_details import AgentDetails
Expand Down
5 changes: 5 additions & 0 deletions tests/a365/hosting/scope_helpers/test_scope_helper_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import pytest

pytest.importorskip("microsoft_agents.activity")

# pylint: disable=wrong-import-position
from microsoft_agents.activity import Activity, ChannelAccount, ConversationAccount
from microsoft.opentelemetry.a365.core.constants import (
CHANNEL_LINK_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

"""Tests for AgenticTokenCache and AgenticTokenStruct."""

import pytest

pytest.importorskip("microsoft_agents.hosting.core")

# pylint: disable=wrong-import-position
import threading
from unittest.mock import AsyncMock, MagicMock

import pytest
from microsoft_agents.hosting.core.app.oauth.authorization import Authorization
from microsoft_agents.hosting.core.turn_context import TurnContext
from microsoft.opentelemetry.a365.hosting.token_cache_helpers import (
Expand Down
Loading