feat: blind second-opinion tool for independent cross-model review#91
feat: blind second-opinion tool for independent cross-model review#91jamubc wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
| import { STATUS_MESSAGES } from '../constants.js'; | |
| import { SECOND_OPINION_MESSAGES } from '../constants.js'; |
| if (!problemStr.trim()) { | ||
| throw new Error( | ||
| 'A non-empty problem description is required for the second-opinion tool.' | ||
| ); | ||
| } |
| const solvePrompt = buildSolvePrompt(problemStr); | ||
|
|
||
| Logger.debug('second-opinion: requesting independent solution'); | ||
| onProgress?.(STATUS_MESSAGES.PROCESSING_START); |
|
|
||
| if (ownAnswerStr && compare) { | ||
| Logger.debug('second-opinion: performing divergence comparison'); | ||
| onProgress?.('Comparing answers for points of divergence...'); |
Summary
Adds a
second-opiniontool (categorygemini) 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
buildSolvePrompt(problem)takes only the problem — there is no parameter through which an existing answer could reach the independent solve call.ownAnsweris supplied withcompare: true(the default).Files
src/utils/secondOpinion.ts— pure prompt-building / formatting helperssrc/tools/second-opinion.tool.ts— the tool + injectable factorytest/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 calldocs/usage/second-opinion.mdVerification
npx tsc --noEmit— cleannode scripts/run-tests.mjs unit integration— 74 pass / 0 failNotes
model: gemini-2.5-flashis available for constrained quota.