fix(stream): 断流检测 + 会话连续 + 思考签名 + 文档映射 + 协议完整性加固 - #141
Closed
asuan-dev wants to merge 6 commits into
Closed
Conversation
Default User-Agent / x-amz-user-agent still advertised 0.11.107. Bump the fallback to the current desktop build and keep the per-endpoint header builders explicit so OAuth and API Key paths stay distinguishable.
Parse AWS event-stream messages with prelude/message CRC validation, keep official optional events, and accumulate parallel tool_use frames by id. Flush only after the full tool set validates so a malformed sibling cannot leak a partial tool call to the client.
Add same-account integrity retry for empty/truncated streams and reject
incomplete tool arguments instead of forging {}. Successful-turn sealing
is gated on terminal outcomes that are safe to continue from.
Mint conversation/continuation ids once and reuse them only on an exact client-transcript match. Store thinking signatures by exact turn key and reattach on the next request from the handler path, without fuzzy matching.
Translate document/file blocks into Kiro documents (including raw text), validate MIME/magic/name/limit rules, and classify upstream stop reasons once for Claude, OpenAI, and Responses mappings.
…r paths Route Claude/OpenAI/Responses through integrity retry, keep ClaudeToKiro pure with handler-side attachStoredReasoning, and restore web-search lifecycle seals: intermediate rounds seal the raw upstream tool shape so the next loop reuses ids; final flush seals client-visible content.
asuan-dev
force-pushed
the
fix/stream-integrity-and-ide-fingerprint
branch
from
July 26, 2026 05:17
1573c30 to
b784418
Compare
Contributor
Author
|
Closing this PR. Will not continue the changes here. |
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.
Summary
本 PR 修复 Kiro-Go 代理的几类真实线上问题,并补齐与官方协议更接近的流完整性/身份/文档路径:
当前 HEAD:
cd836d81. 断流 / 空流(核心)
metadataEvent.stopReasonend_turn/stop/completed,改为报错事件runKiroWithIntegrityRetry:streamIntegrityState,由状态对象统一观测 content / tools / stopReason / reasoning,避免各路径手搓四元组2. 并行 tool 完整性
toolUseId状态机累计,保留到达顺序{},作为 hard integrity errorexcluded正确排除该账号(不误伤 health 记罚)3. 客户端指纹
KiroIDE版本0.11.107→1.0.212resolveKiroEndpoint:URL / headers / content-type / agent-mode 单一来源4. 思考签名按次精确回贴
reasoningContentEvent解析 signature / redacted5. 会话连续性
conversationId/agentContinuationId不再每请求乱造或只靠 opener hash6. 文档 / 附件
document/file/input_document→ KiroDocumentssource.type=text+text/plain)extractClaudeUserContent单次解析返回校验错误,避免 validate 与 translate 各解一遍还吞错7. 协议帧与 stop reason
eventstreamCRC 校验(prelude + message)content_filtered等),统一映射到:end_turn/max_tokens/refusal/tool_use...stop/length/content_filter/tool_callscompleted/incomplete+ reason8. Web Search 生命周期
Test plan
go test ./proxy -count=1go test ./... -count=1Residual risks
Commits
80c2d98fix(protocol): align default client version with current Kiro IDE45b8478fix(stream): parse stopReason and stop losing parallel tool calls599e56bfix(stream): surface empty/truncated upstream streams instead of faking success17e1087fix(stream): reattach thinking signatures by exact turn key26259cbfeat(proxy): map Claude document blocks to Kiro documentsb4e5748fix(session): reuse conversation and continuation ids across a proven chain3a5ac64fix(session): seal the assistant turn the client actually storesce74db6merge: reconcile web search with stream and session fixescd836d8fix(proxy): harden stream integrity and protocol parity