56c4425db2
* Python: bridge AG-UI request state into sessions Decisions: - Project resolved AG-UI Shared State into the per-run AgentSession without typed restoration. - Preserve existing local/service session identifiers and keep AG-UI state out of provider metadata. Files changed: - packages/ag-ui/agent_framework_ag_ui/_agent_run.py - packages/ag-ui/tests/ag_ui/test_endpoint.py Verification: - uv run poe check -P ag-ui - uv run poe test -P ag-ui (912 passed) Notes: - Scoped cross-run Session Continuation State remains for the next dependent issue. * Python: persist scoped AG-UI session continuity Decisions: - Store private Session Continuation State atomically in scoped thread snapshots and restore it through the core AgentSession contract. - Exclude Shared State keys, all HistoryProvider buckets, and tool approval state; request overlays evict colliding private values. - Finalize interrupted response streams before snapshotting so provider after_run mutations are included. Files changed: - packages/ag-ui/agent_framework_ag_ui/_agent_run.py - packages/ag-ui/agent_framework_ag_ui/_snapshots.py - packages/ag-ui/tests/ag_ui/test_endpoint.py - packages/ag-ui/tests/ag_ui/test_snapshots.py - packages/ag-ui/AGENTS.md Verification: - uv run poe test -P ag-ui (921 passed) - uv run poe check -P ag-ui - uv run poe typing -P ag-ui Notes: - Lifecycle, isolation, and broader storage guidance remain for the next dependent issue. * Python: document AG-UI session continuity lifecycle Decisions: - Keep scoped thread snapshots as the single reset and continuity boundary, with missing request Shared State preserving private continuation. - Document trusted typed-restoration storage, State Authorities, custom-store round trips, and one-active-run last-writer-wins consistency. - Verify failure, hydration privacy, scope/thread isolation, and reset mechanics through public endpoint and store seams. Files changed: - packages/ag-ui/README.md - packages/ag-ui/tests/ag_ui/test_endpoint.py - packages/ag-ui/tests/ag_ui/test_snapshots.py Verification: - uv run pytest -q <focused lifecycle tests> (6 passed) - uv run poe test -P ag-ui - uv run poe syntax -P ag-ui -C - uv run poe typing -P ag-ui - uv run poe check -P ag-ui - uv run poe markdown-code-lint Notes: - No runtime capability probe, secondary state store, locking, or configuration flag was added. - No blockers remain for this lifecycle and guidance slice. * Python: harden AG-UI session continuity * Python: isolate AG-UI request state
2.6 KiB
2.6 KiB
AG-UI Package (agent-framework-ag-ui)
AG-UI protocol integration for building agent UIs with the AG-UI standard.
Main Classes
AgentFrameworkAgent- Wraps agents for AG-UI compatibilityAgentFrameworkWorkflow- Wraps nativeWorkflowobjects, or acceptsworkflow_factory(thread_id)for thread-scoped workflow instances without subclassingAGUIChatClient- Chat client that speaks AG-UI protocolAGUIHttpService- HTTP service for AG-UI endpointsAGUIEventConverter- Converts between Agent Framework and AG-UI eventsadd_agent_framework_fastapi_endpoint()- Add AG-UI endpoint to FastAPI app (SupportsAgentRunorWorkflow)InMemoryAGUIThreadSnapshotStore- Memory-only latest AG-UI Thread Snapshot store for local development, demos, and tests
Types
AGUIRequest/AGUIChatOptions- Request typesAGUIThreadSnapshot/AGUIThreadSnapshotStore- Thread snapshot model with client-replayable data, private Session Continuation State, and a scoped async store protocolavailableInterrupts/resume- Optional canonical AG-UIInterruptandResumeEntryprotocol dataAgentState/RunMetadata- State management typesPredictStateConfig- Configuration for state prediction
Protocol Notes
- Outbound custom events are emitted as AG-UI
CUSTOM. - Usage metadata from
Content(type="usage")is surfaced asCUSTOMevents withname="usage". - Inbound custom event aliases are accepted:
CUSTOM,CUSTOM_EVENT, andcustom_event. - Multimodal user inputs support both legacy (
text,binary) and draft-style (image,audio,video,document) shapes. - Interrupted runs complete with
RUN_FINISHED.outcome.type == "interrupt"and canonicaloutcome.interrupts; do not document or add new flows that depend on the legacy top-levelRUN_FINISHED.interruptfield. InterruptandResumeEntrycome from theag-ui-protocolpackage (ag_ui.core), not from an Agent Framework-specific interrupt model.- SSE keepalive is endpoint-owned transport behavior configured through
add_agent_framework_fastapi_endpoint(keepalive_seconds=...). It emits SSE comments only; do not addPING,HEARTBEAT, orKEEPALIVEAG-UI events, and do not add runner-level keepalive settings.
Usage
from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint
from fastapi import FastAPI
app = FastAPI()
add_agent_framework_fastapi_endpoint(app, agent)
Import Path
from agent_framework.ag_ui import AGUIChatClient, add_agent_framework_fastapi_endpoint
# or directly:
from agent_framework_ag_ui import AGUIChatClient