Skip to content

Add DeepSeek context budget diagnostics - #22

Merged
likun666661 merged 2 commits into
apache:mainfrom
likun666661:deepseek-context-budget-phase3
Jun 16, 2026
Merged

Add DeepSeek context budget diagnostics#22
likun666661 merged 2 commits into
apache:mainfrom
likun666661:deepseek-context-budget-phase3

Conversation

@likun666661

@likun666661likun666661 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Refs #19

Summary

  • Add prompt segment attribution for model calls: system prompt, tool schema, prior history, current user content, and volatile turn tail.
  • Add a conservative RuntimeEvent prior-history budget that keeps whole recent turns so tool-call/result pairs are not split.
  • Thread promptSegments and contextBudget diagnostics through usage events, RuntimeEvents, stored token usage messages, RunTrace, and telemetry logs.
  • Add a product-path DeepSeek live cost harness: npm run cost:deepseek-baseline.
  • Enable a provider-aware desktop history budget, with DeepSeek defaulting to 256_000 estimated prior-history tokens and non-DeepSeek providers staying at 32_000, plus env overrides:
    • MAKA_CONTEXT_BUDGET=off
    • MAKA_CONTEXT_HISTORY_BUDGET_TOKENS
    • MAKA_CONTEXT_HISTORY_BUDGET_TURNS
    • MAKA_CONTEXT_MIN_RECENT_TURNS

Live DeepSeek Findings

  • Fresh no-tool 8-turn baseline from Phase 3 prep: input 86,456, cache hit 64,384, cache miss 22,072, estimated cost $0.01047512.
  • Aggressive 4.5k budget live run: input dropped to 61,942, but cache miss rose to 36,982, estimated cost $0.01174114; the cap bounded prompt size but disrupted provider cache economics.
  • 12k budget live run: input 84,762, cache hit 52,864, cache miss 31,898, estimated cost $0.01232174; trimming began around turn 8 and still caused a cold miss.
  • Based on those runs and DeepSeek v4's much larger context window, this PR uses 256_000 as the DeepSeek default so the budget is a long-session guardrail rather than an early cache-disrupting trim. Tighter caps remain explicit env/harness experiments.

Verification

  • npm run typecheck --workspaces --if-present
  • npm --workspace @maka/runtime test
  • npm run test --workspaces --if-present (1399/1399)
  • node --check scripts/deepseek-live-cost-baseline.mjs
  • git diff --check
  • Live DeepSeek harness runs with 4.5k and 12k history-budget caps

