Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

OpenAI Responses streams that end incomplete or failed are logged without token metrics

未关闭 适合新手
#962 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
77/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
observability

调研方向

从 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

braintrustdata/braintrust-sdk-python 的其他 Issue

查看 braintrustdata/braintrust-sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。