docs(runtime): internal/runtime/loop 44 个文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;本模块按长期分批协议(一个模块一次派工)执行。 注释行数 1329 → 1329 逐行 1:1(含中文 33 → 1304);行尾注释 5 条一并译。 校验:机械校验(非注释改动行)= 空;独立 Go AST 程序(剥注释复渲)证明 44/44 文件代码全等; 全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。 gofmt:capacity_loop_test.go / flow.go 改动前即未格式化,按铁律保留原样未动。
This commit is contained in:
1 parent
355f81d04a
commit
91e8d7a029
44 files changed
+1315
-1315
No files matched your search
@@ -8,11 +8,11 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/model"
|
||||
)
|
||||
|
||||
// nativeDatetimeCall is a provider-native tool call response: the adapters put
|
||||
// the call in Response.ToolCalls (not in Content), which is exactly the shape a
|
||||
// thinking model returns for "what time is it" when the datetime tool is
|
||||
// advertised. Content is empty, so a loop that ignores ToolCalls produces a
|
||||
// silent empty reply.
|
||||
// nativeDatetimeCall 是一个 provider 原生工具调用响应:适配器把
|
||||
// 调用放在 Response.ToolCalls(而非 Content)中,这正是
|
||||
// 思考模型在 datetime 工具被广告时对「现在几点」返回的
|
||||
// 形态。Content 为空,因此忽略 ToolCalls 的循环会产出
|
||||
// 静默的空回复。
|
||||
func nativeDatetimeCall() model.Response {
|
||||
return model.Response{
|
||||
Model: "m",
|
||||
@@ -25,8 +25,8 @@ func nativeDatetimeCall() model.Response {
|
||||
}
|
||||
}
|
||||
|
||||
// assertNativeFeedBack checks that req carries the assistant tool_use turn and a
|
||||
// correlated tool result for toolCallID.
|
||||
// assertNativeFeedBack 检查 req 携带 assistant tool_use 轮以及
|
||||
// 与 toolCallID 关联的工具结果。
|
||||
func assertNativeFeedBack(t *testing.T, req model.Request, toolCallID string) {
|
||||
t.Helper()
|
||||
for i := 0; i < len(req.Messages)-1; i++ {
|
||||
@@ -52,10 +52,10 @@ func assertNativeFeedBack(t *testing.T, req model.Request, toolCallID string) {
|
||||
t.Fatalf("no native assistant tool_use + tool_result pair for %q in %+v", toolCallID, req.Messages)
|
||||
}
|
||||
|
||||
// TestRun_NativeToolCall_Streaming covers the real chat path (the loop drives
|
||||
// ChatStream when OnStream is set): a native provider tool call with empty
|
||||
// Content must be executed and fed back as native tool_use + tool_result, and
|
||||
// the run must finish with the model's follow-up text instead of an empty reply.
|
||||
// TestRun_NativeToolCall_Streaming 覆盖真实聊天路径(设置 OnStream 时
|
||||
// 循环驱动 ChatStream):Content 为空的 provider 原生工具调用
|
||||
// 必须被执行并以原生 tool_use + tool_result 回灌,且
|
||||
// run 必须以模型的后续文本结束,而不是空回复。
|
||||
func TestRun_NativeToolCall_Streaming(t *testing.T) {
|
||||
t.Parallel()
|
||||
ad := &mockAdapter{stream: []mgResp{
|
||||
@@ -85,9 +85,9 @@ func TestRun_NativeToolCall_Streaming(t *testing.T) {
|
||||
assertNativeFeedBack(t, ad.streamReqs[1], "call_native_1")
|
||||
}
|
||||
|
||||
// TestRun_NativeToolCall_NonStreaming covers the muted/internal path where the
|
||||
// loop delegates to agent.RunStep (adapter.Chat), which must decode the same
|
||||
// native tool call.
|
||||
// TestRun_NativeToolCall_NonStreaming 覆盖静音/内部路径,其中
|
||||
// 循环委托给 agent.RunStep(adapter.Chat),后者必须解码同一个
|
||||
// 原生工具调用。
|
||||
func TestRun_NativeToolCall_NonStreaming(t *testing.T) {
|
||||
t.Parallel()
|
||||
ad := &mockAdapter{chat: []mgResp{
|
||||
@@ -111,9 +111,9 @@ func TestRun_NativeToolCall_NonStreaming(t *testing.T) {
|
||||
assertNativeFeedBack(t, ad.reqs[1], "call_native_1")
|
||||
}
|
||||
|
||||
// TestExtractToolCalls_PrefersNative pins the decoder contract: provider-native
|
||||
// ToolCalls win over a Content envelope and preserve the provider id, so the
|
||||
// feed-back can correlate the result.
|
||||
// TestExtractToolCalls_PrefersNative 钉住解码器契约:provider 原生
|
||||
// ToolCalls 优先于 Content 信封并保留 provider id,使
|
||||
// 回灌能关联该结果。
|
||||
func TestExtractToolCalls_PrefersNative(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := nativeDatetimeCall()
|
||||
|
||||
Reference in new issue
Block a user