Commit Graph

22 Commits

Author SHA1 Message Date
Your Name efdaf0cb6a passing git add packages/.git add packages/. 2026-05-15 05:32:49 +00:00
Your Name 26602f97fb fix(core): Resolve context loss and token calculator thrashing
This commit addresses the massive context loss and 0% utilization issue by fixing two related bugs in the context management system:

1.  **Masked Tool Retention Bug:** Removed the brittle 'in-flight' protection logic from `getProtectedNodeIds`. Previously, this logic failed to match `MASKED_TOOL` nodes, causing it to perpetually hoard `functionCall` nodes inside the protected list. This hoarding rapidly exhausted the context budget, forcing the GC backstop into an aggressive death spiral. Now, only the `recent_turn` and explicit tasks are protected, allowing standard GC to naturally prune old tool calls (and the `HistoryHardener` handles the rest).
2.  **Adaptive Calculator Overhead Bug:** The `AdaptiveTokenCalculator` was calculating ratio drift by dividing the API's `actualTokens` (which includes the static overhead of the System Instruction and Tools) by the graph's `baseUnits` (which only counts history). We now inject an `getOverheadTokens` callback during initialization, allowing the calculator to subtract the overhead from the Gemini API count before dividing by the base units, achieving an accurate apples-to-apples ratio.
3.  **Violent Oscillation Dampening:** Introduced strict dampening bounds (`maxStep` limit and a hard `targetWeight` clamp) to the Adaptive Token Calculator's EMA. This acts identically to a machine learning learning-rate limit, ensuring that a single massive outlier reading cannot violently thrash the `learnedWeight` multiplier in a single turn.

Includes new test coverage verifying the maxStep logic and overhead subtraction. Also removed an unsafe `as unknown` cast in the `snapshotGenerator` that failed `eslint`.
2026-05-14 23:56:16 +00:00
Your Name 665b5ca6c7 fix issue with missing function responses 2026-05-14 23:13:01 +00:00
Your Name 5e34ea4be3 fix(context): properly re-identify snapshot nodes when loaded from disk
When PR cdd482c2e reverted structural snapshot rehydration, it left
toGraph mapping all non-tool parts as NodeType.USER_PROMPT. This caused
findLatestSnapshotBaseline to fail on resumed sessions, starting the Master
State from an empty baseline and leading to catastrophic data loss.
This fix detects the snapshot signature during graph construction to
properly assign NodeType.SNAPSHOT.
2026-05-14 23:10:19 +00:00
Your Name a31aa6094f tidying 2026-05-14 04:58:17 +00:00
Your Name c7ba026c18 strong owner 2026-05-14 04:40:49 +00:00
Your Name d0032c6749 refactor(context): implement durable NodeIdService and stabilize tool IDs 2026-05-14 04:40:49 +00:00
Your Name 4f6186f6f1 refactor(context): implement commit-on-render strategy for GC backstop 2026-05-14 04:40:48 +00:00
Your Name 2a2834cb77 fix(context): address PR feedback on state persistence and snapshot rehydration 2026-05-14 04:40:48 +00:00
Your Name 78a0e5d457 chore(context): remove dead initialization trigger and unawaited promise 2026-05-14 04:40:47 +00:00
Your Name cdd482c2e0 fix(context): revert structural snapshot rehydration and rely on baseline gc 2026-05-14 04:40:47 +00:00
Your Name 65d4bdfc24 feat(context): persist context engine snapshots across sessions
This commit implements an opaque state export/import pattern for the
ContextManager to ensure expensive LLM-derived snapshots are properly
rehydrated upon session resume.

The ContextManager now exposes `exportState` and `restoreState` methods,
delegating structural validation to the `SnapshotStateHelper`.
During active chat, the GeminiClient routinely passes the finalized
context state down to the ChatRecordingService, which seamlessly
embeds it into the existing JSONL metadata payload. Upon resume, the
saved snapshot is re-published as a draft to the LiveInbox, allowing
the synchronous pipeline to automatically and deterministically splice
it back into the raw graph without an additional LLM call.
2026-05-14 04:40:47 +00:00
joshualitt 07792f98cd feat(context): Introduce adaptive token calculator to more accurately calculate content sizes. (#26888) 2026-05-12 15:51:20 +00:00
joshualitt 01635ddb83 fix(context): implement loose boundary policy for gc backstop. (#26594) 2026-05-08 17:36:57 +00:00
joshualitt 897a4d7f83 fix(core): Fix hysteresis in async context management pipelines. (#26452) 2026-05-06 16:37:08 +00:00
joshualitt 80d2690540 fix(core): Fix chat corruption bug in context manager. (#26534) 2026-05-05 22:50:01 +00:00
joshualitt 0803007c8f fix(core): Minor fixes for generalist profile. (#26357) 2026-05-05 19:32:13 +00:00
joshualitt de8fdcfa16 Fix bulk of remaining issues with generalist profile (#26073) 2026-05-01 22:04:39 +00:00
joshualitt 71f313b51a feat(core): wire up the new ContextManager and AgentChatHistory (#25409) 2026-04-27 18:50:00 +00:00
joshualitt daf5006237 feat(core): introduce decoupled ContextManager and Sidecar architecture (#24752) 2026-04-13 22:02:22 +00:00
joshualitt e0044f2868 feat(core): Land ContextCompressionService (#24483) 2026-04-02 16:22:04 +00:00
joshualitt fd5c103f99 refactor(core): Centralize context management logic into src/context (#24380) 2026-04-01 00:01:46 +00:00