Skip to content

Bound repository context size in load_repo_context #24

Description

@coderabbitai

Summary

Add bounded Markdown context loading to repo_router.py so repository context passed to the LLM has predictable size.

Rationale

load_repo_context() currently reads baseline and intent-matched .agent/**/*.md files in full. Categorizing the query reduces the number of selected files, but a single large selected file can still consume the prompt budget, increase latency, and cause the user query or relevant context to be truncated.

Affected area

  • repo_router.py
  • load_repo_context()

Required changes

  • Introduce a shared capped-read helper for Markdown context files.
  • Apply a per-file content limit to operational data, architecture, core context, and instruction files.
  • Enforce an overall context-size budget while appending sections.
  • Preserve the existing intent-based selection and error logging behavior.
  • Mark truncated content clearly in the assembled context.

Acceptance criteria

  • No individual Markdown context file can exceed the configured per-file cap in the LLM context.
  • The assembled repository context cannot exceed a configured total budget.
  • Existing README truncation remains consistent with the shared limit strategy.
  • The existing routing and intent-selection behavior remains unchanged.

Backlinks

Requested by @kpj2006.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions