🤖 perf: reuse instruction sources during stream startup - #3951
Open
yanncabral wants to merge 1 commit into
Open
Conversation
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
Load structured instruction sources once during stream startup and reuse that snapshot for both system-message assembly and tool-scoped instruction extraction. Existing
buildSystemMessage()andreadToolInstructions()wrappers remain available for callers that need load-and-build behavior.Background
Stream startup previously loaded the same AGENTS.md/instruction sources while building the system message, then loaded them again while extracting tool instructions. Besides duplicate I/O, the two consumers could observe different file contents if instructions changed between reads.
Implementation
InstructionSourcesvaluebuildStreamSystemContext()and reuse it for tool extractionValidation
extractToolInstructionsFromSourceswas not exportedbun test src/node/services/systemMessage.test.ts src/node/services/streamContextBuilder.test.ts src/node/services/aiService.test.ts --timeout 30000— 150 passedbun run tsgo --noEmit -p tsconfig.main.json— passedgit diff --check— passedmake typecheckattempted: main-process typecheck passed, broad renderer typecheck was SIGKILL/OOMRisks
The change touches startup context plumbing. Regression coverage retains the existing system-message matrix for sub-project, multi-project, global/compat, local, model/mode, Xum-only, and tool-scoped semantics, and asserts identity reuse at the AI service boundary.
Generated with
xum• Model:openai:gpt-5.6-sol• Thinking:medium• Cost:unknown