Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/reusable-gemini-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<!-- thought_signature: ${NEW_THOUGHT_SIG} -->"
fi

Expand Down
2 changes: 1 addition & 1 deletion scripts/decide-review-strategy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ else
SKIP_REASON=""
else
# Extract thought signature if present
THOUGHT_SIG=$(echo "$LAST_COMMENT_BODY" | grep -oP '(?<=<!-- thought_signature: )[a-zA-Z0-9+/=]+(?= -->)' | head -n 1 || echo "")
THOUGHT_SIG=$(echo "$LAST_COMMENT_BODY" | grep -oP '<!-- thought_signature: \K[a-zA-Z0-9+/=]+(?= -->)' | head -n 1)
if [ -n "$THOUGHT_SIG" ]; then
echo "::info::Extracted thought signature from last review."
echo "thought-signature=$THOUGHT_SIG" >> "$GITHUB_OUTPUT"
Expand Down
20 changes: 5 additions & 15 deletions scripts/gemini-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -314,6 +310,8 @@ async function main() {
}
}

type ExtendedGenerateContentRequest = GenerateContentRequest & { thought_signature?: string };

export async function generateContentWithFallback({
genAI,
prompt,
Expand All @@ -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)
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/identify-tech-debt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading