Repository navigation
Description
Problem
Agent-server version and capability discovery currently uses a module-level WeakMap<HttpClient, Promise<ServerInfo>>. It successfully coalesces concurrent probes and caches stable metadata, but it hides ownership and lifecycle and combines several responsibilities:
- successful-value caching;
- in-flight request coalescing;
- rejection cleanup;
- refresh/invalidation policy.
PR #5363 added identity-guarded eviction for rejected probes, which is the correct minimal fix for that PR. As more consumers use server capabilities, the global cache will become harder to reason about and test.
Proposed direction
Introduce an instance-owned AgentServerInfoProvider (or similarly narrow name) created alongside the shared HttpClient and injected into clients that need server metadata.
The provider should own:
- a cached successful
ServerInfovalue; - at most one in-flight request;
get({ refresh?: boolean });- explicit
invalidate(); - optionally a
supports(capability)convenience method.
Keep responsibilities separate:
HttpClientremains generic transport and does not learn about/server_info.AgentServerInfoProviderowns fetching, coalescing, caching, and invalidation.- Compatibility/version utilities remain pure functions that interpret
ServerInfo.
The aggregate AgentServerClient should own one provider and share it with ConversationClient, WorkspacesClient, runtime transport selection, and other feature-gated clients. Standalone client constructors should preserve their current public API by creating an internal provider when one is not injected.
Initial cache policy
Cache successful metadata for the provider lifetime; do not add a TTL without a demonstrated need. Failures must never be cached. A forced refresh must not allow an older request to overwrite or clear a newer request.
Acceptance criteria
- No module-level server-info
WeakMapor global reset helper. - Explicit provider ownership and lifecycle.
- Concurrent
get()calls perform one HTTP request. - A rejected request propagates to current callers and the next call re-probes.
- Successful metadata is reused.
- Refresh/invalidation performs a new probe.
- An older request cannot overwrite or clear a newer refresh.
- Aggregate child clients share one provider.
- Standalone client APIs remain backward compatible.
- Existing version gates and fix(client): retry a lost create only where the server deduplicates #5363 lost-create retry safety semantics remain unchanged.
Context
- PR fix(client): retry a lost create only where the server deduplicates #5363
- Resolved cache-failure finding: fix(client): retry a lost create only where the server deduplicates #5363 (comment)
This issue was created by an AI agent (OpenHands) on behalf of Graham Neubig.
Activity
Placidoe commentedon Oct 3, 2026
I'd like to take this on. I checked the current TypeScript client: server-info discovery still lives in a module-level WeakMap in agent-server-compatibility.ts, so the ownership issue is still present.
I'll follow the scope in the issue: one provider shared by the aggregate client's children, backward-compatible standalone constructors, no TTL, and no server-info logic in HttpClient. I'll use offline HTTP tests for request coalescing, rejection recovery, successful caching, invalidation, and an older probe settling after a refresh.
I also checked #5363, which is still open. I'll keep its lost-create retry and rejection-eviction behavior intact and coordinate the overlap rather than submit a competing fix. Is anyone already handling this refactor?
Source inspection only so far; I haven't implemented the refactor or run its tests. I'm using OpenAI Codex to help with the investigation.
Placidoe commentedon Oct 3, 2026
I have a local implementation now. I reproduced both behaviors on a pinned main revision (a failed probe staying cached, and duplicate probes across aggregate children); the refactor passes all 362 TypeScript unit tests, including 13 new cache/sharing cases. Build, lint, formatting, and the public weak-type budget pass too. I also checked create/load/fork routing with the existing loopback HTTP tests. I haven't run Docker-backed Agent Server tests or the Node 22/24 CI matrix.
Before opening a PR, I'd like to confirm the compatibility plan.
getCachedAgentServerInfo,clearAgentServerInfoCache, andassertAgentServerSupportsare exported from both the root and/clientsentrypoints. A clean removal of the global reset/cache helpers, plus making the assertion consume resolved ServerInfo, therefore changes a public API. Standalone client constructors and endpoint methods can stay compatible.Is that helper migration intended as part of this issue, or would you prefer a staged deprecation? I don't want to silently break those exports or reintroduce hidden global state just to preserve them.
#5363 is still open. My main-based implementation doesn't change create retry behavior; I'll reconcile its metadata lookup and rerun its dropped-response safety tests after it lands. No PR submitted yet. I'm using OpenAI Codex to help with implementation and verification.