OpenAI Responses streams that end incomplete or failed are logged without token metrics
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 77/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 py/src/braintrust/integrations/openai/tracing.py 中的 ResponseWrapper._postprocess_streaming_results 开始,追踪 response.completed 如何在两个分支中提供用量和输出。检查终止事件 response.incomplete 和 response.failed 如何暴露最终响应,然后使用提供的流式调用复现。完成标准是这些终止事件会记录 token 指标和最终输出,并且有一份录制的 cassette 覆盖此行为。
由索引模型根据 Issue 内容生成。
描述
ResponseWrapper._postprocess_streaming_results (py/src/braintrust/integrations/openai/tracing.py) reads the final response only from response.completed. That event's response.usage populates the metrics, and its response.output becomes the logged output.
A Responses stream can also end on response.incomplete (for example when max_output_tokens is reached) or response.failed. Both events carry the same final response, with its usage and output. For those streams:
- no token metrics are logged: the intermediate events carry no usage, and the terminal response's usage is only read for
response.completed - the logged output is the partial reconstruction from the deltas, not the final
response.output
Repro: client.responses.create(model="gpt-4.1", input="Write a long essay", max_output_tokens=16, stream=True) with the wrapped client. The stream ends on response.incomplete and the span has no prompt_tokens/completion_tokens metrics.
Suggested fix: handle response.incomplete and response.failed the same way as response.completed in both branches. I'm happy to send a PR with a recorded cassette if that works for you.
This issue was written with help from an AI coding assistant (Claude Code); the code path above was checked on main.
- 主要语言
- Python
- 星标
- 22
- 派生
- 27
- 平均合并
- 14 小时 49 分钟
- 30 天内合并 PR
- 126
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-python 的其他 Issue
-
Temporal: add `workflow.Info.original_execution_run_id` to workflow span metadata可能已有人在做 @Ehsan-hash 于 1 天前认领。 未关闭feature python
难度 2/5 1-3 小时 新手友好度 76/100
braintrustdata/braintrust-sdk-python#868 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
braintrustdata/braintrust-sdk-python#957 ·
维护者通常 1 天内回复
-
python
难度 5/5 一周以上 新手友好度 35/100
braintrustdata/braintrust-sdk-python#956 ·
维护者通常 1 天内回复
-
python
braintrustdata/braintrust-sdk-python#839 ·
维护者通常 1 天内回复
-
new-integration
难度 4/5 3-5 天 新手友好度 68/100
braintrustdata/braintrust-sdk-python#808 ·
维护者通常 1 天内回复
查看 braintrustdata/braintrust-sdk-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#140958 ·
维护者通常 1 天内回复
-
bisect
难度 2/5 1-3 小时 新手友好度 72/100
dtcxzyw/llvm-bisect-service#548 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
sallowayma-git/IELTS-practice#248 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 65/100
anthropics/claude-plugins-official#6763 · 10 条评论 · 10 个 reaction ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复