feat(core): exempt high-signal tools from output masking (#18545)

This commit is contained in:
Abhi
2026-02-07 18:56:45 -05:00
committed by GitHub
parent 979bbee485
commit a1f2aacd1e
2 changed files with 139 additions and 2 deletions
@@ -12,7 +12,14 @@ import { debugLogger } from '../utils/debugLogger.js';
import { sanitizeFilenamePart } from '../utils/fileUtils.js';
import type { Config } from '../config/config.js';
import { logToolOutputMasking } from '../telemetry/loggers.js';
import { SHELL_TOOL_NAME } from '../tools/tool-names.js';
import {
SHELL_TOOL_NAME,
ACTIVATE_SKILL_TOOL_NAME,
MEMORY_TOOL_NAME,
ASK_USER_TOOL_NAME,
ENTER_PLAN_MODE_TOOL_NAME,
EXIT_PLAN_MODE_TOOL_NAME,
} from '../tools/tool-names.js';
import { ToolOutputMaskingEvent } from '../telemetry/types.js';
// Tool output masking defaults
@@ -23,6 +30,18 @@ export const MASKING_INDICATOR_TAG = 'tool_output_masked';
export const TOOL_OUTPUTS_DIR = 'tool-outputs';
/**
* Tools whose outputs are always high-signal and should never be masked,
* regardless of their position in the conversation history.
*/
const EXEMPT_TOOLS = new Set([
ACTIVATE_SKILL_TOOL_NAME,
MEMORY_TOOL_NAME,
ASK_USER_TOOL_NAME,
ENTER_PLAN_MODE_TOOL_NAME,
EXIT_PLAN_MODE_TOOL_NAME,
]);
export interface MaskingResult {
newHistory: Content[];
maskedCount: number;
@@ -89,6 +108,11 @@ export class ToolOutputMaskingService {
// core intent and logic, which are harder for the model to recover if lost.
if (!part.functionResponse) continue;
const toolName = part.functionResponse.name;
if (toolName && EXEMPT_TOOLS.has(toolName)) {
continue;
}
const toolOutputContent = this.getToolOutputContent(part);
if (!toolOutputContent || this.isAlreadyMasked(toolOutputContent)) {
continue;