Fix extended thinking and allow per-repo context files (AGENTS.md, CLAUDE.md, etc.) to be included as context#2387
Conversation
Review Summary by QodoSupport Claude model overrides and repository context files in AI prompts
WalkthroughsDescription• Add support for overriding Claude extended thinking models via config • Include repository context files (AGENTS.md, CLAUDE.md, etc.) in AI prompts • Extend git provider interface with repo file content retrieval capability • Add comprehensive tests for new features and fix minor code issues Diagramflowchart LR
A["Config Settings"] -->|claude_extended_thinking_models_override| B["LiteLLM Handler"]
C["Repo Context Files"] -->|repo_context_files config| D["build_repo_context"]
D -->|fetches files| E["Git Provider"]
D -->|renders context| F["Instruction Files"]
F -->|injected into| G["AI Prompts"]
B -->|uses models| G
File Changes1. pr_agent/algo/__init__.py
|
Code Review by Qodo
Context used 1. claude_extended_thinking_models_override undocumented
|
|
Persistent review updated to latest commit 2b313ad |
2b313ad to
50de2c6
Compare
|
Persistent review updated to latest commit 50de2c6 |
50de2c6 to
e93cad2
Compare
|
Persistent review updated to latest commit e93cad2 |
|
Hey, could you adjust your implementation for Gitea in I made it manually for now, but I think it would be interesting to include it in this PR as well. |
done! |
aae35a9 to
2e11c1f
Compare
|
Persistent review updated to latest commit 2e11c1f |
|
Persistent review updated to latest commit 145b93f |
|
Persistent review updated to latest commit a92f7b3 |
|
Persistent review updated to latest commit 982821f |
982821f to
817fa77
Compare
|
Persistent review updated to latest commit 817fa77 |
817fa77 to
f30a860
Compare
|
Code review by qodo was updated up to the latest commit f30a860 |
|
Code review by qodo was updated up to the latest commit 5dde4dc |
|
/describe |
|
PR Description updated to latest commit (5dde4dc)
|
5dde4dc to
92189c3
Compare
|
Code review by qodo was updated up to the latest commit 92189c3 |
92189c3 to
ca612dc
Compare
|
Code review by qodo was updated up to the latest commit ca612dc |
|
Hey @avidspartan1, Can you please rebase onto main and resolve the leftover Qodo comments? 🙏 |
ca612dc to
b7c6a5c
Compare
Looking for bugs?Check back in a few minutes. Qodo's review agents are on it. |
Thanks, @naorpeled! I've prioritized the "Action required" comments from the review, but left the "Review recommended". I think I've pushed quite a few times, so PR Agent has been generating a lot of comments. 😆 If you'd like me to resolve all of them I can give that a shot; I'm just afraid of introducing too many changes / scope creep from my original goals. Let me know! |
| <<<<<<< feat/improvements | ||
| target_file = file | ||
| break | ||
| ======= | ||
| if file.filename == relevant_file: | ||
| target_file = file | ||
| break | ||
| if target_file is None: | ||
| get_logger().warning(f"Skipping suggestion: file '{relevant_file}' not found in diff") | ||
| continue | ||
| >>>>>>> main |
There was a problem hiding this comment.
1. Merge conflict markers committed 📘 Rule violation ≡ Correctness
Unresolved Git merge conflict markers (<<<<<<<, =======, >>>>>>>) were committed into pr_agent/git_providers/gitlab_provider.py within publish_code_suggestions(), leaving the file in an invalid/ambiguous state. This makes the module syntactically invalid, breaking imports and potentially crashing runtime paths and CI linting/testing.
Agent Prompt
## Issue description
Resolve the committed merge conflict in `pr_agent/git_providers/gitlab_provider.py` where `publish_code_suggestions()` still contains `<<<<<<< / ======= / >>>>>>>` markers, making the module syntactically invalid.
## Issue Context
The PR diff includes conflict markers like `<<<<<<< feat/improvements`, `=======`, and `>>>>>>> main` within `publish_code_suggestions()`. This will cause a hard failure (syntax error) and must be fixed by choosing the intended logic and removing the markers so the file is valid Python and CI/runtime imports succeed.
## Fix Focus Areas
- pr_agent/git_providers/gitlab_provider.py[669-684]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| # contents = self.repo_obj.get_contents(".pr_agent.toml", ref=self.pr.head.sha).decoded_content | ||
| # more logical to take 'pr_agent.toml' from the default branch |
There was a problem hiding this comment.
2. Commented-out settings fetch code 📘 Rule violation ⚙ Maintainability
Commented-out code was added in GithubProvider.get_repo_settings, which violates the requirement to avoid dead/commented-out code. Leaving this in place increases maintenance burden and can confuse future behavior expectations.
Agent Prompt
## Issue description
New commented-out code was introduced in `get_repo_settings()`.
## Issue Context
The PR adds commented lines about loading `.pr_agent.toml` from `self.pr.head.sha`, but the code path now uses the default branch instead.
## Fix Focus Areas
- pr_agent/git_providers/github_provider.py[766-767]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| def get_repo_file_content(self, file_path: str): | ||
| try: | ||
| contents = self.repo_obj.get_contents(file_path).decoded_content | ||
| if isinstance(contents, bytes): | ||
| return contents.decode("utf-8", errors="replace") | ||
| return contents | ||
| except Exception: | ||
| except Exception as e: | ||
| get_logger().warning(f"Failed to load repo file: {file_path}, error: {e}") | ||
| return "" |
There was a problem hiding this comment.
4. Github repo context wrong branch 🐞 Bug ≡ Correctness
GithubProvider.get_repo_file_content() fetches files with no ref, which reads from the repo default branch and can return the wrong instruction files when the PR targets a non-default base branch. This makes the new repo_context_files feature supply incorrect context to prompts for such PRs.
Agent Prompt
## Issue description
Repo-context files for GitHub are fetched from the default branch because `get_contents(file_path)` is called without a `ref`. For PRs targeting release branches or non-default branches, instruction files can differ and the model will receive the wrong guidance.
## Issue Context
Other providers (e.g., Gitea) explicitly prefer the PR target/base ref when available.
## Fix Focus Areas
- pr_agent/git_providers/github_provider.py[791-799]
- pr_agent/git_providers/gitea_provider.py[747-763]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 70895f1 |
|
Code review by qodo was updated up to the latest commit 48338a2 |
| # Optional: override the built-in list of Claude models that receive the extended-thinking payload. | ||
| # When non-empty, this list fully replaces the built-in defaults (see CLAUDE_EXTENDED_THINKING_MODELS | ||
| # in pr_agent/algo/__init__.py). Leave empty to use the defaults. | ||
| claude_extended_thinking_models_override = [] |
There was a problem hiding this comment.
1. claude_extended_thinking_models_override undocumented 📎 Requirement gap ⚙ Maintainability
A new operator-facing config key claude_extended_thinking_models_override was added, but the docs section describing Claude extended-thinking parameters does not mention it. Operators may not discover or correctly use the override behavior.
Agent Prompt
## Issue description
The new config key `claude_extended_thinking_models_override` is not documented for operators in the docs section that describes Claude extended-thinking settings.
## Issue Context
The defaults file adds the key and explains replacement/empty semantics in comments, but operators typically rely on MkDocs pages (e.g., the model/Anthropic section) to learn available configuration.
## Fix Focus Areas
- docs/docs/usage-guide/changing_a_model.md[440-447]
- pr_agent/settings/configuration.toml[69-72]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| }, | ||
| { | ||
| "settings": b"[pr_reviewer]\nnum_max_findings =", | ||
| "settings": b"[github]\nuser_token = \"secret-token\"\n[pr_reviewer]\nnum_max_findings =", |
There was a problem hiding this comment.
2. Hardcoded secret-token test value 📘 Rule violation ⛨ Security
A token-like secret value is committed in a unit test (user_token = "secret-token"). Even as a placeholder, it can trip secret scanners and violates the requirement to avoid committing secrets/tokens in tracked files.
Agent Prompt
## Issue description
The unit test embeds a token-like value (`secret-token`) in TOML content, which violates the "no hardcoded secrets/tokens" requirement.
## Issue Context
Even dummy tokens can be flagged by security tooling and should be replaced with clearly non-secret placeholders.
## Fix Focus Areas
- tests/unittest/test_git_provider_utils.py[123-146]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
|
||
|
|
||
| class _RepoContextCache: | ||
| def __init__(self, max_size: int = REPO_CONTEXT_CACHE_MAX_SIZE, ttl_seconds: int = REPO_CONTEXT_CACHE_TTL_SECONDS): |
There was a problem hiding this comment.
4. Long lines in repo_context.py 📘 Rule violation ⚙ Maintainability
New code introduces lines likely exceeding the 120-character Ruff limit (e.g., the _RepoContextCache.__init__ signature). This can cause Ruff/pre-commit failures and adds style inconsistency.
Agent Prompt
## Issue description
At least one newly added line in `repo_context.py` exceeds typical Ruff line-length constraints (120), risking CI/pre-commit failures.
## Issue Context
This repository enforces Ruff style (120 max line length). Long signatures and f-strings should be wrapped across lines.
## Fix Focus Areas
- pr_agent/algo/repo_context.py[21-23]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit c7d0812 |
User description
Resolves #2357.
I backed out my other PR because it was too many changes (previously included "de-dupe inline comments") in one PR.
PR Type
Enhancement, Bug fix
Description
Add support for per-repository context files (AGENTS.md, CLAUDE.md, etc.) included in AI prompts
Allow overriding Claude extended thinking models via configuration
Support GitHub organization-level global settings repository
Implement repo context caching with TTL and size limits
Add repo file fetching for Gitea, GitLab, and GitHub providers
Diagram Walkthrough
File Walkthrough
15 files
Expand Claude extended thinking model supportAdd configurable Claude extended thinking model overrideNew module for repository context file handlingAdd base method for repository file content retrievalImplement repository file content fetching for GiteaAdd GitHub org-level settings and repo file fetchingImplement repository file content fetching for GitLabSupport multiple repository settings files with mergingInclude repository context in code suggestions promptsInclude repository context in description promptsInclude repository context in review promptsAdd repository context section to code suggestions templateAdd repository context section to non-decoupled templateAdd repository context section to description templateAdd repository context section to review template1 files
Add repo context and Claude model override configuration options6 files
Add tests for merged global and local settingsAdd tests for Gitea repository file content fetchingNew tests for GitHub org-level settings supportAdd tests for GitLab repository file content fetchingNew tests for Claude extended thinking model overrideComprehensive tests for repository context functionality2 files
Document GitHub organization-level settings supportDocument global settings and GitHub Enterprise support