Skip to content

fix(synapse): context-tracker hardcoded to 200K — should read model context window dynamically #605

@LeandroMachadoAveiro

Description

@LeandroMachadoAveiro

Problem

The context-tracker.js module has maxContext: 200000 hardcoded as default. With Claude Opus 4.6 (1M context window), this causes premature bracket escalation:

Prompts With 200K (current) With 1M (correct)
50 32.5% → DEPLETED 91% → FRESH
100 10% → CRITICAL 82% → FRESH
133 0% → CRITICAL 76% → FRESH

Impact: Handoff warnings firing prematurely, unnecessary heavy token injection (2500 budget instead of 800), and false CRITICAL state when 80%+ context is still available.

Root Cause

context-tracker.js line 57:

const DEFAULTS = {
  avgTokensPerPrompt: 1500,
  maxContext: 200000, // ← hardcoded, doesn't reflect actual model
};

Fix Applied

1. Model registry in core-config.yaml

models:
  active: claude-opus-4-6
  registry:
    claude-opus-4-6:
      contextWindow: 1000000
      avgTokensPerPrompt: 1500
    claude-sonnet-4-6:
      contextWindow: 200000
      avgTokensPerPrompt: 1500
    claude-haiku-4-5:
      contextWindow: 200000
      avgTokensPerPrompt: 1200

2. context-tracker.jsgetModelConfig()

New function reads models.active from core-config.yaml, resolves the contextWindow from the registry, and passes it to estimateContextPercent(). Features:

  • Cached per process (read once, no I/O overhead)
  • Graceful fallback to 200K default if config missing/malformed
  • Backward-compatibleoptions parameter still allows override for tests
  • resetModelConfigCache() exported for test cleanup

3. Version bump

context-tracker.js v1.0.0 → v1.1.0

Recommendation for Developers

  1. Add the models section to your project's core-config.yaml
  2. Set models.active to match your Claude Code model
  3. When new models are released, add them to the registry

Files Changed

  • .aiox-core/core-config.yaml — added models section
  • .aiox-core/core/synapse/context/context-tracker.js — dynamic config reader

Commit

9dd94fbfix(synapse): dynamic context window from model registry instead of hardcoded 200K

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions