-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(llmloop): backfill comment thinking from turn output #773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6627ecc
2b18430
373b8c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -247,8 +247,14 @@ func (r *Runner) RunPerFile(ctx context.Context, messages []llm.Message, newPath | |||||||
| taskCompleted := false | ||||||||
| hasValidResult := false | ||||||||
|
|
||||||||
| // Prefer the model's native reasoning content; fall back to the | ||||||||
| // assistant message of this turn for models that do not expose it. | ||||||||
| thinking := resp.ReasoningContent() | ||||||||
| if thinking == "" { | ||||||||
| thinking = content | ||||||||
| } | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capture the model's native reasoning content for this turn.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
| for _, call := range calls { | ||||||||
| cp := r.executeToolCall(ctx, newPath, call, rec) | ||||||||
| cp := r.executeToolCall(ctx, newPath, call, rec, thinking) | ||||||||
| if cp.Failed { | ||||||||
| return false, StopNone, fmt.Errorf("task failed: %s", cp.Data) | ||||||||
| } else if cp.Completed { | ||||||||
|
|
@@ -307,7 +313,7 @@ func (r *Runner) RunPerFile(ctx context.Context, messages []llm.Message, newPath | |||||||
| // records the result in session history. code_comment handling includes | ||||||||
| // optional async dispatch through CommentWorkerPool plus line-number | ||||||||
| // resolution / re-location. | ||||||||
| func (r *Runner) executeToolCall(ctx context.Context, newPath string, call llm.ToolCall, rec *session.TaskRecord) tool.TaskCheckpoint { | ||||||||
| func (r *Runner) executeToolCall(ctx context.Context, newPath string, call llm.ToolCall, rec *session.TaskRecord, thinking string) tool.TaskCheckpoint { | ||||||||
| t := tool.OfName(call.Function.Name) | ||||||||
|
|
||||||||
| if !t.IsKnown() { | ||||||||
|
|
@@ -398,6 +404,14 @@ func (r *Runner) executeToolCall(ctx context.Context, newPath string, call llm.T | |||||||
| return tool.Of(errMsg) | ||||||||
| } | ||||||||
|
|
||||||||
| if thinking != "" { | ||||||||
| for i := range comments { | ||||||||
| if comments[i].Thinking == "" { | ||||||||
| comments[i].Thinking = thinking | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| resolveAndCollect := func(rctx context.Context) { | ||||||||
| for i := range comments { | ||||||||
| cm := &comments[i] | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Russian site documentation is missing, use a translator to translate this to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Synced it. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| --- | ||
| title: Tools | ||
| sidebar: | ||
|
|
@@ -89,8 +89,11 @@ | |
| if omitted, the agent injects the file currently under review. The | ||
| agent also injects `path` automatically when the model leaves it out, so | ||
| the model rarely needs to set it explicitly. `thinking` (per-comment) | ||
| captures the model's reasoning and is preserved on the comment but not | ||
| shown in the final review output. | ||
| captures the model's reasoning and is preserved on the comment; OCR | ||
| backfills it from the reasoning content the model emits on the current | ||
| turn (or the turn's message when there is none), and includes it in | ||
| the JSON output (the terminal output does not | ||
| render it). | ||
|
Comment on lines
-92
to
+96
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you applied the suggestion here: https://github.com/alibaba/open-code-review/pull/773/changes#r3740773775 |
||
|
|
||
| > **`thinking` is a runtime-only field.** OCR parses and stores it, but | ||
| > it is deliberately **not** listed in the `code_comment` schema | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,8 +79,8 @@ OCR が行番号を自動計算できるようにします。 | |
| `comments` は配列なので、モデルは 1 回のツール呼び出しで複数のコメントを発行できます。`content` と | ||
| `existing_code` は必須です。`suggestion_code` は任意ですが、提供が推奨されます。`path` はトップレベルの任意の上書きで—— | ||
| 省略すると、agent は現在レビュー中のファイルを注入します。モデルが省略しても agent が自動的に `path` を注入するため、 | ||
| モデルが明示的に設定する必要はほとんどありません。`thinking`(コメントごと)はモデルの推論を捕捉し、コメントに保持されますが、 | ||
| 最終的なレビュー出力には表示されません。 | ||
| モデルが明示的に設定する必要はほとんどありません。`thinking`(コメントごと)はモデルの推論を捕捉し、コメントに保持されます。 | ||
| OCR はモデルが現在のターンで出力した推論内容(推論内容がない場合はそのターンの本文)で自動的に補完し、JSON 出力に含めます(ターミナル出力には表示されません)。 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
|
|
||
| > **`thinking` はランタイム専用フィールドです。** OCR はこれを解析して保存しますが、モデルに渡す | ||
| > `code_comment` schema には意図的に**含めていません**(`tools.json` には `content`、 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,8 +78,8 @@ OCR 自动计算行号。 | |
| `comments` 是数组,因此模型可以在一次工具调用中发出多条评论。`content` 和 | ||
| `existing_code` 必需;`suggestion_code` 可选但建议提供。`path` 是顶层可选覆盖—— | ||
| 省略时,agent 会注入当前评审的文件。即便模型省略,agent 也会自动注入 `path`,因此 | ||
| 模型极少需要显式设置。`thinking`(按评论)捕获模型推理,保留在评论上,但不会 | ||
| 在最终评审输出中显示。 | ||
| 模型极少需要显式设置。`thinking`(按评论)捕获模型推理,保留在评论上;OCR 会用 | ||
| 模型当轮输出的推理内容(无推理内容时用当轮正文)自动回填,并包含在 JSON 输出中(终端输出不渲染)。 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
|
|
||
| > **`thinking` 是运行时专属字段。** OCR 会解析并存储它,但有意**不**把它列入 | ||
| > 给模型的 `code_comment` schema(`tools.json` 中只有 `content`、 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.