microsoft / microsoft/Agent365-python

Fix broken links in AgentNotification Class docs by improving code

Đang mở
#237 0 bình luận 1 reaction 2 người được giao Xem trên GitHub

@JimDaly đang làm issue này rồi.

Từ ngày 24/4/2026.

  • #238 của @copilot-swe-agent — đã đóng, không merge
Ngôn ngữ chính
Python
Star
41
Fork
23
Merge trung bình
7 giờ 43 phút
Pull request đã merge (30 ngày)
3

Mô tả

Looking at this generated documentation: https://learn.microsoft.com/en-us/python/api/microsoft-agents-a365-notifications/microsoft_agents_a365.notifications.agentnotification?view=agent365-sdk-python-latest

There are several places where links to related classes are broken. For example, the return type data for the on_email method should contain links to the types. But actually, the type value looks like this:

Callable[[Callable[[xref:microsoft_agents_a365.notifications.agent_notification.TContext, xref:microsoft_agents_a365.notifications.agent_notification.TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]

These docs are generated using DocFx, and I have reason to believe that the docs would generated correctly in the code was written differently. The following is the analysis I got:


The root cause is a code issue, not a doc generator bug. Here's what's happening:

The problem chain:

AgentHandler (line 43) is defined as a generic type alias using two TypeVars:

TContext = TypeVar("TContext", bound=TurnContext)
TState = TypeVar("TState", bound=TurnState)
AgentHandler = Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]
When on_email's return type references AgentHandler, the doc generator correctly expands it to its full form — and that expansion contains TContext and TState. Those are TypeVars, not concrete classes, so DocFx can't resolve them as cross-references. The warning is accurate.

Why this is a code problem:

The on_email method (and all the on_* convenience methods) don't actually need generic TypeVars in their signatures. They always deal with concrete TurnContext and TurnState. Using AgentHandler here is conceptually imprecise — it implies the caller could pass a handler typed to a subclass of TurnContext, but the route handler returned is always typed to the concrete base types.

The fix:

Replace AgentHandler in the return types of all on_* methods with an inline version using the concrete bound types. In agent_notification.py:225, change from:

-> Callable[[AgentHandler], Callable[[TurnContext, TurnState], Awaitable[None]]]:
...to:

-> Callable[[Callable[[TurnContext, TurnState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]:
This substitutes TContext → TurnContext and TState → TurnState (their declared bounds), which are real importable classes that DocFx can cross-reference. The same change applies to on_word, on_excel, on_powerpoint, on_lifecycle, on_user_created, on_user_workload_onboarding, and on_user_deleted.

Note that AgentHandler itself can stay as-is — it's legitimately generic for use in user code where someone might subclass TurnContext. The issue is only in the return type annotations of the decorator methods.


Please consider applying these changes for a better implementation that will allow the docs to be generated in a clean way.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.