Skip to content

Comments

Replace per-issue/MR note polling with single project events API call#94

Merged
myaple merged 4 commits intomainfrom
claude/reduce-gitlab-api-calls-cNh9h
Feb 18, 2026
Merged

Replace per-issue/MR note polling with single project events API call#94
myaple merged 4 commits intomainfrom
claude/reduce-gitlab-api-calls-cNh9h

Conversation

@myaple
Copy link
Owner

@myaple myaple commented Feb 18, 2026

Instead of calling get_issue_notes() for each updated issue and
get_merge_request_notes() for each updated MR (O(N+M) API calls per
poll cycle), use the GitLab project events API
(GET /projects/:id/events?action=commented) to fetch all note events
since the last check in a single request.

Introduces GitlabEventNote and GitlabProjectEvent models, adds
get_project_note_events() to the GitLab client, and replaces
process_issues_for_mentions() + poll_merge_requests() with a unified
process_note_events() method that handles both issue and MR mentions
from the single events batch.

https://claude.ai/code/session_01QKGjDY8ggdijJhAxSEGBSU

Instead of calling get_issue_notes() for each updated issue and
get_merge_request_notes() for each updated MR (O(N+M) API calls per
poll cycle), use the GitLab project events API
(GET /projects/:id/events?action=commented) to fetch all note events
since the last check in a single request.

Introduces GitlabEventNote and GitlabProjectEvent models, adds
get_project_note_events() to the GitLab client, and replaces
process_issues_for_mentions() + poll_merge_requests() with a unified
process_note_events() method that handles both issue and MR mentions
from the single events batch.

https://claude.ai/code/session_01QKGjDY8ggdijJhAxSEGBSU
The extract_context_for_mr function was calling get_file_commits() for
every changed file in a merge request, resulting in O(N) API calls where
N is the number of changed files. The commit history rarely changed the
quality of the LLM response meaningfully.

Removes the entire get_file_commits loop and the context_for_comment
commit-history table. Also updates format_final_reply_body to omit the
collapsible commit history block when it is empty.

https://claude.ai/code/session_01QKGjDY8ggdijJhAxSEGBSU
extract_issue_details_and_handle_stale was calling get_issue twice: once
for the stale-label check and again to return the issue to the caller.
build_issue_prompt_with_context then called get_issue a third time even
though the issue was already available via the context struct.

Fetch the issue once in extract_issue_details_and_handle_stale, reuse it
for the stale check, and use context.issue directly in
build_issue_prompt_with_context instead of re-fetching.

https://claude.ai/code/session_01QKGjDY8ggdijJhAxSEGBSU
get_project_by_path was called multiple times per poll cycle and per
request: from poll_repository on every poll interval, and from
repo_context.rs (get_agents_md_content, get_combined_source_files,
find_relevant_files_for_issue) during context extraction.

Adds a project_cache DashMap<String, (GitlabProject, Instant)> to
GitlabApiClient with a 1-hour TTL, deduplicating repeated lookups for
the same repo path across all call sites automatically.

https://claude.ai/code/session_01QKGjDY8ggdijJhAxSEGBSU
@myaple myaple merged commit 87977cc into main Feb 18, 2026
2 of 3 checks passed
@myaple myaple deleted the claude/reduce-gitlab-api-calls-cNh9h branch February 18, 2026 19:41
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.

2 participants