Skip to content

feat: implement message continuation and error handling improvements#65

Merged
chenyme merged 2 commits into
devfrom
error_message
May 27, 2026
Merged

feat: implement message continuation and error handling improvements#65
chenyme merged 2 commits into
devfrom
error_message

Conversation

@chenyme

@chenyme chenyme commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

修复对话流式生成在中途失败或上游协议异常时的回复保留问题。现在如果错误发生前已经生成了部分 assistant 内容、工具调用记录或原生工具用量,会保留为本轮中断消息,并返回给前端展示,同时统一 run、消息用量和账单记录口径,避免“内容已展示但未计费/日志不一致”。

同时优化上游成功状态码但响应格式不兼容时的错误摘要,避免把原始 SSE data: 内容直接暴露在错误正文中,原始响应仍保留在调试信息里。

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • cd backend && go test ./internal/application/conversation
  • cd backend && go test ./internal/transport/http/conversation
  • cd backend && go test ./...
  • cd frontend && pnpm lint
  • cd frontend && pnpm build
  • git diff --check

Screenshots, API examples, or logs

No screenshots added.

Relevant behavior:

  • Interrupted stream responses now include retained message data in the final error event when partial content was persisted.
  • Raw upstream SSE bodies are no longer shown in the user-facing error summary for HTTP 2xx protocol-incompatible responses.

Configuration, migration, and compatibility notes

Configuration changes: None.

Database migrations: None.

Deployment changes: None.

API compatibility: Existing send/stream endpoints remain unchanged. Stream error events may now include retained message data when an interrupted assistant message was successfully persisted.

Swagger: Not regenerated; no new route or request/response DTO schema was introduced.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • User data access remains scoped by authenticated user context unless an admin-only path explicitly requires broader access.
  • Security-sensitive behavior was reviewed, including authentication, authorization, provider routing, file processing, billing, and admin APIs where relevant.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme linked an issue May 27, 2026 that may be closed by this pull request
3 tasks
@chenyme
chenyme merged commit a26b420 into dev May 27, 2026
2 checks passed
@chenyme
chenyme deleted the error_message branch May 27, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: 重试中断回复时复用已成功生成的内容和工具结果

1 participant