Skip to content

Python: Preserve FIDES AG-UI replay provenance - #9878

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 6 commits into
mainfrom
fides-agui-replay-provenance
Nov 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 6 commits into
mainfrom
fides-agui-replay-provenance

Conversation

@eavanvalkenburg

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Motivation & Context

FIDES security state can be restored from an AG-UI Thread Snapshot while the current turn adds a fresh client tool result or resolves an approval. Without transport provenance, normalization can either reclassify restored history as fresh external data or let fresh data inherit coverage from the stored snapshot. Confirmation and approval safe-point returns can also persist before FIDES folds new replay data.

This is the fourth layer of the upstream replacement stack for #9652. It builds on #9875, #9876, and #9877 and isolates AG-UI replay provenance, snapshot folding, and authenticated approval-result handling from the later MCP carrier layer.

This layer uses the core replay seams available in agent-framework-core 1.25.0, matching the current AG-UI dependency floor of agent-framework-core>=1.25.0,<2. Core now requires typing-extensions>=4.16.0 so the private replay Sentinel remains identity-stable when messages are copied.

Description & Review Guide

  • What are the major changes? AG-UI now privately marks only messages restored from the backend Thread Snapshot, preserves that origin through reasoning removal, tool-history sanitation, deduplication, and synthetic skipped results, and clears the transport marker before provider exposure. Replay coverage is scoped to each FIDES provider and remains available until every SecureAgentConfig consumes its own entry. A minimal FIDES replay seam treats covered messages as represented by restored state, folds uncovered messages before snapshot-only or approval safe-point saves, reconstructs complete local replay when the stored context label is missing, and rejects reconstruction when service-owned history is unavailable. Lifecycle-authenticated approvals, replacement approvals, and mixed siblings retain backend authority. Denial provenance binds to the exact synthesized result object, edited client calls lose snapshot provenance, and fresh client results remain conservative. Non-FIDES approval paths avoid the extra full transcript conversion.
  • What is the impact of these changes? Restored snapshots no longer gain unnecessary taint after normalization, fresh client tool results cannot inherit snapshot coverage, and confirmation or provider-failure paths persist the correct conservative FIDES label. Multiple security providers preserve their independent restored labels. Missing FIDES state fails closed for service-managed history rather than trusting an incomplete AG-UI snapshot. There are no public API or breaking changes.
  • What do you want reviewers to focus on? Please review the backend-snapshot identity boundary after reasoning normalization and deduplication, provider-scoped marker consumption, the ordering of FIDES folding before confirmation and approval safe-point saves, exact synthesized-denial provenance, edited-call invalidation, and the fail-closed service-history boundary. This layer intentionally excludes service-history ownership, general replay or approval binding, policy materialization, and MCP IFC changes.

Related Issue

Fixes #9652

#9652 is the original source draft. This PR is its AG-UI replay-provenance replacement layer, stacked as #9875 -> #9876 -> #9877 -> this PR rather than a competing implementation.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: GitHub Copilot assisted with implementation, regression tests, validation, and this PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (1 commit(s)): c127b36c74d5
Model: gpt-5.6-sol

Overview

The PR establishes a strong object-identity boundary for backend snapshot provenance, preserves it through normalization, and folds uncovered replay before the new snapshot-only save points. The regression coverage exercises restored history, missing labels, confirmation, authenticated rejection, and provider-failure paths. Two residual trust-boundary issues remain: the supported AG-UI dependency range permits a core version without the new security seam, and authenticated rejection provenance is assigned by a reusable call ID and public result string rather than by the exact lifecycle-produced result.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 1 file. Details are attached to the affected lines below.

Affected areas: python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py

@github-code-quality

github-code-quality Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: Python

Python / code-coverage/python

main b89eaeb fides-agui-replay-pr... 5eb0907 +/-
92% 92% 0%
View coverage of the 3 most impacted files.
File main b89eaeb fides-agui-replay-pr... 5eb0907 +/-
packages/ag-ui/...i/_agent_run.py 90% 90% 0%
packages/core/a...ork/security.py 90% 91% +1%
packages/ag-ui/...age_adapters.py 93% 94% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 12, 2026 12:59 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active security flaws can preserve trusted provenance for client-controlled tool data and reconstruct labels from incomplete history, bypassing conservative labeling and fail-closed protections.

4 open issues
What changed in this PR

This PR adds the AG-UI replay-provenance layer of the FIDES hardening stack, distinguishing backend-restored history from fresh client data when restoring and persisting security state.

Changes:

  • Preserve snapshot provenance through message normalization and remove private markers before provider exposure.
  • Fold uncovered replay before confirmation and approval snapshot saves, including missing-label reconstruction.
  • Add regression coverage for replay provenance, authenticated denials, and provider-failure persistence.
File Description
python/​packages/​core/​tests/​test_security.py Tests restored-state handling and replay-marker removal.
python/​packages/​core/​agent_framework/​security.py Adds transport-aware replay labeling and snapshot-time folding.
python/​packages/​ag-ui/​tests/​ag_ui/​test_endpoint.py Adds end-to-end provenance and security-state persistence tests.
python/​packages/​ag-ui/​agent_framework_ag_ui/​_message_adapters.py Carries snapshot provenance through message conversion and sanitation.
python/​packages/​ag-ui/​agent_framework_ag_ui/​_agent_run.py Connects snapshot and approval provenance to FIDES folding before saves.

Review effort: Balanced

Base automatically changed from fides-service-history-continuation to main November 12, 2026 11:14
@agent-framework-automation agent-framework-automation Bot added the documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs label Nov 12, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAF Automated Review — Iteration 2

Result: Findings reported
Scope: full PR (4 commit(s)): 26f309133f05, a13c157b2581, c0cc54dd603f, cc166c2eacbb
Model: gpt-5.6-sol

Overview

The PR carefully carries backend-snapshot provenance through AG-UI normalization, binds denial provenance to exact synthesized objects, invalidates provenance after client edits, and fails closed when service-owned history cannot be reconstructed. The added tests cover the principal replay, approval, provider-failure, and snapshot-save paths. Residual risk remains because the new sentinel is not copy-safe at the declared minimum dependency and because its global marker is consumed incorrectly when multiple FIDES context providers are configured.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 1 file. Details are attached to the affected lines below.

Affected areas: python/packages/core/agent_framework/security.py

Merged via the queue into main with commit e836934 Nov 12, 2026
55 checks passed
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) deleted the fides-agui-replay-provenance branch November 12, 2026 13:15

This branch was successfully deployed

1 active deployment
github-app-auth — 5eb09071 Deployed Nov 12, 2026 by eavanvalkenburg via add_label #27679
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants