ag-ui-protocol / ag-ui-protocol/ag-ui

[Feature]: Add event sequence validation (`validate_sequence`) to Python SDK

未關閉
#1,322 3 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Python
星號
15.9k
分支
1.4k
平均合併
1 天 17 小時
30 天內合併 PR
163

描述

### Pre-flight Checklist

- [x] I have searched existing issues and this hasn't been requested yet.

### Problem or Motivation

The Go SDK provides `ValidateSequence` (sdks/community/go/pkg/core/events/events.go) and the TypeScript SDK provides `verifyEvents` (sdks/typescript/packages/client/src/verify/verify.ts) for validating that AG-UI event streams conform to the protocol's state machine rules (run lifecycle, message/tool call/step open-close pairing, no duplicates, etc.).

The Python SDK (`ag-ui-protocol`) has no equivalent. There is only get Pydantic type validation on individual events, but no sequence-level validation.

### Proposed Solution

Add a `validate_sequence` function (or similar) to the Python SDK under `ag_ui.verify` (or `ag_ui.core`), mirroring the rules enforced by the Go and TypeScript implementations:

- **Run lifecycle**: No duplicate starts, no finishing/erroring unstarted runs, no restarting finished runs
- **Message lifecycle**: TEXT_MESSAGE_CONTENT/END require an active message started with TEXT_MESSAGE_START
- **Tool call lifecycle**: TOOL_CALL_ARGS/END require an active tool call started with TOOL_CALL_START
- **Step lifecycle**: No duplicate step names, can't finish unstarted steps
- **Reasoning lifecycle**: Same open-close pairing as messages

### Alternatives Considered

Manually implementing validation in each project that uses the Python SDK

### Additional Context

Reference implementations:
- Go: https://github.com/ag-ui-protocol/ag-ui/blob/main/sdks/community/go/pkg/core/events/events.go#L229 (ValidateSequence)
- TypeScript: https://github.com/ag-ui-protocol/ag-ui/blob/main/sdks/typescript/packages/client/src/verify/verify.ts#L5 (verifyEvents)

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。