Repository navigation
perf(server): Claude instances on the same home share one capabilities probe #13696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4967cf2
perf(server): Claude instances that share a home share one capabiliti…
t3dotgg de08e34
test(server): cover the Claude probe gate and fix the driver header
t3dotgg cd07128
fix(server): Claude probe cache no longer thrashes past 64 instances
t3dotgg 8691ad7
refactor(server): export make for the Claude probe cache
t3dotgg e84169f
fix(server): keep ClaudeProbeCache make module-private
t3dotgg e996211
refactor(server): export ClaudeProbeCache make like other services
t3dotgg 9fb0039
fix(server): Claude probe cache retries a failed usage read after 30 …
t3dotgg 9161e7d
test(server): an empty Claude home and an explicit ~/.claude run sepa…
t3dotgg ce9d3b3
fix(server): shared Claude probes keep honest usage times and run wit…
t3dotgg bbfa575
fix(server): cached Claude reads keep fresh reset credits, and a repe…
t3dotgg acb67c2
docs(server): say reset credits come from the probed limits
t3dotgg f88b84b
fix(server): bound the Claude probe cache's failure memory
t3dotgg df89a24
fix(server): new Claude instances probe fresh, and a replaced probe c…
t3dotgg 81204d0
refactor(server): shrink the shared Claude probe cache to one Effect …
t3dotgg cc29c1f
fix(server): a new or rebuilt Claude instance probes fresh
t3dotgg 10c54c9
docs(server): drop a stale reference from the Claude probe cache doc
t3dotgg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * One server-wide cache for the Claude capabilities probe. Claude instances | ||
| * with the same probe input read the same account, so they share one cached | ||
| * result, and concurrent reads of one input join one SDK probe. Each entry | ||
| * keeps 5 minutes, a failed probe (`undefined`) included. | ||
| * | ||
| * @module provider/Drivers/ClaudeProbeCache | ||
| */ | ||
| import type { ClaudeSettings, ProviderInstanceEnvironment } from "@t3tools/contracts"; | ||
| import * as Cache from "effect/Cache"; | ||
| import * as Context from "effect/Context"; | ||
| import * as Duration from "effect/Duration"; | ||
| import * as Layer from "effect/Layer"; | ||
|
|
||
| import { type ClaudeCapabilitiesProbe, probeClaudeCapabilities } from "../Layers/ClaudeProvider.ts"; | ||
| import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts"; | ||
|
|
||
| /** | ||
| * Every instance input the probe reads, and also the cache key. The lookup | ||
| * gets only this value, so the probe cannot read an input the key leaves out. | ||
| * Keys compare structurally. | ||
| */ | ||
| export type ClaudeProbeInput = Pick<ClaudeSettings, "binaryPath" | "homePath"> & { | ||
| readonly cwd: string; | ||
| readonly environment: ProviderInstanceEnvironment; | ||
| }; | ||
|
|
||
| export class ClaudeProbeCache extends Context.Service< | ||
| ClaudeProbeCache, | ||
| Cache.Cache<ClaudeProbeInput, ClaudeCapabilitiesProbe | undefined> | ||
| >()("t3/provider/Drivers/ClaudeProbeCache") {} | ||
|
|
||
| /** @public Service construction is part of the canonical Effect module API. */ | ||
| export const make = Cache.make({ | ||
| // Far above any real input count. Each refresh reads keys in the same | ||
| // order, so a cap below the live key count would re-probe every key. | ||
| capacity: 256, | ||
|
t3dotgg marked this conversation as resolved.
|
||
| timeToLive: Duration.minutes(5), | ||
| lookup: (input: ClaudeProbeInput) => | ||
| probeClaudeCapabilities(input, mergeProviderInstanceEnvironment(input.environment), input.cwd), | ||
| }); | ||
|
|
||
| export const layer = Layer.effect(ClaudeProbeCache, make); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.