Install
Configure once
AgentFeedbackFlask immediately after creating the app, before other app-wide after_request
handlers. It registers one response hook and wraps app.wsgi_app. Through Flask’s public
response API, it marks only non-streamed, non-passthrough response sequences whose bodies are already
materialized. JSON objects receive _agentFeedback, HTML receives embedded machine-readable JSON, and
arrays or scalar JSON use the Agent-Feedback response header.
The generic AgentFeedbackWSGI adapter remains available for Django WSGI, Bottle, Pyramid, and custom WSGI
applications. It inspects only exact built-in list and tuple bodies whose declared size is at most 1 MiB
and matches their materialized bytes. Custom iterables and generators, including ones with a known length,
retain their identity, laziness, first-byte timing, and close(). Lazy start_response(..., exc_info) calls
are delegated to the WSGI server so its replacement and re-raise rules remain intact.
With cache_mode="request", only callers sending Agent-Feedback-Request: 1 receive a contract. The
middleware adds Vary: Agent-Feedback-Request to ordinary and opted-in responses so a shared cache cannot
hide the opted-in request.
Eligible finite ordinary 2xx GET and HEAD responses also advertise a same-path-and-query Link for one
authenticated Companion refetch; redirects and non-safe methods never advertise it.
Server-rendered HTML
Included finite HTML pages receive the same machine-readable contract as the other adapters, and Epode recalculatesContent-Length. Streaming or unknown-size HTML remains byte-for-byte untouched.