@likun666661
likun666661force-pushed the deepseek-context-budget-phase3 branch from 0240762 to 20a1e42CompareJune 16, 2026 05:23
@likun666661
likun666661 merged commit b2b1be9 into apache:mainJun 16, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
Astro-Han added a commit that referenced this pull request Jul 5, 2026
…contract
- P2-1: InputGroupInput/Textarea spread props before unstyled and
data-maka-field-chrome so a caller's unstyled={false} cannot re-enable
the inner chrome (would double the border / focus ring). The InputGroup
owns the chrome; the inner control stays bare.
- P2-2: port type="search" WebKit cancel/decoration/results reset into
primitives/input. Main's primitives/input always applied this for
InputGroupInput (search-modal path); the unified Input keeps the
contract for both the @maka/ui Input and InputGroupInput paths.
size/nativeInput/type=file variants audited — no callers in repo
(@maka/ui Input was ui.tsx without these; InputGroupInput never
passed them); removed without a compat layer.
- P3-1: rewrite input-canonical-contract as behavior tests only — no
source regex. Styled/unstyled single element + chrome, InputGroup
force-bare even with unstyled={false}, type="search" webkit reset,
barrel import smoke.
- P3-2: #22 PR10 -> #520 item 22 in comments (the PR流水号 narrative
pointed at the wrong tracker).
Astro-Han added a commit that referenced this pull request Jul 6, 2026
… Input (#520 item 22) (#555)
* feat(ui): canonical Input/Textarea onto Base UI, retire native ui.tsx Input (#22 PR10)
#22 PR10: collapse the dual Input tracks onto one canonical
primitives/input.tsx + primitives/textarea.tsx, retiring the native ui.tsx
Input/Textarea.
- primitives/input.tsx now wraps Base UI's Input primitive with maka's
inputClasses styling ported as the default chrome. Stays a single <input>
(no span wrapper) so caller CSS targeting `> input` / `input:focus-visible`
still matches. unstyled gives the bare form (bareFieldClasses +
data-maka-field-chrome="none") for Field/InputGroup embedding.
- primitives/textarea.tsx parallel shape: single <textarea> + inputClasses +
textarea sizing. Base UI ships no Textarea, so this is a native textarea.
Drops the Base UI Field.Control + span wrapper (caller doesn't use Field).
- ui.tsx Input, Textarea, inputClasses, bareFieldClasses retired. inputClasses +
bareFieldClasses moved into primitives/input.tsx (exported) so number-field
keeps its standalone NumberFieldInput chrome.
- InputGroup: InputGroupInput/InputGroupTextarea already pass unstyled (inner
field bare, InputGroup owns the chrome — no double chrome). InputGroup CSS
updated to key off data-slot="input"/"textarea" (the single element) instead
of the retired span data-slot="input-control"/"textarea-control"; dropped the
span-only `:contents` / `:before:hidden` rules.
- index.ts re-exports primitives/input + primitives/textarea as the canonical
Input/Textarea; the 44 usages across 9 settings files keep importing from
@maka/ui unchanged.
- Contracts: new input-canonical-contract (single element, inputClasses token
lock, ui.tsx retired, bare-field shape); field-chrome.test rewritten for the
unified shape (drops nativeInput/h-8.5/field-sizing-content assertions that
pinned the old primitives/input vs ui.tsx divergence); radius-converge
inputClasses tier repointed at primitives/input.tsx.
Verification: typecheck clean; @maka/ui test 43/43; @maka/desktop test
2069/2069. Screenshot pixel diff vs main: settings-general and settings-bots
light/dark 1280 AE=0 (pixel-identical, both contain Input). settings-data
364 px (edge); settings-appearance/daily-review ~9-10K px in a 12px right-edge
column (window edge, not input/textarea); settings-memory ~18K px in a large
content block (main-branch composer/sidebar commits #510/#511, not this PR).
* fix(ui): PR10 review — InputGroup force-bare, search reset, behavior contract
- P2-1: InputGroupInput/Textarea spread props before unstyled and
data-maka-field-chrome so a caller's unstyled={false} cannot re-enable
the inner chrome (would double the border / focus ring). The InputGroup
owns the chrome; the inner control stays bare.
- P2-2: port type="search" WebKit cancel/decoration/results reset into
primitives/input. Main's primitives/input always applied this for
InputGroupInput (search-modal path); the unified Input keeps the
contract for both the @maka/ui Input and InputGroupInput paths.
size/nativeInput/type=file variants audited — no callers in repo
(@maka/ui Input was ui.tsx without these; InputGroupInput never
passed them); removed without a compat layer.
- P3-1: rewrite input-canonical-contract as behavior tests only — no
source regex. Styled/unstyled single element + chrome, InputGroup
force-bare even with unstyled={false}, type="search" webkit reset,
barrel import smoke.
- P3-2: #22 PR10 -> #520 item 22 in comments (the PR流水号 narrative
pointed at the wrong tracker).
* fix(ui): drop redundant data-maka-field-chrome on InputGroup adapters
The canonical Input/Textarea already force data-maka-field-chrome="none"
when unstyled (the {...props} spread precedes the attribute in both
primitives, so a caller cannot override it). The adapter passing it
explicitly was a no-op. Drop the redundant attribute; keep unstyled.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@likun666661