Skip to content

fix: only load project context (CODEACTOR.md/CLAUDE.md) on first conv…#50

Merged
iohub merged 4 commits into
mainfrom
feat-openai-go
May 7, 2026
Merged

fix: only load project context (CODEACTOR.md/CLAUDE.md) on first conv…#50
iohub merged 4 commits into
mainfrom
feat-openai-go

Conversation

@iohub
Copy link
Copy Markdown
Owner

@iohub iohub commented May 7, 2026

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:

  • Cache project workspace context files in the Conductor agent so they are loaded only once per session and injected only on the first conversation turn.
  • Update TUI tool call rendering to draw subtle borders around completed tool call headers while leaving running calls and bodies unbordered.
  • Filter file watcher events in the code analysis service to ignore changes originating from the .git directory.

Documentation:

  • Remove DevOps-Agent documentation sections from both English and Chinese READMEs.

iohub added 4 commits May 7, 2026 07:22
…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
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 7, 2026

Reviewer's Guide

This 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 conversation

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Add bordered headers for completed tool calls in the TUI and introduce reusable border helpers/styles.
  • Adjust RenderToolLine so early and running states remain borderless while successful tool calls get bordered headers.
  • Ensure tools with skipped bodies still render within bordered headers.
  • Wrap headers with new addToolCallBorders helper and keep bodies outside the border.
  • Introduce ToolCallBorderTop/Bottom styles and a makeBorderLine helper for compact border lines.
internal/tui/render.go
internal/tui/styles.go
Cache project context loading and only inject project context into the system prompt on the first conversation turn.
  • Add cachedProjectContext field to ConductorAgent to store the first load result.
  • Update loadProjectContext to short-circuit on cached results and to cache newly loaded content.
  • Gate project context injection in Run so it only happens when there are no prior conversation messages (first turn).
internal/agents/conductor.go
Ignore file change events coming from the .git directory in the codebase watcher.
  • Add filtering logic in the watcher to skip events whose paths include a .git component before queueing re-analysis.
codebase/src/http/handlers/mod.rs
Remove DevOps-Agent documentation sections from English and Chinese READMEs.
  • Delete DevOps-Agent section and its configuration/disable instructions from README.md.
  • Delete DevOps-Agent section and its configuration/disable instructions from README_zh.md.
README.md
README_zh.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@iohub iohub merged commit 9f94e5b into main May 7, 2026
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant