Skip to content

标题: [Bug] ChatRuntimeStreamError: Runtime delivery receipt does not resolve to this Web Chat session - messages lost after LLM success #962

Description

@gongjing2012

环境

  • Clawith 版本: 1.11.3 (main branch, commit from 2026-08-12)
  • 部署方式: Docker Compose (单节点, APP_WORKERS=1)
  • 系统: Amazon Linux 2023 ARM64 (t4g.large)
  • Redis: 7-alpine (容器内)
  • PostgreSQL: 15-alpine (容器内)

问题描述

Agent Runtime V2 在单 worker 部署下,LLM 调用成功返回 200,但 WebSocket stream 报 ChatRuntimeStreamError: Runtime delivery receipt does not resolve to this Web Chat session,导致:

  1. 前端看不到 AI 的回复
  2. 刷新页面后消息完全丢失(chat_messages 未持久化)

复现步骤

  1. 全新 Docker Compose 部署(AGENT_RUNTIME_V2_ENABLED=true)
  2. 创建 Agent,配置 DeepSeek 模型(deepseek-v4-pro)
  3. 新建对话,发送任何消息
  4. 后端日志显示 LLM 返回 200 OK
  5. 但随后报 ChatRuntimeStreamError: Runtime delivery receipt does not resolve to this Web Chat session
  6. 前端收到 "Runtime execution continues, but its live event stream was interrupted"
  7. 刷新后对话为空

关键日志

[RuntimeModelRequest] provider=deepseek model=deepseek-v4-pro HTTP Request: POST https://api.deepseek.com/v1/chat/completions "HTTP/1.1 200 OK" [Token Cache] API Provider -> Created: 0 tokens, Read: 7680 tokens

ERROR | app.api.websocket:1154 - [WS] Runtime event stream failed: Runtime delivery receipt does not resolve to this Web Chat session File "/app/app/services/agent_runtime/chat_stream.py", line 72, in _load_delivered_message raise ChatRuntimeStreamError(

附加问题

  • 设置 AGENT_RUNTIME_V2_ENABLED=false 后,Agent 的 native runtime 类型完全不处理消息(WS 收到内容但不调用 LLM)
  • 问题在每次新 session 中 100% 复现

其他已发现的代码问题

  1. db: Any = None 依赖注入缺失app/api/enterprise.py 等 35+ 个文件中的路由函数 db 参数没有 Depends(get_db)
  2. UUID 类型错误enterprise.py:401uuid.UUID(tid) 对已经是 UUID 类型的 tid 调用导致 'UUID' object has no attribute 'replace'
  3. Alembic migration 冲突f061_enterprise_info_tenant_id 尝试 ADD COLUMN tenant_id,但 initial_schema 已经创建了该列

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions