Skip to content

fix(agent-manager): reduce background Git and GitHub process churn - #13463

Merged
marius-kilocode merged 2 commits into
mainfrom
investigate-kilo-crowdstrike-high-cpu
Aug 26, 2026
Merged

fix(agent-manager): reduce background Git and GitHub process churn#13463
marius-kilocode merged 2 commits into
mainfrom
investigate-kilo-crowdstrike-high-cpu

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Agent Manager repeatedly starts Git and GitHub CLI subprocesses while projects remain open. Each project refresh previously ran a separate git worktree list, the embedded chat provider created another Git stats poller, and PR badges fetched metadata, checks, and reviewers through separate gh commands. With multiple projects and worktrees, this creates sustained background process churn.

Why This Change Was Made

The existing git for-each-ref query can return checked-out worktree paths alongside refs and upstreams, so normal worktree presence checks do not need another Git process. Agent Manager already owns project-scoped Git polling, so its embedded KiloProvider must not start a duplicate poller. GitHub CLI can also return check rollups, review requests, and complete review history in the existing gh pr view response.

The implementation preserves existing polling intervals and external Git-change detection. It falls back to git worktree list for detached worktrees, incomplete metadata, and Git versions without %(worktreepath). PR lookups remain scoped by project, detached worktrees keep separate cache entries, and older GitHub CLI versions or restricted tokens fall back once to the existing basic request without repeating failed capability probes. Complete review history is retained so a later comment does not erase an earlier approval.

User Impact

Agent Manager uses fewer background processes with multiple projects while preserving branch changes, staged and untracked diffs, ahead/behind counts, CI status, review decisions, file search, and the existing CLI behavior. The change does not introduce file watchers, replace the existing file-search implementation, or modify shared upstream OpenCode source.

Evidence

Identical isolated VS Code runs used two expanded projects, eight managed worktrees, and a 25-second observation window.

Background process metric Before After Difference
Total Git subprocesses 80 50 -37.5%
Worktree status scans 45 35 -22.2%
Ref queries 20 15 -25.0%
git worktree list subprocesses 10 0 -100%

PR enrichment was verified independently because the disposable benchmark repositories do not have GitHub pull requests.

PR enrichment operation Before After Difference
PR metadata, check results, and reviewers At least 3 gh subprocesses 1 gh pr view subprocess At least -66.7%
Cold repository identity lookup Up to 1 additional gh repo view per worktree Reused per project Project-scoped cache

A real GitHub PR response returned 22 checks and its reviewer history through the combined command. Automated coverage includes two repositories with matching branch names, detached worktrees, unsupported Git atoms, unknown GitHub fields, restricted GitHub tokens, cancelled checks, and approvals followed by comments.

Validation: all 4,217 VS Code extension unit tests passed, along with extension typecheck, lint, Knip, formatting, and upstream annotation checks. Real UI verification covered both projects, external edits, staged changes, commits, branch renames, detached worktrees, project-specific diffs, and newly created files appearing in search.

Comment thread packages/kilo-vscode/src/agent-manager/PRStatusPoller.ts Outdated
Comment thread packages/kilo-vscode/src/agent-manager/pr/am-pr-utils.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • packages/kilo-vscode/src/agent-manager/PRStatusPoller.ts
  • packages/kilo-vscode/src/agent-manager/pr/am-pr-utils.ts
  • packages/kilo-vscode/tests/unit/am-pr-status-bridge.test.ts
  • packages/kilo-vscode/tests/unit/am-pr-utils.test.ts
Previous Review Summary (commit 743fafc)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 743fafc)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/src/agent-manager/PRStatusPoller.ts 365 Rich-field gh fallback is not latched, so old CLI/restricted tokens keep extra processes
packages/kilo-vscode/src/agent-manager/pr/am-pr-utils.ts 59 Cancelled checks counted as failed can hide in-progress CI behind a failure badge
Files Reviewed (14 files)
  • .changeset/quiet-agent-manager-stats.md - 0 issues
  • packages/kilo-vscode/src/KiloProvider.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/GitStatsPoller.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/PRStatusPoller.ts - 1 issue
  • packages/kilo-vscode/src/agent-manager/git-stats-snapshot.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/pr/am-pr-types.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/pr/am-pr-utils.ts - 1 issue
  • packages/kilo-vscode/src/agent-manager/vscode-host.ts - 0 issues
  • packages/kilo-vscode/src/kilo-provider/options.ts - 0 issues
  • packages/kilo-vscode/tests/unit/am-pr-status-bridge.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/am-pr-utils.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/git-stats-poller.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/git-stats-snapshot.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/kilo-provider-followup.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 59K · Output: 7.7K · Cached: 269.4K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 3c2bc84 into main Aug 26, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the investigate-kilo-crowdstrike-high-cpu branch August 26, 2026 12:11
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