Skip to content

fix(discovery): avoid reprobing unchanged agents on attach - #345

Closed
ccch1mneyyy wants to merge 1 commit into
mainfrom
work/333-ccch1mneyyy
Closed

ccch1mneyyy wants to merge 1 commit into
mainfrom
work/333-ccch1mneyyy

Conversation

@ccch1mneyyy

@ccch1mneyyy ccch1mneyyy commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #333

What was wrong

Each discovery reconcile called the complete presentation/system-prompt assembly for every live agent before checking whether anything changed. Attaching an empty discovery worker also registered an empty provider and emitted an unnecessary registry change. Creating one ordinary agent therefore repeatedly assembled unchanged agents' prompts.

The change

  • Reuse successful background presentation decisions while context, session, cwd and freshly resolved policy inputs match. Skip no-op provider registration for start([]).
  • Invalidate on actual tool/prompt/config/ownership and service changes; handle session-mode changes locally. Failed probes are not cached. Runtime updates wait for the real asynchronous Fiber restart even though the pinned next() declaration says void.
  • Keep each model pre-step and tool execution fresh for its own agent, so unsignalled dynamic providers and cached definitions cannot authorize stale calls. Retire async results on invalidation and preserve unload cleanup.
  • Add deterministic real-host-service counting/lifecycle tests, paired docs and changelog. Correct the pre-existing stale discovery-entry measurement in those docs to the current 95 tokens / 416 bytes; the schema itself is unchanged.

This removes repeated full assembly in ordinary attach reconciliation, not all O(N) work. Cheap ownership/policy/tool-diff scans remain. Registry notifications have no affected-scope payload, so genuine external registry/presentation changes conservatively invalidate all entries; an attach that also declares a new scoped presentation is not promised zero old-agent probes.

Validation

node test/run.mjs discovery-incremental discovery-composition discovery presentation-readiness progressive-loop
  5 suites / 41 checks passed, 0 failed, 0 skipped
  discovery-incremental: all 14 checks passed

Deterministic real-host-service count, 12 existing agents plus one new agent:
  baseline: old-agent probes 24, new-agent probes 2
  fixed:    old-agent probes 0,  new-agent probes 1
  real registration notifications: system-prompt/change 0, tools/change 2
  no host registry method is replaced

Pre-step count:
  baseline: own agent 2 probes, unrelated agent 1
  fixed:    own agent 1 probe,  unrelated agent 0

Red/green:
  reverting both implementation files to a9ff940: 7 of the then-13 checks fail
  synchronous-finally variant for delayed config restart: 1 of 14 checks fails
  final await-next implementation: all 14 pass

node scripts/verify-gate.mjs --skip-install
  final implementation, including the asynchronous-update fix:
  linux-x64: gate green
  125 suites passed; 2 skipped (optional external tui-host/tui-native)
  Rust: 42 passed, 0 failed, 0 ignored
  manifest: 73 checks (minimum 59)
  all release build/runtime/pack closure steps passed

git diff --check
  passed

These are assembly counts, not wall-clock benchmark claims. The independent gate uses real Landlock to separate main's unrelated bwrap cache defect (#337/#338); the combined-tree check including that fix is recorded separately. No dependency, host SDK, shared registry, sandbox permission or version changes. Tool-schema/model-description byte delta: 0.

PR-triggered CI: https://github.com/T-Auto/dsh-ops/actions/runs/39484192359 — pull_request; aggregate CI required: SUCCESS (Windows x64, Linux x64, macOS arm64 and required supporting jobs passed).

Environment

Arch Linux x64, Node 24.21.0, Rust 1.97.1; source checkout based on main a9ff940 with the pinned host services.

Combined local validation

The submitted heads of #338, #340, #341, #342, #343, #344 and #345 were applied together in an isolated local verification worktree, including their combined changelog entries. With ordinary PATH selecting real bwrap 0.13.0 and real dsh-TUI 0.16.1 host/worker/renderer suites enabled, node scripts/verify-gate.mjs --skip-install passed all 11 release-gate steps: 129 suites passed, 0 skipped; 46 Rust unit tests passed; manifest 73/59. This Linux combined-tree evidence is separate from each PR's own cross-platform CI; no upstream merge or host installation was performed.

@ccch1mneyyy

Copy link
Copy Markdown
Collaborator Author

Withdrawing this duplicate PR: #333 was assigned to Nicholas023 before my claim, and the original assignee has opened #347. Please continue with #347. Keeping this branch for reference; this PR should not be merged.

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

Labels

None yet

Projects

None yet

1 participant