Repository navigation
v0.1.35
Release Notes — v0.1.35
Tool calls whose first stream delta was lost are repaired instead of failing
- What you saw. Some third-party relays intermittently omit a tool call's first streamed delta — the frame carrying
function.nameand the opening{"of the arguments. Grok Build then dispatched an empty tool name with head-truncated arguments and reportedAgent tried calling a tool that doesn't exist, feeding a parse error back into the model and burning a retry round (observed repeatedly on GLM-family channels through relays). - What changed. hellogrok now repairs that damage in its shared tool-compatibility layer, for all three upstream protocols (
chat_completions,messages,responses), streaming and non-streaming alike:- Arguments truncated at the head are restored when prefixing
{"(or{) yields exactly one complete JSON object. - Empty names are inferred from the argument key set against the tools declared on that request; the shared
command+descriptionshape, which matches bothrun_terminal_commandandmonitor, resolves deterministically torun_terminal_command. Anything still ambiguous is left unrepaired rather than guessed. - Persisted history replayed in later requests (including
/resume) receives the same repair, and the repaired name is backfilled onto the matching tool-result message, so broken records no longer reach the upstream verbatim.
- Arguments truncated at the head are restored when prefixing
Out-of-order and name-less tool blocks are held until they can be resolved
- Chat Completions. Tool frames are now emitted at the stream terminal (
[DONE], stream end, or error frame) instead of atfinish_reason. Grok Build's chat accumulator reads the whole stream regardless of chunk order, so argument fragments a relay sends afterfinish_reasonare merged into complete arguments instead of being silently dropped with tail-truncated parameters. Held inline reasoning still flushes atfinish_reason, so visible latency of thought and text is unchanged. - Messages.
tool_useblocks are held betweencontent_block_startandcontent_block_stop; the accumulated input JSON resolves the name (and repairs its prefix) before the block is re-emitted as start + one completeinput_json_delta+ stop. Unclosed blocks flush atmessage_stop/error. - Responses.
function_callitems are held betweenresponse.output_item.addedandresponse.output_item.done; the done frame's complete item additionally serves as a second source for name and arguments, so a truncated argument stream loses to a complete terminal item. Unclosed items flush atresponse.completed/incomplete/failed.
Diagnostics
- Tool-call deltas that arrive after an early flush (error terminals) and are therefore discarded are logged per call index as
late-tool-deltas-discarded(index=N), making a relay that emitsfinish_reasonbefore its last argument fragments visible in the proxy log instead of surfacing only as a Grok Build parse failure.
Restart both hellogrok executables after upgrading.
发布说明 — v0.1.35
丢失首个流式增量的工具调用现在会被修复,而不是报错
- 你看到的现象。 部分第三方中继会间歇性丢掉工具调用的第一个流式增量——携带
function.name与参数开头{"的那一帧。Grok Build 随后以空工具名和缺开头的参数进行分发,报出Agent tried calling a tool that doesn't exist,并把解析错误回喂给模型、消耗一轮重试(在经中继的 GLM 系渠道上反复出现)。 - 本次变化。 hellogrok 在共享的工具兼容层修复这类损坏,覆盖三种上游协议(
chat_completions、messages、responses)及流式与非流式:- 参数缺开头时,补
{"(或{)后若能解析为恰好一个完整 JSON 对象,则恢复前缀。 - 空名称按该请求已声明工具的参数键集合推断;
command+description这一同时匹配run_terminal_command与monitor的共享形状确定性地解析为run_terminal_command。仍无法判定时保持不修复,不做猜测。 - 后续请求回放的已持久化历史(含
/resume)接受同样的修复,修复后的名称回填到对应 tool result 消息,损坏记录不再原样送达上游。
- 参数缺开头时,补
乱序与缺名工具块扣留到可解析为止
- Chat Completions。 工具帧改在流终止(
[DONE]、流末或错误帧)发出,而非finish_reason时刻。Grok Build 的 chat 累加器读取整条流、不依赖 chunk 顺序,因此中继在finish_reason之后补发的参数片段会并入完整参数,而不是被静默丢弃留下尾部截断。持有中的行内推理仍在finish_reason时发出,思考与正文的可见延迟不变。 - Messages。
tool_use块在content_block_start与content_block_stop之间扣留;累积的 input JSON 先解析名称(并修复前缀),再以"开始帧 + 单条完整input_json_delta+ stop"重发。未闭合块在message_stop/error时冲刷。 - Responses。
function_call项在response.output_item.added与response.output_item.done之间扣留;done 帧的完整 item 同时作为名称与参数的第二来源,截断的流上参数让位于完整的终止 item。未闭合项在response.completed/incomplete/failed时冲刷。
诊断
- 提前 flush(错误终止)之后到达、因而被丢弃的工具调用增量,按调用索引记录为
late-tool-deltas-discarded(index=N)。中继在最后一个参数片段之前发出finish_reason的缺陷由此在代理日志中可见,而不是只表现为 Grok Build 的解析失败。
升级后请重启两个 hellogrok 可执行文件。