Use compaction model context limit
This commit is contained in:
parent
8553bc7283
commit
9330632402
|
|
@ -320,9 +320,19 @@ func (ag *Agent) executeTurn(ctx context.Context, input string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// autoCompactLimit returns the token threshold for auto-compaction (75%).
|
||||
// autoCompactLimit returns the token threshold for auto-compaction (75% of
|
||||
// the compaction model's context window). Compaction may use a different model
|
||||
// from the active turn model, so querying the active model here can overestimate
|
||||
// the request limit.
|
||||
func (ag *Agent) autoCompactLimit(ctx context.Context) int {
|
||||
ctxLen := ag.runtime.Backend.ContextLength(ctx)
|
||||
b := ag.runtime.Backend
|
||||
compactModel := resolveCompactionModel(ag.runtime.CompactionModel, b)
|
||||
origModel := b.Model()
|
||||
if compactModel != "" && compactModel != origModel {
|
||||
b.SetModel(compactModel)
|
||||
defer b.SetModel(origModel)
|
||||
}
|
||||
ctxLen := b.ContextLength(ctx)
|
||||
if ctxLen <= 0 {
|
||||
ctxLen = defaultContextLength
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue