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

Method compactionContextLimit

pkg/runtime/session_compaction.go:173–189  ·  view source on GitHub ↗

compactionContextLimit returns the context-window limit of the model that generates the summary: the dedicated compaction model when one is configured, otherwise the agent's own model. Returns 0 when it can't be resolved. Failure is non-fatal: a before_compaction hook may supply its own summary and

(ctx context.Context, a *agent.Agent)

Source from the content-addressed store, hash-verified

171// pass the cloned summary-call provider so its provider_opts (which
172// match the underlying model) are considered.
173func (r *LocalRuntime) compactionContextLimit(ctx context.Context, a *agent.Agent) int64 {
174 if a == nil {
175 return 0
176 }
177 model := a.CompactionModel()
178 if model == nil {
179 model = a.Model(ctx)
180 }
181 if model == nil {
182 return 0
183 }
184 summaryModel := provider.CloneWithOptions(ctx, model,
185 options.WithStructuredOutput(nil),
186 options.WithMaxTokens(compactor.MaxSummaryTokens),
187 )
188 return r.resolveContextLimit(ctx, summaryModel, summaryModel.ID())
189}
190
191// effectiveContextLimit returns the context budget the running session
192// operates within: the primary model's window, capped by the dedicated

Calls 7

resolveContextLimitMethod · 0.95
CloneWithOptionsFunction · 0.92
WithStructuredOutputFunction · 0.92
WithMaxTokensFunction · 0.92
CompactionModelMethod · 0.80
ModelMethod · 0.80
IDMethod · 0.65