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
@@ -9,9 +9,9 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/model"
|
||||
)
|
||||
|
||||
// TestAssembleContext_ReRetrievesEachRound proves memory is re-retrieved every
|
||||
// round rather than cached from the first turn: an empty store yields no memory
|
||||
// block, then after seeding the store a later round picks it up.
|
||||
// TestAssembleContext_ReRetrievesEachRound 证明记忆每轮都重新
|
||||
// 检索,而非从首轮缓存:空 store 产出无记忆块,
|
||||
// 随后在 store 中播种后,之后的轮次能取到它。
|
||||
func TestAssembleContext_ReRetrievesEachRound(t *testing.T) {
|
||||
t.Parallel()
|
||||
store := newTestMemoryStore(t)
|
||||
@@ -20,12 +20,12 @@ func TestAssembleContext_ReRetrievesEachRound(t *testing.T) {
|
||||
|
||||
msgs := []model.Message{model.TextMessage(model.RoleUser, "do the thing")}
|
||||
|
||||
// Round 1: the store is empty, so no memory is injected.
|
||||
// 第 1 轮:store 为空,因此不注入记忆。
|
||||
if view := l.assembleContext(context.Background(), msgs, 1); len(view) != 1 {
|
||||
t.Fatalf("round 1 view = %d messages, want 1 (not memory)", len(view))
|
||||
}
|
||||
|
||||
// Seed a memory as if it was learned between rounds.
|
||||
// 播种一条记忆,如同它在轮次之间被学到。
|
||||
if _, err := store.Add(context.Background(), memory.MemoryItem{
|
||||
PersonaID: "persona-a", Content: "她喜欢冰美式",
|
||||
Scope: memory.ScopePersona, Kind: memory.KindRelationship,
|
||||
@@ -33,7 +33,7 @@ func TestAssembleContext_ReRetrievesEachRound(t *testing.T) {
|
||||
t.Fatalf("seed memory: %v", err)
|
||||
}
|
||||
|
||||
// Round 2: the retrieval is re-run and the memory now appears.
|
||||
// 第 2 轮:检索重新运行,该记忆现在出现。
|
||||
view := l.assembleContext(context.Background(), msgs, 2)
|
||||
if len(view) != 2 {
|
||||
t.Fatalf("round 2 view = %d messages, want 2 (memory injected)", len(view))
|
||||
@@ -43,8 +43,8 @@ func TestAssembleContext_ReRetrievesEachRound(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestCompactIfNeeded_OverBudget_Compacts drives a multi-turn conversation over a
|
||||
// small budget and verifies the loop compacts it into a leading summary.
|
||||
// TestCompactIfNeeded_OverBudget_Compacts 驱动一段超出小预算的
|
||||
// 多轮对话,并验证循环把它压缩为一条前导摘要。
|
||||
func TestCompactIfNeeded_OverBudget_Compacts(t *testing.T) {
|
||||
t.Parallel()
|
||||
l := New(Options{MaxContextTokens: 1000})
|
||||
@@ -61,11 +61,11 @@ func TestCompactIfNeeded_OverBudget_Compacts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestCompactIfNeeded_Disabled_NoOp keeps the pre-existing behavior when
|
||||
// MaxContextTokens is left at its zero value.
|
||||
// TestCompactIfNeeded_Disabled_NoOp 在 MaxContextTokens
|
||||
// 保持零值时保留既有行为。
|
||||
func TestCompactIfNeeded_Disabled_NoOp(t *testing.T) {
|
||||
t.Parallel()
|
||||
l := New(Options{}) // MaxContextTokens == 0 → disabled
|
||||
l := New(Options{}) // MaxContextTokens == 0 → 已关闭
|
||||
big := buildTurns(6, 300, false)
|
||||
got := l.compactIfNeeded(context.Background(), big)
|
||||
if len(got) != len(big) {
|
||||
@@ -73,9 +73,9 @@ func TestCompactIfNeeded_Disabled_NoOp(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRun_TransformContext_InvokedEachRound verifies the TransformContext hook is
|
||||
// called once per model step (per round), bridging per-round assemble into the
|
||||
// Run path.
|
||||
// TestRun_TransformContext_InvokedEachRound 验证 TransformContext 钩子
|
||||
// 每个模型步(每轮)调用一次,把每轮的 assemble 桥接
|
||||
// 进 Run 路径。
|
||||
func TestRun_TransformContext_InvokedEachRound(t *testing.T) {
|
||||
t.Parallel()
|
||||
call := `{"tool_calls":[{"name":"echo","args":{"q":"x"}}]}`
|
||||
@@ -107,15 +107,15 @@ func TestRun_TransformContext_InvokedEachRound(t *testing.T) {
|
||||
if rounds[0] != 1 || rounds[1] != 2 {
|
||||
t.Fatalf("rounds passed to TransformContext = %v, want [1 2]", rounds)
|
||||
}
|
||||
// Round 1 has just the user message; round 2 has the fed-back tool result.
|
||||
// 第 1 轮只有用户消息;第 2 轮有回灌的工具结果。
|
||||
if sizes[0] != 1 || sizes[1] != 2 {
|
||||
t.Fatalf("sizes = %v, want [1 2]", sizes)
|
||||
}
|
||||
}
|
||||
|
||||
// TestRun_ContextOverflow_CompactsHistory passes a long multi-turn history and a
|
||||
// small budget into Run; the first model step should see a compacted conversation
|
||||
// carrying a leading summary.
|
||||
// TestRun_ContextOverflow_CompactsHistory 把一段长的多轮历史和一个小
|
||||
// 预算传入 Run;第一个模型步应看到一段带前导摘要的
|
||||
// 压缩后对话。
|
||||
func TestRun_ContextOverflow_CompactsHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
ad := &mockAdapter{chat: []mgResp{{resp: model.Response{Content: "final answer"}}}}
|
||||
|
||||
Reference in new issue
Block a user