Skip to content

Derived session ids survive a restart, so a burned ses_… keeps 429ing after the egress changes #159

Closed

Description

@cheerc

Problem

CanonicalSessionID (internal/identity/request.go) re-encodes a conversation signal deterministically: the same server key, conversation seed, and UTC day produce the same ses_… in every process. Once the free tier has charged that session, restarting the gateway does not change the upstream identity, so the request is answered 429 Free usage limit reached again even when the exit — and therefore its per-IP bucket — is new. The only escape today is editing the conversation's opening messages or waiting for UTC midnight / the timestamp offset to drift.

Evidence

Field report from one deployment (anonymous lane, deepseek-v4.1-flash-free, v2 upstream): after a 429, changing the host IP and restarting the gateway did not help. The request log still showed the same session, and upstream answered 429 in ~0.7 s with in: 0. Minting a new session id for the same conversation made the same request pass on the new IP.

Source path: DeriveRequestIDs → scopedSessionID → CanonicalSessionID. Its only inputs are the server-key scope and the signal; timePart is day-stable by design (descendingTimePart truncates to UTC midnight minus a hash offset). Nothing process-scoped or random enters the hash, so a restart is a no-op for the upstream session.

This is not a controlled experiment: the exit changed at the same time as the session. Two cheap confirmations:

  1. On one fixed exit, take a request that 429s, restart the gateway, and compare session in the request log. Before a per-process salt the ids are identical; with one they differ.
  2. Keep the exit fixed and replay the same body with the burned ses_… versus a freshly minted one. If only the fresh one passes, the limiter is not IP-only.

This adds field evidence to #158 (open question 3: session+project metering) and contradicts its measured "per egress /64 + UTC day only" model on at least one path.

Scope

internal/identity/request.go, synthesized session ids only (CanonicalSessionID). Official client-minted ses_… stay verbatim, and per-process stability (affinity, sticky proxy, prompt cache) must be preserved.

Expected Outcome

  • Two gateway processes derive different ses_… for the same signal.
  • One process keeps deriving the same ses_… for the same signal.
  • Official client sessions are forwarded unchanged.

Related

Activity

  1. cheerc commented on Oct 29, 2026

    @cheerc
    ContributorAuthor

    Measured today on one fixed exit (IPv4 114.39.220.139), one body, only the ses_ value varied:

    session result
    ses_e7d96c721ffe (a real CLI session's time part) + fresh random suffix 200
    random 12-hex time part + the known-good suffix of a passing session 429
    ses_000000000000… 200
    the exact session from the field-report log (ses_e8722fbfaffe5rgVd0mpvuAo3Z) 200
    random ses_ + 20 hex (too short) 429

    So the limiter does read the session, and an implausible time part is answered with the same 429 Free usage limit reached as an exhausted bucket — which is what CanonicalSessionID already normalizes. But on this exit the session named in the original report passes, so the session alone did not reproduce the reported failure here.

    What did reproduce, deterministically, was a different trigger found today: a shaped body whose tools still carry another client's names. A Claude Code request that declares both ReportFindings and ScheduleWakeup is refused 3/3, and renaming either name makes the same request pass 3/3, with the session, exit and body otherwise identical. Fixed in #161.

    This issue stays open for the session-restart behaviour: the salt in #160 does not change the id encoding, so it cannot make a session invalid, and re-minting on restart remains the right way to leave a session that the upstream has charged (session+IP affinity is the mechanism the field report points at).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions