fix(acp): persist model catalogs and scope discovery per agent #6197
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #6197"
general
weight: 0.35
me2seeks
Summary
Opening a new draft after more than 60 seconds or a Host/application restart previously launched another ACP discovery process. Successful neutral-discovery catalogs now persist across drafts and restarts.
Performance benefits and trade-offs
This change primarily improves model-picker readiness and reduces discovery subprocess churn. It does not accelerate model inference, and real conversation initialization still validates its own model and mode.
| Optimization | Benefit | Trade-off / current limitation |
| --- | --- | --- |
| Reuse successful catalogs without a 60-second TTL, including across Host restarts | Reopening a draft can use memory or a persisted snapshot instead of launching and disposing another ACP process. Warm memory reads do no storage I/O. | Catalog freshness becomes event/manual driven. Remote model changes and account switches performed outside Maka can leave stale choices until refresh or invalidation. Executable/helper metadata is checked on snapshot load and successful probe persistence, not on every memory hit; an in-place installation change is not detected immediately by a running cached executor. |
| Load and refresh catalogs per Agent | A fast Agent can become selectable before a slow Agent finishes. Targeted retries and setup invalidation avoid re-probing unrelated Agents. | A draft now requests an inventory followed by one request per Agent: roughly
N + 1requests instead of one batched request. This can cost more when every catalog is warm, especially over a remote Host connection. Discovery still shares a two-probe FIFO budget, so cold Agents can still queue; this does not increase probe concurrency. || Preserve the last good catalog on transient refresh failure; cool down cold failures | Existing choices remain usable during temporary discovery failures, and repeated draft reads do not continually restart a failing Agent. | Cached choices are advisory and may later fail real Session validation. A cold failure can delay an automatic retry for up to 60 seconds; expiry only permits a later read to retry, with no scheduled retry. If a good catalog was retained after a failed refresh, ordinary reads keep returning it with
refreshFailed; another explicit refresh or invalidation is needed to re-probe. Explicit retry bypasses the cooldown. || Keep neutral catalogs separate from real Session capabilities | Project-specific models, defaults and modes cannot overwrite the public choices shown in other drafts. | A real Session may expose different choices and require reselection. Even if a task has already initialized successfully, the first uncached draft still needs its own neutral probe. Draft discovery does not warm or replace the real conversation process. |
| Persist versioned snapshots bound to configuration and executable/helper metadata | Compatible restarts reuse validated snapshots; missing, corrupt or incompatible records fall back to discovery. | The first load adds a storage read and metadata checks, and successful probes add persistence work. Derived labels/groups/defaults depend on a manually maintained
CATALOG_SNAPSHOT_VERSION; adapter or normalization changes require a version bump. Binary/configuration fingerprints do not automatically detect those code-only changes. || Revalidate ready Session pickers silently | Periodic inspection and Session events no longer flash the loading indicator for an already usable picker. | The existing 3-second Session polling remains. This improves presentation stability, not polling traffic or inference latency. |
A controlled local comparison of
ff74d21c8and0bcb095aused the repository's real stdio test Agent, ACP SDK and subprocess lifecycle on an Apple M4 Pro with Node 24.18.1 (3 warmup rounds, 30 measured rounds). Median catalog reads after the old TTL elapsed changed from 97.98 ms to 0.006 ms; executor recreation with a valid file-backed snapshot changed from 98.61 ms to 0.52 ms. Both scenarios went from 30 probe process starts to zero across the measured rounds. First uncached discovery and forced refresh remained about 98 ms.These are discovery-layer measurements, not end-to-end application speedups: the TTL boundary was simulated by advancing the clock, restart was executor recreation rather than a full Host/app restart, and persistence used a JSON file rather than the Host database. Electron IPC/UI and authenticated official Agents were not measured. The remote-Host cost of the additional per-Agent requests remains unquantified.
Verification
f7fd46469) and advanced the protocol epoch to 228, preserving main's epoch-227 ShellRun event-wait changes.build:test, full workspace typecheck, repository-wide lint and formatting checks, and the staged ASF header check.0bcb095a; the synchronized head triggers a fresh CI run.Compatibility
Runtime Host compatibility epoch increases from 227 to 228 for executor inventory/filter queries; update Desktop and Host together. Missing, corrupt, or incompatible snapshots fall back to neutral discovery.
AI use
OpenAI Codex implemented the changes, regression tests, documentation, and local verification. Follow-up commits include a
Generated-by: Codextrailer.Checklist
Does this PR entail a change in behavior?