Skip to content

feat(llmloop): backfill comment thinking from turn output - #773

Open
yingjiexu2002 wants to merge 1 commit into
alibaba:mainfrom
yingjiexu2002:feat/comment-thinking-backfill
Open

feat(llmloop): backfill comment thinking from turn output#773
yingjiexu2002 wants to merge 1 commit into
alibaba:mainfrom
yingjiexu2002:feat/comment-thinking-backfill

Conversation

@yingjiexu2002

Copy link
Copy Markdown
Contributor

Description

Comments parsed from code_comment tool calls have a runtime-only thinking field that most models never populate (it is deliberately not advertised in the tool schema). This PR backfills it from the model's output of the current turn, so --format json output carries the review reasoning:

  • Add ChatResponse.ReasoningContent() to expose the native reasoning content of a response (OpenAI reasoning_content in both streaming and non-streaming paths; Anthropic thinking blocks).
  • In the agent loop, compute the turn's thinking text as reasoning content, falling back to the assistant message for models that do not expose reasoning, and backfill it into each collected comment whose thinking is empty. Explicit model-provided thinking always wins.
  • Terminal output is unchanged (renderComment does not render thinking); only the JSON output gains the field.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Added unit tests: backfill uses the turn's thinking text when a comment has no explicit thinking; explicit thinking is preserved; no backfill when the turn has no thinking text. Also verified end-to-end with a local review run (--format json) against providers with and without native reasoning output.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

Related Issues

N/A

… message

Expose ChatResponse.ReasoningContent and backfill per-comment thinking
with the current turn's reasoning content, falling back to the assistant
message for models that do not expose reasoning, so --format json output
carries thinking even when the model omits it.
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant