Commit Graph

13 Commits

Author SHA1 Message Date
sususu
580df36423 feat(usage): propagate session and parent session hierarchy to usage reporting queue
- Reuse coresession.ExtractSessionInfo across HTTP headers and request payloads to unify canonical session prefix namespaces with the scheduler.
- Extract hierarchical session identities in two phases: initial extraction from request headers on entry, and authoritative deep extraction once request payloads and metadata are available.
- Support Claude Code multi-level subagents (X-Claude-Code-Agent-Id, metadata.agent_id) and Codex thread fork lineages.
- Propagate SessionID and ParentSessionID across ClientRequestMetadata, UsageReporter, and coreusage.Record without root_session_id.
- Include session_id and parent_session_id in queuedUsageDetail for Home LPushUsage forwarding and Redis consumption with self-loop guards.
- Add comprehensive test coverage for canonical headers, body extraction, ghost parent elimination, and self-referential loop guards.
2026-09-06 10:45:32 +08:00
sususu98
e899f0e539 feat(session): derive distinct branch session ID, parent lineage on Merkle LCP forks, and enhance Codex fork/subagent affinity (#5418) (#5454) 2026-09-03 17:52:40 +08:00
sususu
dc0f7a594b fix(session): derive LCP session ID from rolling prefix keys and harden matcher
- root derived session ID in rolling prefix key to disambiguate conversations with different system prompts
- sanitize matcher config to guarantee MaxPrefixes >= MaxTurns
- tie-break tool parts sorting with digest for determinism
2026-09-01 18:00:13 +08:00
Luis Pater
fae57a3a88 fix(session): support identity and subagent extraction from nested request payloads
- Extract subagent IDs, user IDs, and prompt cache keys from nested `request` objects across session identity, session info, and auth selection.
- Normalize and fall back appropriately when top-level prompt cache key fields are empty strings.
- Inspect nested request fields when validating explicit session identities.
2026-09-01 11:23:38 +08:00
Luis Pater
f2e2d713b2 fix(auth): propagate upstream error causes in auth selection failures
- Attach candidate upstream errors as causes to scheduler availability and cooldown errors.
- Introduce `errorWithCause` wrapper to extract and display upstream error summaries.
- Enrich auth selection error messages with upstream details and preserve model cooldown errors.
- Forward `Retry-After` response headers for model cooldown errors in Claude Code handler.

Closes: #5365
2026-09-01 08:15:51 +08:00
sususu
5755d00b1b refactor(session): prune in-memory session tree store in favor of flat KV affinity and pure info extraction
- Replace complex materialized tree structures with lightweight (session_id, parent_id) extraction
- Maintain O(1) flat KV cache for subagent-to-parent prompt cache inheritance
- Add tree_compat.go with deprecated stubs to preserve SDK compatibility
- Add comprehensive regression tests for multi-protocol session headers and payloads
2026-08-31 20:28:15 +08:00
sususu
c99ce12123 fix(session): harden depth-cap index cleanup, bound lcp fingerprints, and support nested payloads (#5202) 2026-08-31 14:55:37 +08:00
sususu
100c564313 fix(session): harden nil fallback, normalize agent id, and support nested antigravity payloads (#5202) 2026-08-31 14:00:10 +08:00
sususu
8211388946 feat(session): implement Merkle LCP session affinity, session tree, and distributed Home hierarchy (#5202)
- Implement Merkle Longest Common Prefix (LCP) session affinity engine across OpenAI, Claude, Gemini, Interactions, and Responses protocols in sdk/cliproxy/session/lcp.go
- Implement in-memory hierarchical session tree store with dynamic lineage recalculation, reparenting, cycle prevention, and parentIndex descendant cascading in sdk/cliproxy/session/tree.go
- Integrate Merkle prefix matching and hierarchical session tree into SessionAffinitySelector
- Bound SessionCache capacity to 65,536 entries with deterministic eviction
- Support Claude nested metadata parent extraction and Header+Body parent merging
- Enforce TTL expiration checks in touchLocked and bindLocked
- Propagate ParentSessionID in authDispatchRequest and RPopAuthWithSessionHierarchy for distributed Home dispatch
- Add isHierarchyParent in home_session_alias.go covering Claude, Codex, Pi slot, Antigravity, and Gemini caching
- Add comprehensive test suites in lcp_test.go, tree_test.go, selector_lcp_test.go, client_test.go, and home_session_alias_test.go
2026-08-31 11:18:41 +08:00
sususu
9992920984 Avoid copying large payloads in Antigravity reads
gjson.GetBytes copies the matched subtree before returning it, so every read of
request.contents on a multi-megabyte request allocated another copy of it. The
reasoning replay, executor, signature validation and session identity paths all
read whole arrays this way, and hasExplicitSession parsed the entire body with
gjson.ParseBytes on every request.

Use the no-copy helpers for these reads. Each call site only reads from the
result and writes through sjson, which allocates a new buffer, so the payload
stays immutable while the results are alive.
2026-08-09 00:40:57 +08:00
kyinhub
c1f16b706e fix(session): reject edge control characters 2026-07-27 16:18:18 +08:00
kyinhub
a97b1ae622 fix(auth): prefer native client session signals for affinity 2026-07-27 16:18:18 +08:00
Luis Pater
f6c32ec3ff feat(runtime): implement derived session identity features and tests
- Added utilities for generating stable session identities, including `DerivedSessionID`, `DerivedSessionUUID`, and `ProviderSessionUUID`.
- Introduced support for Antigravity's negative decimal `DerivedAntigravitySessionID` mapping.
- Enhanced metadata handling for provider-scoped UUID stabilization and consistent session identity inference.
- Added comprehensive tests for stability, namespace isolation, and preferred execution session prioritization.
2026-07-26 03:07:21 +08:00