Skip to content

[Bug]: 413 Request Entity Too Large 严重错误 #4036

Backlog

Description

@litterbug23

Summary

Failed to compact session: Validation error: Session must be idle before manual compaction: AI provider error: Model request failed after 1 attempts: OpenAI Streaming API client error 413 Payload Too Large: {"error":{"message":" (request id: 2026112420434332351684979683196)","type":"upstream_error","param":"413","code":"bad_response_status_code"}}

Area

Desktop app

Reproduction or evidence

image

Environment, if relevant

No response

Activity

  1. litterbug23 commented on Nov 25, 2026

    @litterbug23
    Author
    image
  2. litterbug23 commented on Nov 25, 2026

    @litterbug23
    Author

    最近总是弹出这个对话框,初步分析是我在对话中经常会截图并对截图分析
    image
    一般请求要求读文件时会发生;或者内容里面有文件链接,agent要弄清楚链接内容,也会读取。在CC产品级agent,自己会保护,如果这条路不通,会尝试切割或者grep关键内容或者读前几行。但是在OpenBitfun中没有考虑到这种情况,可能每次都把截图带入请求,导致请求体超过大小。
    在后台网关分析,请求体超过了5M,一次请求超过了5MB导致的网关触发保护模型。导致请求失败。碰到了输入大小保护,200KB,是上下文token,不是传统的理解大小,当工具调用时,如果都取是很大文件,会被拦截。
    这里应该是OpenBitfun的处理逻辑存在问题。

  3. changed the title [-][Bug]: Failed to compact session: Validation error:[/-] [+][Bug]: Failed to compact session: Validation error 严重错误[/+] on Nov 25, 2026
  4. changed the title [-][Bug]: Failed to compact session: Validation error 严重错误[/-] [+][Bug]: OpenAI Streaming API client error 413 Payload Too Large 严重错误[/+] on Nov 25, 2026
  5. changed the title [-][Bug]: OpenAI Streaming API client error 413 Payload Too Large 严重错误[/-] [+][Bug]: 413 Request Entity Too Large 严重错误[/+] on Nov 25, 2026
  6. litterbug23 commented on Nov 25, 2026

    @litterbug23
    Author

    Agent 多轮会话持续携带历史图像(base64),每一轮请求体不断累积膨胀,最终触发 413 Request Entity Too Large(Payload 过大)。
    这个问题在多轮视觉 Agent、MCP / 工具调用场景非常典型:图像二进制数据体积远大于文本,反复透传会快速打满服务端限制(常见上限 1~10MB)。

  7. litterbug23 commented on Nov 25, 2026

    @litterbug23
    Author

    Agent 多轮会话持续携带历史图像(base64),每一轮请求体不断累积膨胀,最终触发 413 Request Entity Too Large(Payload 过大)。
    这个问题在多轮视觉 Agent、MCP / 工具调用场景非常典型:图像二进制数据体积远大于文本,反复透传会快速打满服务端限制(常见上限 1~10MB)。

    核心解决思路(分层方案,从快到稳)

    方案 1:本地缓存图像,请求只传引用(推荐工程方案)

    不在每轮消息里塞 base64 原图,改成:

    1. 收到图像后,本地持久化(内存 Map / 本地文件 / 对象存储),分配一个短 id:img_001
    2. 发给 LLM 的消息里只放引用标记,不再携带 base64
    {
      "type": "image_ref",
      "ref_id": "img_001",
      "desc": "上一轮分析截图"
    }
    
    1. LLM/Agent 后续如果需要再次解析这张图,Agent 本地根据 ref_id 取出原图,单独发起一次图像识别子请求;不需要读图时,ref 只做上下文记忆,不上传图像二进制。
    2. 增加淘汰策略:LRU,超过 N 张 / 超时自动清理缓存图片,防止内存泄漏。

    优势:从根源切断 base64 循环携带;兼容多轮思考链;请求体体积可控。

  8. litterbug23 commented on Nov 25, 2026

    @litterbug23
    Author

    这个问题应该在已经解决了,我今天测试一下
    #4032

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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