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:
AskaEth committed 2026-10-03 22:28:21 +08:00
1 parent 355f81d04a
commit 91e8d7a029
44 files changed
+1315 -1315

No files matched your search

+18 -18
View File
@@ -9,29 +9,29 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/trace"
)
// stepOutcome is the loop's internal view of one model step, normalized from the
// agent's *agent.StepResult (non-streaming) or the equivalent built by the
// streaming path.
// stepOutcome 是循环对单个模型步的内部视图,由
// agent 的 *agent.StepResult(非流式)或流式路径构建的等价物
// 归一化而来。
type stepOutcome struct {
final bool
text string
toolCalls []agent.ToolCall
stopReason string
// modelStopReason is the provider's raw stop/finish reason for the model
// call (Anthropic max_tokens / end_turn / tool_use), recorded on the llm_call
// span so a truncation is visible even when the step itself ended normally.
// modelStopReason 是 provider 对该模型调用的原始 stop/finish
// 原因(Anthropic max_tokens / end_turn / tool_use),记录在 llm_call
// span 上,使即使该步本身正常结束,截断也可见。
modelStopReason string
// model is the routed model that served the call, known on the streaming path
// (which builds the request itself) and empty on the agent path. It is
// recorded on the llm_call span's log event.
// model 是服务该调用的路由模型,在流式路径上可知
//(该路径自行构建请求),在 agent 路径上为空。它
// 记录在 llm_call span 的日志事件上。
model string
}
// step runs a single model call. When an OnStream callback is configured it
// drives the adapter's ChatStream directly, threading deltas to OnStream and
// applying the loop's guardrails; otherwise it delegates to the agent's RunStep,
// which runs the agent's own guardrails and records its own CallRecord. The whole
// call is wrapped in an llm_call span so the M9 panel sees each LLM invocation.
// step 运行单次模型调用。配置了 OnStream 回调时,它
// 直接驱动适配器的 ChatStream,把增量串给 OnStream 并
// 应用循环的护栏;否则委托给 agent 的 RunStep,
// 由后者运行 agent 自身的护栏并记录自己的 CallRecord。整个
// 调用被包在 llm_call span 中,使 M9 面板能看到每次 LLM 调用。
func (l *Loop) step(ctx context.Context, sessionID string, messages []model.Message) (*stepOutcome, error) {
_, llmSpan := l.span(ctx, "llm.call", trace.SpanKindLLM)
@@ -39,8 +39,8 @@ func (l *Loop) step(ctx context.Context, sessionID string, messages []model.Mess
out *stepOutcome
err error
)
// Muted (internal autonomous pass) bypasses streaming: it neither streams to
// the UI nor pays the streaming path's extra overhead. Normal chat streams.
// 静音(内部自主流程)绕过流式:它既不流向
// UI,也不付流式路径的额外开销。正常聊天则流式。
if l.onStream != nil && !isMutedBroadcast(ctx) {
out, err = l.streamStep(ctx, messages)
} else {
@@ -62,8 +62,8 @@ func (l *Loop) step(ctx context.Context, sessionID string, messages []model.Mess
return out, nil
}
// agentStep delegates a non-streaming step to the turn's agent, which runs input
// and output guardrails, calls the model and decodes any tool calls.
// agentStep 把非流式步委托给该 turn 的 agent,由后者运行输入
// 与输出护栏、调用模型并解码所有工具调用。
func (l *Loop) agentStep(ctx context.Context, sessionID string, messages []model.Message) (*stepOutcome, error) {
sr, err := l.agentFor(ctx).RunStep(ctx, sessionID, messages)
if err != nil {