Skip to content

feat: blind second-opinion tool for independent cross-model review#91

Open
jamubc wants to merge 1 commit into
mainfrom
feat/blind-second-opinion
Open

feat: blind second-opinion tool for independent cross-model review#91
jamubc wants to merge 1 commit into
mainfrom
feat/blind-second-opinion

Conversation

@jamubc

@jamubc jamubc commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a second-opinion tool (category gemini) that obtains an independent Gemini answer to a problem without exposing any existing analysis, removing anchoring bias from multi-pass review. An optional follow-up call then compares the two independent answers and surfaces agreements and points of divergence.

Design

  • Anti-anchoring is statically enforced: buildSolvePrompt(problem) takes only the problem — there is no parameter through which an existing answer could reach the independent solve call.
  • The comparison step runs only after the independent solve completes, and only when ownAnswer is supplied with compare: true (the default).
  • The tool is constructed via a factory that accepts an injected executor, so the invariant is verified hermetically without spawning a subprocess.

Files

  • src/utils/secondOpinion.ts — pure prompt-building / formatting helpers
  • src/tools/second-opinion.tool.ts — the tool + injectable factory
  • test/unit/tools/second-opinion.test.ts — 15 tests, including the sentinel test that captures every prompt sent to the executor and asserts the supplied answer never appears in the solve call
  • docs/usage/second-opinion.md

Verification

  • npx tsc --noEmit — clean
  • node scripts/run-tests.mjs unit integration — 74 pass / 0 fail

Notes

  • Opt-in: a new tool; no existing behavior changes.
  • Two sequential Gemini calls when comparing; model: gemini-2.5-flash is available for constrained quota.

Introduces the second-opinion tool (category: gemini) that sends a problem
to Gemini without exposing any existing answer, then optionally compares the
independent result with the orchestrator's own answer to surface agreements
and divergences.

Anti-anchoring guarantee is statically enforced: buildSolvePrompt accepts
only problem (single-arg signature), making it a TypeScript compile error to
accidentally pass an existing answer into the solve call. Injected-executor
support makes the invariant hermetically testable without spawning subprocesses.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the second-opinion tool, which obtains a blind, independent Gemini answer to a problem to prevent anchoring bias, with an optional comparison step to highlight points of divergence. It includes implementation files, prompt utilities, comprehensive unit tests, and documentation. The review feedback suggests improving code consistency by utilizing the newly defined SECOND_OPINION_MESSAGES constants in the tool implementation instead of generic status messages or hardcoded strings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

buildComparePrompt,
formatResult,
} from '../utils/secondOpinion.js';
import { STATUS_MESSAGES } from '../constants.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since you defined specific messages for the second-opinion tool in SECOND_OPINION_MESSAGES within src/constants.ts, you should import and use them here instead of importing the generic STATUS_MESSAGES.

Suggested change
import { STATUS_MESSAGES } from '../constants.js';
import { SECOND_OPINION_MESSAGES } from '../constants.js';

Comment on lines +75 to +79
if (!problemStr.trim()) {
throw new Error(
'A non-empty problem description is required for the second-opinion tool.'
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the defined constant SECOND_OPINION_MESSAGES.NO_PROBLEM_PROVIDED instead of hardcoding the error message string.

      if (!problemStr.trim()) {
        throw new Error(SECOND_OPINION_MESSAGES.NO_PROBLEM_PROVIDED);
      }

const solvePrompt = buildSolvePrompt(problemStr);

Logger.debug('second-opinion: requesting independent solution');
onProgress?.(STATUS_MESSAGES.PROCESSING_START);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the specific SECOND_OPINION_MESSAGES.SOLVE_START status message instead of the generic STATUS_MESSAGES.PROCESSING_START.

Suggested change
onProgress?.(STATUS_MESSAGES.PROCESSING_START);
onProgress?.(SECOND_OPINION_MESSAGES.SOLVE_START);


if (ownAnswerStr && compare) {
Logger.debug('second-opinion: performing divergence comparison');
onProgress?.('Comparing answers for points of divergence...');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the defined constant SECOND_OPINION_MESSAGES.COMPARE_START instead of hardcoding the progress message string.

Suggested change
onProgress?.('Comparing answers for points of divergence...');
onProgress?.(SECOND_OPINION_MESSAGES.COMPARE_START);

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.

2 participants