Skip to content

Return concatinated result when streaming is enabled - #1276

Merged
isamu merged 3 commits into
receptron:mainfrom
masap:fix-1275
Jan 30, 2026
Merged

isamu merged 3 commits into
receptron:mainfrom
masap:fix-1275

Conversation

@masap

@masap masap commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #1275.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed streaming text accumulation so streamed chunks are reliably gathered and used in the final reply.
    • Ensured final responses prefer accumulated stream content when present, improving accuracy of streamed interactions.
    • Preserved consistent behavior for non-streamed responses to avoid regressions.
    • Improved handling of mixed streaming/non-streaming cases to maintain response fidelity across modes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The change adds a new concatenatedText parameter to convertOpenAIChatCompletion in the Gemini agent (JS/TS). Streaming handlers now accumulate chunk text into concatenatedText and pass it to the converter on completion; non-streaming paths pass an empty string to preserve prior behavior.

Changes

Cohort / File(s) Summary
Gemini agent core (JS & TS)
llm_agents/gemini_agent/lib/gemini_agent.js, llm_agents/gemini_agent/src/gemini_agent.ts
Updated convertOpenAIChatCompletion signature to (response, concatenatedText, functionCalls, messages, llmMetaData). Streaming path now accumulates chunkText into concatenatedText and forwards it to the converter; non-streaming paths pass "". All call sites updated accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I nibble on chunks and bind them tight,

Hopping bytes together till they’re right,
Streaming bits stitched into one bright thread,
A whole reply from pieces once spread,
Joyful hops — no text left behind!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title contains a typo ('concatinated' instead of 'concatenated') and has been flagged by reviewers, though it accurately describes the main change: returning concatenated results when streaming is enabled. Correct the typo in the title from 'concatinated' to 'concatenated' to match standard spelling and reviewer feedback.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request successfully addresses issue #1275 by implementing concatenatedText parameter to return complete streamed output instead of incomplete data.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the streaming concatenation issue in gemini_agent files without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@llm_agents/gemini_agent/lib/gemini_agent.js`:
- Around line 173-175: The code assigns chunk.text to chunkText and concatenates
it into concatinatedText without guarding against undefined, which can insert
the literal "undefined"; update the logic in gemini_agent.js around the
variables chunkText, finalResponse, and concatinatedText to treat missing text
as an empty string (e.g., set chunkText = chunk.text ?? '' or check typeof
chunk.text === 'string' before concatenation) and only set finalResponse when
appropriate, so undefined chunk.text values are ignored and not concatenated.

In `@llm_agents/gemini_agent/src/gemini_agent.ts`:
- Around line 242-244: The code assigns chunk to finalResponse and appends
chunk.text to concatinatedText without guarding for undefined, causing the
literal "undefined" to appear; update the logic around chunk, chunkText,
finalResponse and concatinatedText so you normalize chunkText to an empty string
when chunk.text is undefined (e.g., use chunk.text ?? '' or a typeof check) and
only append the normalized value to concatinatedText; keep the finalResponse =
chunk assignment as-is if needed but ensure concatenation uses the safe
chunkText variable.
🧹 Nitpick comments (2)
llm_agents/gemini_agent/src/gemini_agent.ts (2)

57-64: Typo in parameter name: concatinatedText → concatenatedText.

The variable name has a spelling error ("concatinated" instead of "concatenated"). While functional, this affects code readability and searchability.


235-235: Add missing semicolons for consistency.

Lines 235 and 244 are missing semicolons, which is inconsistent with the rest of the file that uses them consistently.

Proposed fix
-    let concatinatedText = ''
+    let concatinatedText = '';
-      concatinatedText += chunkText
+      concatinatedText += chunkText;

Also applies to: 244-244

@isamu
isamu requested a review from ystknsh January 29, 2026 02:49
@isamu

isamu commented Jan 30, 2026

Copy link
Copy Markdown
Member

Please fix the typo that coderabbitai pointed out: concatinated → concatenated

Signed-off-by: Masashi Honma <[email protected]>
@masap

masap commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

@isamu Thank you for comment. Fixed.

@isamu

isamu commented Jan 30, 2026

Copy link
Copy Markdown
Member

Thank you for your pull request!!

@isamu
isamu merged commit e0928bf into receptron:main Jan 30, 2026
@masap
masap deleted the fix-1275 branch January 30, 2026 04:55
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.

Return concatinated result when streaming is enabled

2 participants