Skip to content

fix(voice): long summaries were cut off; cap before the spoken rewrite - #84

Merged
DowLucas merged 1 commit into
mainfrom
fix/voice-summary-truncation
Oct 7, 2026
Merged

DowLucas merged 1 commit into
mainfrom
fix/voice-summary-truncation

Conversation

@DowLucas

@DowLucas DowLucas commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Summary

Two truncations, seen on production right after #83:

  1. long reply summaries stopped mid-word ("…summaries will take about one hundred"). Gemini 2.5 Flash's thinking tokens count against maxOutputTokens (1024). Voice summaries now run with thinking off where the model allows it (thinkingBudget: 0 on 2.5 Flash, via a new optional callGemini option), and the cap is 4096 elsewhere.
  2. normal summaries ended in a stray "." ("…especially for."). The word cap ran after speakable(), whose expansions ("5s" → "5 seconds", "0.25.1" → "0 point 25 point 1") pushed a summary that was within its limit over the cap. Now toSpokenText caps the model's own words first, and speakable() runs after.
    • toSpokenText keeps underscores inside words, so identifiers still reach speakable().
    • An announcement whose rewrite would outgrow one voice-audio request (440 chars) keeps the un-rewritten text, so it never falls back to the local voice.

Also strips an echoed Project: label, and the prompts ask for the project name without one.

Measured with the real model (gemini-2.5-flash, prod key)

6 summaries (short/normal/long × 2): all complete, 18–73 words, no label, 0.6–1.0 s each (was ~3.4 s with thinking).

Test plan

  • bun test speakable + voiceSummary + routes/voice + ai: 183 pass (new: underscore and label handling, thinking budget per model).
  • tsc: 34 errors both before and after this change.

🤖 Generated with Claude Code

Two truncations, both visible on production right after #83:
- `long` reply summaries stopped mid-word ("...about one hundred"): Gemini
  2.5 Flash's thinking tokens count against maxOutputTokens (1024). Voice
  summaries now run with thinking off on 2.5 Flash (thinkingBudget 0) and
  a 4096 cap elsewhere; measured 0.6-1 s instead of ~3.4 s.
- `normal` summaries ended in a stray "." mid-sentence: the word cap ran
  after speakable(), whose expansions ("5s" -> "5 seconds", versions)
  pushed a within-limit summary over it. Now toSpokenText caps the model's
  own words first and speakable() runs after; toSpokenText keeps intra-word
  underscores so identifiers still reach speakable(). An announcement that
  would outgrow one voice-audio request keeps the un-rewritten text.
Also strips an echoed "Project:" label and tells the model not to use one.

callGemini accepts an optional thinkingBudget.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8be3311d-fc63-460a-a43c-45ecb2b5699c
📥 Commits

Reviewing files that changed from the base of the PR and between 19a410d and c12ae4f.

📒 Files selected for processing (4)
  • packages/backend/src/ai/gemini.ts
  • packages/backend/src/routes/voice.ts
  • packages/backend/src/services/__tests__/voiceSummary.test.ts
  • packages/backend/src/services/voiceSummary.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DowLucas
DowLucas merged commit 53a57f5 into main Oct 7, 2026
6 checks passed
@DowLucas
DowLucas deleted the fix/voice-summary-truncation branch October 7, 2026 11:05
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.

1 participant