Repository navigation
feat: per-session token burn in logs, monitor rings, and usage snapshots - #77
Merged
Merged
Conversation
Every anonymous-lane session draws from one shared upstream IP bucket, but nothing showed which conversation was draining it. Carry the canonical ses_ ID into RequestMeta and the request_routed line, the recent-request ring, and per-model/per-tier style usageSessions maps in both lifetime and hourly snapshots. The lifetime sessions map is capped at 500 entries (smallest-first eviction): session IDs are high-cardinality and an unbounded map grows forever. Buckets and snapshots are short-lived and stay uncapped.
This was referenced Oct 14, 2026
jasonxu114514
added a commit
that referenced
this pull request
Oct 15, 2026
…ots (#77) Carry the canonical ses_ ID into RequestMeta, the request_routed line, the recent-request ring, and per-session usage maps in the lifetime and hourly snapshots, including rotation requests. The lifetime map keeps the 500 most recently seen sessions. Co-authored-by: sk-dev-ai <[email protected]>
SK-DEV-AI
added a commit
to SK-DEV-AI/opencode2api
that referenced
this pull request
Oct 15, 2026
…ver-key usage) Takes upstream f8e996d/be91f86/0204ca1 (client fingerprint + inference endpoint + genuine tools), jasonxu114514#59 anon cooldown lockup, jasonxu114514#63 token floor, jasonxu114514#64 whole-attempt deadline, jasonxu114514#62 tool images, jasonxu114514#58 server-key usage split, jasonxu114514#65/jasonxu114514#66 models surface, plus our merged jasonxu114514#76/jasonxu114514#77/jasonxu114514#78. Kept local (fork-owned, still no upstream equivalent): zero-delivery replay + length rescue + SSE heartbeat + stop/tail census (stream lanes), offline no_upstream_contact probe guard, single-marshal Zen shaping with paid-model gate, tcp4 dial + TLS resumption, RandomID math/rand fallback, cancel-detached refresh fix (PR jasonxu114514#80 superseded by maintainer feedback; kept locally pending lifetime-context rework). Telemetry takes upstream's session-burn + server-key split with their LRU session cap (better than our smallest-first); CloneMap takes upstream's merged comment. Metrics ring test retargeted at upstream's concrete ring types. doUpstream keeps upstream's 3-value signature; replay uses a new doUpstreamCounted wrapper for continuous legs.
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.
Every anonymous-lane session draws from one shared upstream IP bucket, but nothing shows which conversation is draining it. This carries the canonical ses_ ID into RequestMeta and the request_routed line, the recent-request ring, and usageSessions maps in both lifetime and hourly usage snapshots.
The lifetime sessions map is capped at 500 entries with smallest-first eviction: session IDs are high-cardinality (one per conversation) and an unbounded map grows forever. Buckets and snapshots are short-lived and stay uncapped.
Validation: go vet clean, go build -trimpath clean, gofmt clean. Additive only: one log field, one omitempty ring field, one snapshot map.