Python: [BREAKING] restore agent middleware API contract - #7918
Conversation
Remove the agent-hooks extra from the core package and restore sequence-only middleware inputs for agents and the harness.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Restores sequence-only agent middleware APIs and removes the experimental agent-hooks package extra.
Changes:
- Restricts agent middleware parameters to sequences.
- Adds runtime rejection tests for singular middleware.
- Requires direct installation of
agent-hooks-sdk.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
python/uv.lock |
Removes the agent-hooks extra. |
python/pyproject.toml |
Clarifies the SDK test dependency. |
python/packages/core/pyproject.toml |
Removes core’s agent-hooks extra. |
python/packages/core/agent_framework/_agents.py |
Restores sequence-only agent signatures. |
python/packages/core/agent_framework/_middleware.py |
Adjusts middleware runtime handling. |
python/packages/core/agent_framework/observability.py |
Aligns telemetry-layer signatures. |
python/packages/core/agent_framework/_harness/_agent.py |
Restricts harness middleware input. |
python/packages/core/agent_framework/_harness/_agent.pyi |
Updates harness typing. |
python/packages/core/agent_framework/_agent_hooks.py |
Updates SDK installation guidance. |
python/packages/core/tests/core/test_middleware_with_agent.py |
Tests singular-input rejection. |
python/packages/core/tests/core/test_harness_agent.py |
Tests harness rejection behavior. |
python/packages/core/tests/core/test_agent_hooks.py |
Uses bundles within sequences. |
python/PACKAGE_STATUS.md |
Documents direct SDK installation. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 612069f25526
Model: gpt-5.6-sol
Overview
The PR consistently restores sequence-only middleware annotations and removes the experimental core package extra while retaining agent-hooks bundles as sequence elements. The new tests cover ordinary singular-value rejection and valid sequence execution across direct agent and harness paths, and the packaging metadata remains internally consistent. Review identified contract-enforcement and public-factory gaps, but each is already covered by unresolved review feedback, so there are no additional publishable findings.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
…o-agent-hooks-api
Use one strict sequence validator across agent entry points and align client and Foundry factory signatures with the runtime contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ac1d6000-fc1a-4891-95f4-8d77d4420e31
Motivation & Context
The agent-hooks integration introduced two unrelated changes to the core package surface: an
agent-framework-core[agent-hooks]extra and support for singular middleware values on agents andcreate_harness_agent. The singular form conflicts with the sequence-only API decision recorded in #2902, and the experimental integration should not add a core package extra.Description & Review Guide
agent-hooksextra from core package metadata and directs users to installagent-hooks-sdkseparately. Restores sequence-only middleware inputs acrossBaseAgent,RawAgent,Agent, the inherited middleware and telemetry layers, andcreate_harness_agent, including runtime rejection of singular values. Agent-hooks bundles remain supported as elements of a middleware sequence.allextra and that sequence-only enforcement remains consistent across constructor, per-run, attribute, and harness paths.Related Issue
Fixes #7917
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.