mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
The host appended a <context-budget> block to the turn tail at 75% and 92% of the compaction trigger and raised a matching warning card. The model can still ask: the read-only context_budget tool and its figures are unchanged, and its description now says when to check, since nothing reports it unprompted.
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package agent
|
|
|
|
import "reasonix/internal/contract/tool"
|
|
|
|
// ContextBudget reports the room left before the next automatic fold, measured
|
|
// with the estimate the compaction thresholds themselves compare against so
|
|
// what the model is told and what the host acts on cannot drift apart.
|
|
func (a *Agent) ContextBudget() tool.ContextBudget {
|
|
if a == nil {
|
|
return unmeasuredContextBudget("no active agent session")
|
|
}
|
|
return a.window().contextBudget()
|
|
}
|
|
|
|
func (a *contextWindow) contextBudget() tool.ContextBudget {
|
|
trigger := a.compactTrigger()
|
|
window := a.effectiveContextWindow()
|
|
if trigger <= 0 || window <= 0 {
|
|
return unmeasuredContextBudget("the active provider declares no context window, so compaction is disabled")
|
|
}
|
|
used := a.contextUsedTokens()
|
|
return tool.ContextBudget{
|
|
Status: "ok",
|
|
TokensRemaining: max(0, trigger-used),
|
|
TokensUsed: used,
|
|
CompactAt: trigger,
|
|
Window: window,
|
|
}
|
|
}
|
|
|
|
func unmeasuredContextBudget(reason string) tool.ContextBudget {
|
|
return tool.ContextBudget{Status: "unmeasured", Reason: reason}
|
|
}
|