修复AGC大上下文请求体限制 #295
Reference in New Issue
Block a user
Delete Branch "fix/llm-body-limit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景与问题
AGC(AI 游戏创作智能体 App)Direct Codex 模式在携带图片工具结果等大上下文调用 LLM 时,
/api/llm/responses与/api/llm/chat/completions会命中 Axum 默认 2 MiB 请求体上限,直接被 413 拒绝,大上下文任务无法执行;同时 Codex app-server 的 failed turn 未把上游 413 映射为稳定错误分类,前端只能显示笼统的“其他错误”,无法引导用户处理。改动内容
1. api-server(server-rs)
LLM_REQUEST_MAX_BODY_BYTES = 32 MiB,作为两个 LLM 代理路由的正式请求体上限;DefaultBodyLimit::max(32 MiB),避免 Axum 默认 2 MiB 提前拒绝;handler 内保留超限检查,超过 32 MiB 仍返回413 PAYLOAD_TOO_LARGE;2. AGC 壳(apps/ai-game-creator-shell)
codex_app_server错误映射:上游/连接层 HTTP 413、PAYLOAD_TOO_LARGE、provider request too large等统一映射为稳定分类codex-app-server-error:request-too-large,不再落入other或误判为权限/安全策略错误;3. 文档
DefaultBodyLimit、413 映射规则与用户文案。验证
cargo test -p api-server llm_routes_accept_large_context_bodies_beyond_axum_default通过cargo test -p api-server llm_responses_rejects_bodies_above_explicit_limit通过cargo test ... ai-game-creator-shell ... codex_app_server_failed_turn_maps_request_too_large_details通过npm run test -- apps/ai-game-creator-shell/tests/agentRuntimeModel.test.ts(27 通过)全量 workspace 测试与 CI 门禁待推送后由 CI 覆盖。
当前提交代码审查通过,未发现需要修改的问题。
已在该提交完成以下定向验证:
远端 4 项 CI 仍为 Waiting to run,合并前请等待门禁通过。