Skip to content

Conversation

@gundermanc
Copy link
Member

@gundermanc gundermanc commented Dec 31, 2025

Summary

Finishes wiring up systemMessage and additionalContext fields from the SessionStart hook.

Now you can inject context and info messages into the history using a SessionStart hook.

image

Details

Related Issues

Fixes #15413.

How to Validate

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gundermanc, 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 introduces a significant enhancement by enabling the SessionStart hook to inject contextual information directly into the model's input and display system messages. This functionality allows for greater extensibility, letting external hooks dynamically influence the initial conversation state and user experience across both the command-line interface and the interactive UI.

Highlights

  • Context Injection via SessionStart Hook: The SessionStart hook can now return additionalContext and systemMessage as part of its output, allowing external logic to influence the initial state of a session.
  • CLI Integration: In the command-line interface, any additionalContext returned by the SessionStart hook is prepended to the model's input, and systemMessage is displayed in stderr.
  • UI Integration: For the interactive UI, additionalContext is added to the chat history as a user message, and systemMessage is shown as an informational message.
  • Improved Hook Output Handling: The fireSessionStartHook function now returns a structured output object, enabling calling components to react to the hook's decisions and any injected data.
  • Test Coverage: A new integration test has been added to validate the end-to-end functionality of context injection and system message display via the SessionStart hook.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
Copy link

github-actions bot commented Dec 31, 2025

Size Change: +1.5 kB (+0.01%)

Total Size: 22.2 MB

Filename Size Change
./bundle/gemini.js 22.2 MB +1.5 kB (+0.01%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 successfully implements context injection via the SessionStart hook. The changes are well-structured, covering both non-interactive and interactive modes. In non-interactive mode, context is correctly prepended to the input, and in interactive mode, it's added to the conversation history. The addition of a comprehensive integration test validates the new functionality effectively. A notable improvement is the change to wrap the FakeContentGenerator with LoggingContentGenerator, which enhances testability by allowing API request inspection even with fake responses. Overall, the implementation is robust and the code quality is high.

@gundermanc gundermanc force-pushed the gundermanc/session-start-hook branch 2 times, most recently from 5ab9c61 to 935dccd Compare January 2, 2026 17:15
@gundermanc gundermanc force-pushed the gundermanc/session-start-hook branch from fcd35b0 to 1af770f Compare January 2, 2026 17:36
@gundermanc gundermanc marked this pull request as ready for review January 2, 2026 20:07
@gundermanc gundermanc requested a review from a team as a code owner January 2, 2026 20:07
// item, including the ones from the start session hook will cause a
// re-render and an error when we try to reload config.
//
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member Author

Choose a reason for hiding this comment

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

One thing I want to call out is that our use of useEffect() for first-time initialization is pretty brittle and possible bad practice, though I'm not a react expert.

  • We load the config inside of the useEffect()
  • Config expects to only get loaded once, so if the use effect runs multiple times, it causes an error.
  • Adding the new item to history with historyManager trips a linter error that wants us to include historyManager in the dependency array.
  • Doing so causes us to react to the addItem() call, causing the useEffect() to run again immediately after the first time.

For now I'm just excluding the historyManager from the dependencies because I think we're really just trying to cause a side effect here, not cause a redundant repaint, but I think we should rethink this in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

cc @jacob314, @scidomino do either of you have any insights?

if (result?.systemMessage) {
context.ui.addItem(
{
type: MessageType.INFO,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should have a new message type for information like this. Right now we utilize this for "updates pending" or "warning xyz", it's a bit of everything.

Don't block on this comment (i.e. can always do in another PR) but food for thought. It's worth putting out a parallel feeler to UX folks to see their take.

Date.now(),
);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this also be adding a message to history post-clear?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, great catch!

@gundermanc gundermanc added this pull request to the merge queue Jan 5, 2026
Merged via the queue into main with commit 6d1e276 Jan 5, 2026
20 checks passed
@gundermanc gundermanc deleted the gundermanc/session-start-hook branch January 5, 2026 21:43
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.

SessionStart does not support context injection via additionalContext

2 participants