MCPcopy
hub / github.com/docker/docker-agent / effectiveContextLimit

Method effectiveContextLimit

pkg/runtime/session_compaction.go:206–218  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

204// window is resolvable (e.g. a local primary absent from the catalogue), that
205// window is used so compaction still runs.
206func (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:

Callers 4

runStreamLoopMethod · 0.95
compactWithReasonMethod · 0.95

Calls 2

CompactionModelMethod · 0.80

Tested by 1