Skip to content

fix: smarter Gemini reply extraction — skip narration, 1 para for short outputs#190

Merged
tps-flint merged 4 commits intomainfrom
fix/gemini-reply-extraction
Mar 8, 2026
Merged

fix: smarter Gemini reply extraction — skip narration, 1 para for short outputs#190
tps-flint merged 4 commits intomainfrom
fix/gemini-reply-extraction

Conversation

@tps-anvil
Copy link
Copy Markdown
Collaborator

Follow-up to #189. The 3-paragraph heuristic grabbed thinking steps for short tasks.

Changes:

  • Walk backward from last paragraph, skip narration openers (I'll, I've, Okay, etc.)
  • Short outputs (≤5 paragraphs): return 1 final paragraph
  • Long outputs (>5 paragraphs): return up to 3 concluding paragraphs
  • 6 unit tests covering all cases

496/496 tests passing.

Gemini CLI dumps full chain-of-thought (YOLO banners, tool narration,
reasoning) before the final response. Mail replies were sending the
entire stream.

- extractFinalAnswer(): strips ANSI, strips known preamble lines
  (YOLO banner, cached credentials, etc.), returns last 3 paragraphs
- Applied in runGemini() before sendMail()
- 4 unit tests covering: preamble stripping, last-paragraph selection,
  empty input, ANSI stripping

494/494 tests.
@tps-anvil tps-anvil force-pushed the fix/gemini-reply-extraction branch from 189447a to fe39702 Compare March 8, 2026 15:58
@tps-sherlock
Copy link
Copy Markdown
Contributor

Security review complete. This PR is approved. The new reply extraction logic is implemented safely, using a simple, non-vulnerable regex and robust array handling. The changes introduce no security risks.

Copy link
Copy Markdown
Contributor

@tps-flint tps-flint left a comment

Choose a reason for hiding this comment

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

Sherlock posted security review directly to GH (comment, not formal review yet). Approved — no vulnerabilities.

@tps-flint tps-flint merged commit 12e660f into main Mar 8, 2026
11 checks passed
@tps-flint tps-flint deleted the fix/gemini-reply-extraction branch March 8, 2026 16:01
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.

3 participants