robustness(core): static checks to validate history is immutable (#21228)

This commit is contained in:
Jacob Richman
2026-03-09 11:26:03 -07:00
committed by GitHub
parent e7b20c49ac
commit 4c9f9bb3e2
13 changed files with 34 additions and 31 deletions
@@ -43,7 +43,7 @@ const EXEMPT_TOOLS = new Set([
]);
export interface MaskingResult {
newHistory: Content[];
newHistory: readonly Content[];
maskedCount: number;
tokensSaved: number;
}
@@ -67,7 +67,10 @@ export interface MaskingResult {
* are preserved until they collectively reach the threshold.
*/
export class ToolOutputMaskingService {
async mask(history: Content[], config: Config): Promise<MaskingResult> {
async mask(
history: readonly Content[],
config: Config,
): Promise<MaskingResult> {
const maskingConfig = await config.getToolOutputMaskingConfig();
if (!maskingConfig.enabled || history.length === 0) {
return { newHistory: history, maskedCount: 0, tokensSaved: 0 };