fix: only load project context (CODEACTOR.md/CLAUDE.md) on first conv…#50
Merged
Conversation
…ersation per session Previously, loadProjectContext() was called on every ConductorAgent.Run() invocation, injecting hundreds of lines of repository knowledge files into the LLM system prompt for every follow-up chat in the same taskID session. This wasted significant tokens. Changes: - Add cachedProjectContext field to ConductorAgent struct for I/O caching - Add early-return check in loadProjectContext() if cache exists - Cache result after first disk read in loadProjectContext() - Wrap project context injection in Run() with condition: only inject when memory is empty (first conversation); skip on follow-up chats
Reviewer's GuideThis PR tweaks the TUI tool-call rendering to add thin borders around completed tool call headers, introduces reusable border helpers, caches project context so it is only loaded and injected into the system prompt once per conversation, and filters out .git directory events from the codebase watcher, while also removing the DevOps-Agent docs from the READMEs. Sequence diagram for project context loading on first conversationsequenceDiagram
actor User
participant ConductorAgent
participant Memory as MemoryConversation
participant FS as FileSystem
participant Publisher
participant LLM as LLMEngine
User->>ConductorAgent: Run(ctx, input, mem)
ConductorAgent->>Memory: GetMessages()
Memory-->>ConductorAgent: messages (len == 0)
alt first_conversation_turn
ConductorAgent->>ConductorAgent: loadProjectContext()
alt cachedProjectContext is nil
ConductorAgent->>FS: read CODEACTOR.md / CLAUDE.md / AGENTS.md
FS-->>ConductorAgent: contents
ConductorAgent->>ConductorAgent: build Content and LoadedFiles
ConductorAgent->>ConductorAgent: cache in cachedProjectContext
else cachedProjectContext already set
ConductorAgent-->>ConductorAgent: reuse cachedProjectContext
end
ConductorAgent->>Publisher: Publish(context_loaded, loadResult, Name())
ConductorAgent->>ConductorAgent: prepend project context to systemPrompt
else followup_conversation_turn
ConductorAgent-->>ConductorAgent: skip loadProjectContext()
end
ConductorAgent->>LLM: send messages with systemPrompt
LLM-->>ConductorAgent: response
ConductorAgent-->>User: reply
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
setup_watcher, the.gitfilter currently checks components for exact equality with.git; if you expect nested worktrees or alternative Git directories, consider making this filter more robust (e.g., checking for.gitdirectories via metadata or a configurable ignore list) so you don’t inadvertently miss or over-filter events. - The
makeBorderLinehelper is currently only invoked with the'─'character and its comment mentions half-block characters; either update the comment to match the actual usage or allow callers to pass a half-block rune so the intent and implementation stay aligned.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `setup_watcher`, the `.git` filter currently checks components for exact equality with `.git`; if you expect nested worktrees or alternative Git directories, consider making this filter more robust (e.g., checking for `.git` directories via metadata or a configurable ignore list) so you don’t inadvertently miss or over-filter events.
- The `makeBorderLine` helper is currently only invoked with the `'─'` character and its comment mentions half-block characters; either update the comment to match the actual usage or allow callers to pass a half-block rune so the intent and implementation stay aligned.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 by Sourcery
Cache project context loading per session and adjust when it is injected into the system prompt, refine TUI tool call rendering with bordered headers, and ignore .git changes in the codebase watcher while removing DevOps-Agent docs from the READMEs.
Enhancements:
Documentation: