Skip to content

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

Description

@eavanvalkenburg

Summary

PR #4746 refactored the middleware layering in the Python SDK and split the Anthropic client into raw/public variants. Several documentation artifacts need to be updated to reflect these changes.

Changes from PR #4746 that require doc updates

  1. Middleware pipeline reordering — The public chat client stack is now FunctionInvocationLayer -> ChatMiddlewareLayer -> ChatTelemetryLayer -> Raw/Base client. Documentation describing the old middleware ordering needs to be updated.

  2. Chat middleware now runs per inner model call — Chat middleware executes for each inner model call in the function loop (outside telemetry so middleware latency does not skew per-call timings). Any docs describing middleware execution semantics should reflect this.

  3. Per-call middleware routing via client_kwargs["middleware"] — Mixed per-call middleware is now standardized on client_kwargs["middleware"]. References to the old function_middleware parameter in docs/docstrings should be removed.

  4. Anthropic raw/public client splitAnthropicClient is now split into RawAnthropicClient + public AnthropicClient, matching the pattern used by other providers. Provider documentation and any Anthropic-specific guides should be updated.

Docs to review and update

  • docs/decisions/0007-agent-filtering-middleware.md — ADR on middleware design; verify the described pipeline ordering and execution semantics still match.
  • docs/decisions/0016-python-context-middleware.md — ADR on context middleware; check for any stale references to old middleware layering.
  • python/AGENTS.md and relevant package-level AGENTS.md files — Ensure public API references (e.g., Anthropic client names, middleware parameters) are current.
  • Any other docs referencing function_middleware or the old pipeline ordering.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docspythonUsage: [Issues, PRs], Target: Python

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions