Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ export function validateConfigTypes(config: Record<string, any>): ValidationErro
actual: typeof config.turnProtection.turns,
})
}
if (typeof config.turnProtection.turns === "number" && config.turnProtection.turns < 1) {
errors.push({
key: "turnProtection.turns",
expected: "positive number (>= 1)",
actual: `${config.turnProtection.turns}`,
})
}
}

// Commands validator
Expand Down Expand Up @@ -326,6 +333,16 @@ export function validateConfigTypes(config: Record<string, any>): ValidationErro
actual: typeof tools.settings.nudgeFrequency,
})
}
if (
typeof tools.settings.nudgeFrequency === "number" &&
tools.settings.nudgeFrequency < 1
) {
errors.push({
key: "tools.settings.nudgeFrequency",
expected: "positive number (>= 1)",
actual: `${tools.settings.nudgeFrequency} (will be clamped to 1)`,
})
}
if (
tools.settings.protectedTools !== undefined &&
!Array.isArray(tools.settings.protectedTools)
Expand Down Expand Up @@ -497,6 +514,17 @@ export function validateConfigTypes(config: Record<string, any>): ValidationErro
actual: typeof strategies.purgeErrors.turns,
})
}
// Warn if turns is 0 or negative - will be clamped to 1
if (
typeof strategies.purgeErrors.turns === "number" &&
strategies.purgeErrors.turns < 1
) {
errors.push({
key: "strategies.purgeErrors.turns",
expected: "positive number (>= 1)",
actual: `${strategies.purgeErrors.turns} (will be clamped to 1)`,
})
}
if (
strategies.purgeErrors.protectedTools !== undefined &&
!Array.isArray(strategies.purgeErrors.protectedTools)
Expand Down
2 changes: 1 addition & 1 deletion lib/messages/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const insertPruneToolContext = (
contentParts.push(renderCompressNudge())
} else if (
config.tools.settings.nudgeEnabled &&
state.nudgeCounter >= config.tools.settings.nudgeFrequency
state.nudgeCounter >= Math.max(1, config.tools.settings.nudgeFrequency)
) {
logger.info("Inserting prune nudge message")
contentParts.push(getNudgeString(config))
Expand Down
2 changes: 1 addition & 1 deletion lib/strategies/purge-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const purgeErrors = (
}

const protectedTools = config.strategies.purgeErrors.protectedTools
const turnThreshold = config.strategies.purgeErrors.turns
const turnThreshold = Math.max(1, config.strategies.purgeErrors.turns)

const newPruneIds: string[] = []

Expand Down