Repository navigation
小助手失败可查看详情,并在本机记日志 - #22
Merged
Merged
Conversation
上游超时、限额、解析失败和网络错误不再一律显示「没想好」。每次 /api/ai 带 requestId,失败返回分类和可公开细节,并写一行不含密钥的结构化日志。 Co-authored-by: Jett Wang <jamiesun@users.noreply.github.com>
小助手请求返回 401 时,孩子看到「登录已经过期了」,查看详情里仍有分类和 requestId。 Co-authored-by: Jett Wang <jamiesun@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
根因
「小助手这次没想好,再试一次吧。」出现在两条互不相通的路径上,中间把原因丢掉了:
upstream_failed(或未捕获异常)。errorResponse还会把意外错误的Error.message原样返回,里面可能带上接口地址。askGateway只看 HTTP 状态:不是 401 / 403 / 503 就抛GatewayError("failed")。noteApiProblem于是固定显示text.ai.failed。outcome.message(解析失败、没有main.py、素材复制被拒),但对话卡的outcomeCopy不读它,一律text.pane.failed。所以孩子看不到超时、限额、断网、未登录和解析位置。控制台里的
console.warn刷新就没了,也没有requestId能到 Cloudflare 日志里对上。顺手修掉的高频原因
fetch没有超时。挂起会拖到平台杀掉 Worker,浏览器只看到一段非 JSON。现在 45 秒后返回分类timeout。Retry-After与「模型没按 JSON 回答」长得一样。现在是rate_limit,细节里只有状态码和秒数。response.json()抛出的异常可能带上正文。现在是固定的parse细节。content做成片段数组,旧代码当成空回答。现在会把文本片段拼起来。JSON.parse的SyntaxError会引用模型原文(可能含孩子的代码或密钥样式的字符串)。解析失败只保留字符位置。sign_in和requestId。新行为
POST /api/ai生成gk_开头的requestId(身份被拒也有)。失败返回category、给孩子的一句话、可公开细节。旧的code(sign_in_required、upstream_failed等)还在。consoleJSON(source: "gamekit.ai"):操作、耗时、状态、用量、失败分类。不记录邮箱、密钥、提示词、源码。gamekit版本 4 的logs表,最近 200 条)。可筛选、搜索、查看、复制、清空。不登录、不上传。句子的唯一来源是
shared/assistant-error.ts。docs/ai-rules.md和docs/roadmap.md的验收矩阵已补上这一行。截图
上游返回 429 时,对话里是「小助手太忙了,稍后再试。」点开「查看详情」能看到分类
rate_limit、gk_编号、时间和upstream HTTP 429。正文里没有密钥。小助手太忙时展开查看详情
工具栏「日志」打开本机记录。同一条请求在「小助手」筛选里,带出错标记和同一句人话。
日志面板里的小助手出错记录
To show artifacts inline, enable in settings.