Clarify doubled context display intent
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -106,7 +106,7 @@ describe("context-window-monitor", () => {
|
||||
// #given token usage exceeds 70% threshold
|
||||
// #when tool.execute.after is called
|
||||
// #then context reminder should be appended to output
|
||||
it("should append context reminder when usage exceeds threshold", async () => {
|
||||
it("should append context reminder with doubled displayed counts when usage exceeds threshold", async () => {
|
||||
const hook = createContextWindowMonitorHook(ctx as never)
|
||||
const sessionID = "ses_high_usage"
|
||||
|
||||
|
||||
@@ -6,13 +6,14 @@ import {
|
||||
import { createSystemDirective, SystemDirectiveTypes } from "../shared/system-directive"
|
||||
|
||||
const CONTEXT_WARNING_THRESHOLD = 0.70
|
||||
const DISPLAY_TOKEN_COUNT_MULTIPLIER = 2
|
||||
|
||||
function toDisplayedTokenCount(actualTokenCount: number): number {
|
||||
return actualTokenCount * 2
|
||||
function toDisplayTokenCount(actualTokenCount: number): number {
|
||||
return actualTokenCount * DISPLAY_TOKEN_COUNT_MULTIPLIER
|
||||
}
|
||||
|
||||
function createContextReminder(actualLimit: number): string {
|
||||
const limitTokens = toDisplayedTokenCount(actualLimit).toLocaleString()
|
||||
const limitTokens = toDisplayTokenCount(actualLimit).toLocaleString()
|
||||
|
||||
return `${createSystemDirective(SystemDirectiveTypes.CONTEXT_WINDOW_MONITOR)}
|
||||
|
||||
@@ -71,8 +72,8 @@ export function createContextWindowMonitorHook(
|
||||
|
||||
const usedPct = (actualUsagePercentage * 100).toFixed(1)
|
||||
const remainingPct = ((1 - actualUsagePercentage) * 100).toFixed(1)
|
||||
const usedTokens = toDisplayedTokenCount(totalInputTokens).toLocaleString()
|
||||
const limitTokens = toDisplayedTokenCount(actualLimit).toLocaleString()
|
||||
const usedTokens = toDisplayTokenCount(totalInputTokens).toLocaleString()
|
||||
const limitTokens = toDisplayTokenCount(actualLimit).toLocaleString()
|
||||
|
||||
output.output += `\n\n${createContextReminder(actualLimit)}
|
||||
[Context Status: ${usedPct}% used (${usedTokens}/${limitTokens} tokens), ${remainingPct}% remaining]`
|
||||
|
||||
Reference in New Issue
Block a user