diff --git a/.github/workflows/reusable-gemini-review.yml b/.github/workflows/reusable-gemini-review.yml index 166db8f0d4..d7348d64f7 100644 --- a/.github/workflows/reusable-gemini-review.yml +++ b/.github/workflows/reusable-gemini-review.yml @@ -433,9 +433,9 @@ jobs: FOOTER="\n\n---\n#### 🤖 [Gemini Manual Trigger Guide](${{ github.server_url }}/${{ github.repository }}/blob/leader/docs/workflows/MANUAL_TRIGGERS.md)" # Extract the new thought signature if present - NEW_THOUGHT_SIG=$(jq -r '.thoughtSignature // empty' review_result.json) + NEW_THOUGHT_SIG=$(jq -r '.thoughtSignature // ""' review_result.json) SIG_MARKER="" - if [ -n "$NEW_THOUGHT_SIG" ]; then + if [[ -n "$NEW_THOUGHT_SIG" && "$NEW_THOUGHT_SIG" != "null" ]]; then SIG_MARKER="\n\n" fi diff --git a/scripts/decide-review-strategy.sh b/scripts/decide-review-strategy.sh index a9a64bdd80..bf512c0ed8 100755 --- a/scripts/decide-review-strategy.sh +++ b/scripts/decide-review-strategy.sh @@ -132,7 +132,7 @@ else SKIP_REASON="" else # Extract thought signature if present - THOUGHT_SIG=$(echo "$LAST_COMMENT_BODY" | grep -oP '(?<=)' | head -n 1 || echo "") + THOUGHT_SIG=$(echo "$LAST_COMMENT_BODY" | grep -oP ')' | head -n 1) if [ -n "$THOUGHT_SIG" ]; then echo "::info::Extracted thought signature from last review." echo "thought-signature=$THOUGHT_SIG" >> "$GITHUB_OUTPUT" diff --git a/scripts/gemini-client.ts b/scripts/gemini-client.ts index 69ba40adc2..d22c2e94c9 100644 --- a/scripts/gemini-client.ts +++ b/scripts/gemini-client.ts @@ -25,10 +25,6 @@ const outputFile = getArg('--output') const preset = getArg('--preset') const instructions = getArg('--instructions') -// List of models to try in order. -// The first model in the list is the primary model, and the rest are fallbacks. - -// UPDATED: Aligned with latest model recommendations (Q1 2026+) const defaultFallbacks = [ 'gemini-3.1-flash-lite-preview', 'gemini-2.5-flash', @@ -314,6 +310,8 @@ async function main() { } } +type ExtendedGenerateContentRequest = GenerateContentRequest & { thought_signature?: string }; + export async function generateContentWithFallback({ genAI, prompt, @@ -330,14 +328,10 @@ export async function generateContentWithFallback({ for (const modelName of MODEL_FALLBACKS) { try { const model = genAI.getGenerativeModel({ model: modelName }) - const request: any = { + const request: ExtendedGenerateContentRequest = { contents: [{ role: 'user', parts: [{ text: prompt }] }], ...config, - } - - // Implement thought signature circulation if provided - if (thoughtSignature) { - request.thought_signature = thoughtSignature + ...(thoughtSignature && { thought_signature: thoughtSignature }) } const result = await model.generateContent(request) @@ -346,11 +340,7 @@ export async function generateContentWithFallback({ const text = result.response.text() // Capture thought signature from the response if present - const candidate = result.response.candidates?.[0] - const capturedSignature = - candidate && 'thought_signature' in candidate - ? (candidate as any).thought_signature - : undefined + const capturedSignature = (result.response.candidates?.[0] as any)?.thought_signature return { text, thoughtSignature: capturedSignature } } catch (error: unknown) { diff --git a/scripts/identify-tech-debt.ts b/scripts/identify-tech-debt.ts index 812130dd0f..61c82c73f4 100644 --- a/scripts/identify-tech-debt.ts +++ b/scripts/identify-tech-debt.ts @@ -93,7 +93,7 @@ export async function main() { const prompt = promptTemplate.replace('{{diff}}', processedDiff) - const rawResponse = await generateContentWithFallback({ + const { text: rawResponse } = await generateContentWithFallback({ genAI, prompt, config: {