Skip to content

Python: Update docs for middleware layering refactor and Anthropic client split#4801

Closed
LEDazzio01 wants to merge 1 commit intomicrosoft:mainfrom
LEDazzio01:docs/update-middleware-layering-docs
Closed

Python: Update docs for middleware layering refactor and Anthropic client split#4801
LEDazzio01 wants to merge 1 commit intomicrosoft:mainfrom
LEDazzio01:docs/update-middleware-layering-docs

Conversation

@LEDazzio01
Copy link
Contributor

Motivation and Context

Fixes #4789.

PR #4746 refactored the middleware layering in the Python SDK and split the Anthropic client into raw/public variants. This PR updates documentation artifacts to reflect those changes.

Description

python/packages/anthropic/AGENTS.md

  • Added RawAnthropicClient to the main classes listing
  • Added a "Client Architecture" section with an ASCII diagram showing the standard layer stack
  • Updated import path examples to include RawAnthropicClient

python/packages/core/AGENTS.md

  • Added a "Chat Client Layer Architecture" section documenting:
    • The standard layer ordering: FunctionInvocationLayer → ChatMiddlewareLayer → ChatTelemetryLayer → Raw/BaseChatClient
    • Key behaviors: chat middleware runs per inner model call (inside the function loop), chat middleware stays outside telemetry, per-call middleware routing via client_kwargs={"middleware": [...]}
    • The Raw vs Public client pattern that providers follow

Docs confirmed unchanged (no stale references found)

  • docs/decisions/0007-agent-filtering-middleware.md — C#-focused ADR, no Python layer ordering references
  • docs/decisions/0016-python-context-middleware.md — About context providers/hooks, no middleware layer references
  • python/AGENTS.md — General index, no middleware-specific content
  • No function_middleware references found in any markdown documentation

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? No — documentation only

Copilot AI review requested due to automatic review settings March 19, 2026 21:58
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Mar 19, 2026
…GENTS.md

Fixes microsoft#4789

- Update python/packages/anthropic/AGENTS.md to document RawAnthropicClient
  and the layered client architecture
- Add Chat Client Layer Architecture section to python/packages/core/AGENTS.md
  explaining the standard layer ordering (FunctionInvocationLayer ->
  ChatMiddlewareLayer -> ChatTelemetryLayer -> Raw/Base), per-call middleware
  routing via client_kwargs, and raw vs public client pattern
@LEDazzio01 LEDazzio01 force-pushed the docs/update-middleware-layering-docs branch from f30d9ba to 36b514d Compare March 19, 2026 21:59
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

Updates Python package documentation to reflect the middleware layering refactor and (intended) Anthropic raw/public client split described in #4746 / #4789.

Changes:

  • Added a new “Chat Client Layer Architecture” section to python/packages/core/AGENTS.md describing the layer stack and per-call middleware routing.
  • Expanded python/packages/anthropic/AGENTS.md with a “Client Architecture” section and updated class/import listings to mention a raw client.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
python/packages/core/AGENTS.md Adds an architecture section documenting the chat client layer stack and per-call middleware routing.
python/packages/anthropic/AGENTS.md Updates Anthropic package docs to describe client architecture and add raw/public client references.

@LEDazzio01
Copy link
Contributor Author

Thanks for the thorough review, @copilot!

All 6 comments reference the same root cause: this docs PR intentionally documents the changes introduced by PR #4746

Specifically:

This PR was created to address issue #4789, which was filed as a follow-up docs task for PR #4746. It should be merged after #4746 lands.

I'll update the PR description to note this dependency explicitly.

@eavanvalkenburg
Copy link
Member

Appreciate the enthousiasm, but that issue was supposed to go to our docs repo, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Update docs for middleware layering refactor and Anthropic client split

4 participants