Repository navigation
feat(keepalive): manual ping endpoint, next-request costs, manual_pings savings - #655
Merged
Merged
Conversation
…gs savings POST /api/me/cache/ping sends one ordinary keep-alive ping (max_tokens 1, same cached prefix) on the caller's own session/thread. It accepts the dashboard cookie, the account's proxy token, or direct loopback, like /api/adapt/*. It answers 409 cold, 409 not held, 404 unknown session and 429 too soon (30 s per thread). The row is a keepalive row with manual_ping set and the avoided cache write stored beside its cost. /api/stats gains manual_pings (net of the pings), which joins total_saved_usd and stays out of every strategy ledger. The dashboard shows it as a cache-savings row and a waterfall step. /api/cachestate gains next_warm_usd and next_cold_usd on the session and each thread. Schema: two additive columns, no existing migration edited. Data dependence: the same as keep-alive (needs the held body and key); docs/data-dependence.md notes it. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
Price carrying a declaration over every captured request that declared it, used or not, per tool, skill and MCP server. unused_usd is unchanged. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
OsherElhadad
marked this pull request as ready for review
October 21, 2026 19:49
added 4 commits
October 21, 2026 19:52
True per thread when the keeper holds the body and key a manual ping needs (PingNow's ErrNotHeld test), so a client can hide a Ping button that would only answer 409. Omitted when the host cannot say. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
- Ignore ?tenant=: a ping acts on the caller's own account only. - Hold a press to the per-ping ceiling (409 too costly). - A refused manual ping no longer stops the thread's automatic schedule. - Keep the 30 s claim after a timeout; evict only expired claims. - pingable is left out (nil) when there is no keeper. - State the overlap with the keep-alive credit in the UI, waterfall and docs. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
- carry_reads and carry_usd use the same per-request pricing as unused_usd (carriedCost), so a never-used tool carries exactly its unused cost. Add carry_priced; a used tool in an unpriced session no longer reads as priced with carry_usd 0. Skills have no carry total (they are slices of the listing). - OpenReadOnly names a missing manual_ping column and the fix, instead of failing each query with 'no such column'. - A press over the per-ping ceiling answers 409 over budget. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
added 2 commits
October 21, 2026 20:20
…utton OpenReadOnly cannot add columns. Instead of refusing an older file, each read-only connection gets a temp view over requests that supplies manual_ping and manual_saved_usd as constants, then turns on query_only. Nothing is written to the file; a current file gets no shim. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
The temp view now supplies each missing column of additiveColumns as its default (NULL where none), not only the Ping button's two, so a reader beside an older proxy reads whatever the schema has gained since. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
amiddavid
added a commit
that referenced
this pull request
Oct 22, 2026
Main moved the keeper core into package keepalive and added the manual ping (#655), the manual-only hold (#666), predictive campaigns and the per-tenant builder. This merge keeps those and re-applies the TTL-aware schedule in the new package: - keepalive: ResolveTier, Policy.ForOneHour, per-thread tier1h, entry.hold(), MaxHold1h. - Manual-only hold lives 59 min on a 1h thread (ManualHoldMax1h), 300 s otherwise. A press still never extends it. - Campaigns and overrides bound a 1h thread's ping count downward. - Tests for each interaction, confirmed by mutation. Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
added a commit
that referenced
this pull request
Oct 22, 2026
feat(keepalive): follow the cache TTL each session was billed at Read the cache lifetime per thread from the traffic. A thread is a 1h thread when every breakpoint asks ttl 1h and the response billed the 1h tier for the whole write. Anything else keeps the 5m schedule. Name strategies by ping count: auto (default), 1-ping, 2-ping. The old name 5-min-ping stays as an alias of auto. Default per TTL: 5m cache keeps today's schedule (270 s, 2 pings); 1h cache gets 1 ping at 59 min. The 59 min value is one constant in internal/modelinfo. Refs #505 Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]> test(plugin): let the picker-skill check accept strategy aliases Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]> fix(keepalive): address review of the TTL-aware schedule - Plugin/binary skew: write a 1-hour config key only when it differs from the proxy default, and have start-proxy.sh drop the keys and retry when an older binary rejects them. - Credential hold: cap keepalive_max_pings_1h at 3 (236 min), clamp it in forOneHour, state the per-tier hold in the consent copy, the arm dialog and the ctl API. An override does not change a 1h schedule. - Dashboard: the credit floor and kaSaved window follow the row's cache_ttl, so a 1h rescue is credited and insights stays honest. - tier1h: write it beside turns, keep the current thread on reset, and never grow it on refused requests. - Tests for each, confirmed by mutation. Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]> fix(keepalive): apply a session override's ping count to 1h threads The override bounds a 1-hour thread's ping count downward; the 1-hour timing stays the account's. The arm dialog and ctl API state the hold. Owner accepted a hold of about 2 hours for a 1-hour thread. Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]> fix(plugin): scope the 1h-key recovery to this start and to one proxy version - start-proxy.sh reads only the log written by the current launch, so a rejection from an earlier run cannot trigger the recovery. - The legacy marker records the proxy version. After an update the 1-hour keys are written again. Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]> merge: bring feat/keepalive-ttl-aware up to origin/main Main moved the keeper core into package keepalive and added the manual ping (#655), the manual-only hold (#666), predictive campaigns and the per-tenant builder. This merge keeps those and re-applies the TTL-aware schedule in the new package: - keepalive: ResolveTier, Policy.ForOneHour, per-thread tier1h, entry.hold(), MaxHold1h. - Manual-only hold lives 59 min on a 1h thread (ManualHoldMax1h), 300 s otherwise. A press still never extends it. - Campaigns and overrides bound a 1h thread's ping count downward. - Tests for each interaction, confirmed by mutation. Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]> merge: bring feat/keepalive-ttl-aware up to origin/main (v0.5.4 bump) Assisted-By: Claude <[email protected]> docs(keepalive): state the manual-only hold per cache tier The manual-only hold lasts 300 s on a 5-minute cache and up to 59 min on a 1-hour cache. Five texts still said 5 minutes. Fix the install consent note, the install skill, the dashboard doc, the data-dependence doc and the settings.py comment, plus two Go comments. The install test now pins the per-tier wording. Assisted-By: Claude <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
/api/adapt/*principal: dashboard cookie, the account's proxy token, or direct loopback. Own account only./api/statsgainsmanual_pings{count, ping_usd, saved_usd (net)}. It joinstotal_saved_usd. No strategy ledger counts it./api/cachestategainsnext_warm_usdandnext_cold_usdon the session and each thread.What changed
keepalive/manual.go:Keeper.PingNow. It uses the same body builder, dispatcher and pricing as scheduled pings. It does not spend the K scheduled pings. A ping that read the cache restarts the automatic clock.dash: two additive columns (manual_ping,manual_saved_usd). Every ping ledger now filters onmanual_ping = 0.proxy/manualping.go: the route.Data dependence
Same as keep-alive. It needs the held body and key, so with keep-alive off the answer is 409 not held.
docs/data-dependence.mdis updated. Storage levels are unchanged.How it was tested
savedPartsis added but not run here (no node on this host); CI should run it.carry_readsandcarry_usdon /api/tools (tool, skill and MCP server rows) are the second commit.unused_usdis unchanged.