agentService.ts ×10

Frontier kind: Code frontier

unlabeled · c_849920c18711

6 tests · 51745 LOC · 304 files · introduces 0 tests · 47 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges47 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5437 ranges51745 lines · 304 files · Browse complete extent
All tests (intent)
6 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 47 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentService.ts 37 introduced LOC · 10 ranges

Open complete file

1965 // provider runtime. A zero grace releases on the next tick.
1966 this._pendingSessionRelease.set(resource, disposableTimeout(() => {
1967 > this._pendingSessionRelease.deleteAndDispose(resource); agentService.ts
1968 > this._maybeEvictIdleSession(resource);
1969 }, SESSION_RELEASE_GRACE_MS));
1970 }
2050 */
2051 private _maybeEvictIdleSession(resource: URI): void {
2052 > const key = resource.toString(); agentService.ts
2053 > if (this._resourceSubscribers.has(resource)) {
2054 return;
2055 }
2056 > // Walk up the subagent ancestry: the SDK session and its turn tree are agentService.ts
2057 > // owned by the root session, so eviction must target the root.
2058 > let evictionTarget = resource;
2059 > {
2060 > let parsed;
2061 > while ((parsed = parseSubagentSessionUri(evictionTarget))) {
2062 evictionTarget = parsed.parentSession;
2063 }
2064 > } agentService.ts
2065 > // Don't evict if the root or any of its subagent descendants still has subscribers.
2066 > if (this._resourceSubscribers.has(evictionTarget)) {
2067 return;
2068 }
2069 > for (const subscribedUri of this._resourceSubscribers.keys()) { agentService.ts
2070 if (this._isSubagentDescendantOf(subscribedUri, evictionTarget)) {
2071 return;
2072 }
2073 }
2074 > const evictionTargetKey = evictionTarget.toString(); agentService.ts
2075 > // A restore/resume racing this unsubscribe means a client is about to
2076 > // observe the session again; releasing now would tear down state that
2077 > // the in-flight rehydrate is populating.
2078 > if (this._restoreSessionInFlight.has(evictionTargetKey)) {
2079 return;
2080 }
2081 > const targetState = this._stateManager.getSessionState(evictionTargetKey); agentService.ts
2082 > if (!targetState || targetState.activeTurn !== undefined) {
2083 return;
2084 }
2085 > this._logService.info(`[AgentService] Evicting idle session: ${evictionTargetKey} (triggered by unsubscribe of ${key})`); agentService.ts
2086 > // Also evict any sibling subagent entries cached under the parent: their
2087 > // authoritative state is the parent's turn tree, and dropping the parent
2088 > // would leave them orphaned.
2089 > const subagentPrefix = buildSubagentSessionUriPrefix(evictionTarget);
2090 > for (const cachedKey of this._stateManager.getSessionUrisWithPrefix(subagentPrefix)) {
2091 this._stateManager.removeSession(cachedKey);
2092 }
2093 > this._stateManager.removeSession(evictionTargetKey); agentService.ts
2094 > // Release the provider's in-memory SDK session in lockstep with the
2095 > // cached state. Non-destructive: durable data is preserved so the
2096 > // session resumes transparently on the next access. Fire-and-forget —
2097 > // the provider sequences the release internally and re-checks its own
2098 > // invariants (e.g. a turn that started after this call).
2099 > const provider = this._findProviderForSession(evictionTarget);
2100 > provider?.releaseSession?.(evictionTarget).catch(err => {
2101 this._logService.error(err, `[AgentService] Failed to release idle session ${evictionTargetKey}`);
2102 > }); agentService.ts
2103 > }
2104
2105 // Returns true when a changeset is safe to drop from the in-memory cache.
src/vs/platform/agentHost/node/agentHostStateManager.ts 6 introduced LOC · 2 ranges

Open complete file

447 */
448 getSessionUrisWithPrefix(prefix: string): string[] {
449 > const result: string[] = []; agentHostStateManager.ts
450 > for (const key of this._sessionStates.keys()) {
451 > if (key.startsWith(prefix)) {
452 result.push(key);
453 }
455 > return result;
456 > }
457
458 // ---- Snapshots ----------------------------------------------------------
src/vs/platform/agentHost/test/node/mockAgent.ts 4 introduced LOC · 1 range

Open complete file

177
178 async releaseSession(session: URI): Promise<void> {
179 > // Non-destructive: record the call but keep the session in the catalog mockAgent.ts
180 > // so a later restore/resume still finds its durable data.
181 > this.releaseSessionCalls.push(session);
182 > }
183
184 async abortSession(session: URI): Promise<void> {