fix: reuse parent system prompt for background review to preserve cache bytes - #25330
Closed
NeroNarada wants to merge 4 commits into
Closed
fix: reuse parent system prompt for background review to preserve cache bytes#25330NeroNarada wants to merge 4 commits into
NeroNarada wants to merge 4 commits into
Conversation
Collaborator
|
This PR appears to be superseded by #25332, which contains all changes from this PR plus additional gateway session cleanup and tool-defs cache cap fixes. Additionally, #17276 is an existing open PR addressing the same background review prompt cache issue (#25322). Consider closing in favor of #25332. |
Author
|
Superseded by #25332, which carries the same intent plus gateway session cleanup/tool-defs cache cap fixes. Keeping only the broader follow-up. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Background self-improvement review currently builds a new
AIAgentwith a freshlygenerated system prompt, which can differ from the parent agent and break prefix
cache / preprocessing tree-dedup behavior. This change reuses the parent’s
already-built system prompt when spawning the review agent, while keeping the
review toolset restricted to
memory/skills.Changes
cached_system_prompt: Optional[str] = NonetoAIAgent.__init__.self._cached_system_promptfrom that value during initialization._spawn_background_review, pass:session_id=self.session_idpass_session_id=self.pass_session_idcached_system_prompt(from parent cache, or built lazily if absent)enabled_toolsets=["memory", "skills"]unchanged.Motivation
This preserves byte-identical prompt bytes across the parent/review boundary
without relaxing the tool-restriction safety model from #15204.
Issue