effectiveContextLimit returns the context budget the running session operates within: the primary model's window, capped by the dedicated compaction model's (smaller) window when one is configured. It drives both the proactive compaction trigger and the UI context gauge, so the gauge fills to ~90% r
(ctx context.Context, a *agent.Agent, primaryLimit int64)
| 204 | // window is resolvable (e.g. a local primary absent from the catalogue), that |
| 205 | // window is used so compaction still runs. |
| 206 | func (r *LocalRuntime) effectiveContextLimit(ctx context.Context, a *agent.Agent, primaryLimit int64) int64 { |
| 207 | if a == nil || a.CompactionModel() == nil { |
| 208 | return primaryLimit |
| 209 | } |
| 210 | compactionLimit := r.compactionContextLimit(ctx, a) |
| 211 | if compactionLimit <= 0 { |
| 212 | return primaryLimit |
| 213 | } |
| 214 | if primaryLimit <= 0 { |
| 215 | return compactionLimit |
| 216 | } |
| 217 | return min(primaryLimit, compactionLimit) |
| 218 | } |
| 219 | |
| 220 | // resolveContextLimit resolves the effective context window size for a |
| 221 | // model. Resolution order: |