feat(core): inject memory and JIT context into subagents#23032
Conversation
Summary of ChangesHello, 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 enhances the Highlights
Using Gemini Code AssistThe 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
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 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. Footnotes
|
|
Size Change: +506 B (0%) Total Size: 26.2 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request aims to align subagent memory injection with the main agent's architecture. However, it introduces a critical prompt injection vulnerability: memory content from workspace files is injected into the prompt wrapped in XML-like tags without proper sanitization, allowing potential tag escaping. Additionally, there's an inconsistency in how environment memory is handled when JIT context is disabled, diverging from the main agent's architecture.
|
/gemini review I want to maintain the exact way the main agent injects this context for now. Further tag cleaning should be a separate task |
There was a problem hiding this comment.
Code Review
This pull request aligns sub-agent context injection with the main agent's architecture by injecting environment and JIT context. However, it introduces several prompt injection vectors where untrusted data from project files, extensions, and background processes is injected into LLM prompts without sanitization. This allows an attacker to use tag escaping to break out of the context and execute arbitrary instructions, which is particularly dangerous given the agent's access to system tools like the shell. Additionally, there's a potential issue with context duplication when JIT is disabled, which seems to be a pre-existing pattern that this PR propagates.
Summary
Injects environment memory (GEMINI.md and AGENT.md context) and JIT context support into subagent execution loops to align with main agent context injection architecture.
Details
LocalAgentExecutor.buildSystemPromptto appendgetSystemInstructionMemory()into the global SI.LocalAgentExecutor.runto inject Tier 2 memory (Project/Extension) into the initial turn's message array part using formatted tags<loaded_context>.local-executor.test.tsto verify prompt strings with memory flags loaded and JIT flag variations.Related Issues
N/A
How to Validate
npm run test -w @google/gemini-cli-core -- src/agents/local-executor.test.tsPre-Merge Checklist