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 摘要。