Python: Add approval storage and improve truth checks - #7631
Conversation
There was a problem hiding this comment.
Pull request overview
Adds session-bound approval storage and strict boolean authorization to prevent forged, replayed, or malformed approvals.
Changes:
- Rebinds approval responses to stored request snapshots.
- Requires literal
Trueacross core, declarative, and AG-UI paths. - Adds regression tests and updates type-checker dependencies.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
python/uv.lock |
Updates Pyrefly and Zuban. |
python/packages/declarative/tests/test_function_tool_executor.py |
Tests approval validation. |
python/packages/declarative/tests/test_declarative_approval_binding.py |
Tests malformed decisions. |
python/packages/declarative/agent_framework_declarative/_workflows/_executors_tools.py |
Enforces strict approvals. |
python/packages/declarative/agent_framework_declarative/_workflows/_executors_mcp.py |
Hardens MCP approvals. |
python/packages/core/tests/core/test_types.py |
Tests safe deserialization. |
python/packages/core/tests/core/test_harness_tool_approval.py |
Tests forged standing approvals. |
python/packages/core/tests/core/test_function_invocation_logic.py |
Tests binding and replay protection. |
python/packages/core/agent_framework/_types.py |
Normalizes malformed decisions. |
python/packages/core/agent_framework/_tools.py |
Stores and binds pending approvals. |
python/packages/core/agent_framework/_harness/_tool_approval.py |
Integrates binding with middleware. |
python/packages/ag-ui/tests/ag_ui/test_run.py |
Tests canonical decisions. |
python/packages/ag-ui/tests/ag_ui/test_message_adapters.py |
Tests adapter validation. |
python/packages/ag-ui/tests/ag_ui/test_approval_result_event.py |
Tests malformed rejection handling. |
python/packages/ag-ui/agent_framework_ag_ui/_message_adapters.py |
Applies strict truth checks. |
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py |
Makes pending entries immutable and validated. |
docs/specs/004-python-function-calling-loop.md |
Documents approval guarantees. |
💡 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: Findings reported
Scope: full PR (1 commit(s)): 0ae9dea73012
Model: gpt-5.6-sol
Overview
The PR strengthens local approval handling by snapshotting pending requests, rebinding responses to server-held call data, consuming approvals once, and requiring strict boolean decisions across core, AG-UI, and declarative paths. The new tests cover substitution, replay, malformed decisions, and forged history well. Residual risk remains because snapshot identity is based only on provider request IDs, is not tied to the tool registry that originated it, and grows for abandoned session approvals without a lifecycle bound.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
3 verified findings remained after source verification (2 high, 1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/_tools.py
|
westey (@westey-m) there are a couple of merge conflicts. |
Thanks Evan Mattson (@moonbox3), I've resolved the conflicts |
Motivation & Context
Description & Review Guide
Related Issue
Fixes #
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.