Skip to content

cache-transcript-turn-indexes - #29516

Open
harshitgupta31415 wants to merge 1 commit into
google-gemini:mainfrom
harshitgupta31415:cache-transcript-turn-indexes
Open

harshitgupta31415 wants to merge 1 commit into
google-gemini:mainfrom
harshitgupta31415:cache-transcript-turn-indexes

Conversation

@harshitgupta31415

Copy link
Copy Markdown

Cache turn indexes in a Map instead of calling indexOf() for every node. Relative turn labels and transcript text stay unchanged.

A local synthetic benchmark with 10,000 text nodes and unique turns went from 414.20 ms to 17.91 ms. This measures formatting only.

25 related tests, ESLint, formatting and core typecheck passed. Full preflight is still pending.

Fixes #29514.

@harshitgupta31415
harshitgupta31415 requested a review from a team as a code owner September 26, 2026 09:35
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request optimizes the transcript formatting logic by caching turn indexes in a Map. This change reduces the computational complexity of formatting nodes for LLMs, resulting in a substantial performance improvement for large datasets while maintaining existing behavior for turn labels and transcript text.

Highlights

  • Performance Optimization: Replaced the O(n) indexOf() lookup with an O(1) Map lookup for turn indexes, significantly improving formatting speed for large node sets.
  • Test Coverage: Added new test cases to verify turn numbering with repeated/empty IDs, empty histories, and scenarios where turn markers should be omitted.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions github-actions Bot added the size/s A small PR label Sep 26, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 49
  • Additions: +47
  • Deletions: -2
  • Files changed: 2

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request optimizes the formatNodesForLlm utility by caching turn indices in a Map to avoid repeated indexOf lookups, improving performance. Additionally, new unit tests have been added to verify turn numbering behavior with repeated or empty turn IDs, as well as handling of empty histories. There are no review comments, and I have no feedback to provide.

@gemini-cli gemini-cli Bot added area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality priority/p3 Backlog - a good idea but not currently a priority. labels Sep 26, 2026
@gemini-cli

gemini-cli Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality priority/p3 Backlog - a good idea but not currently a priority. size/s A small PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cache-transcript-turn-indexes

1 participant