feat: show tools mode (disabled/passthrough) in startup and request logs

- Startup log: Tools: disabled / passthrough / schema=full
- Request log: tools=98(跳过) / tools=98(透传) / tools=98
This commit is contained in:
小海
2026-03-20 09:26:23 +08:00
parent 4a026b6b98
commit db5d3fb1f7
2 changed files with 19 additions and 7 deletions

View File

@@ -159,12 +159,18 @@ app.listen(config.port, () => {
const toolsCfg = config.tools;
let toolsInfo = 'default (full, desc=full)';
if (toolsCfg) {
const parts: string[] = [];
parts.push(`schema=${toolsCfg.schemaMode}`);
parts.push(toolsCfg.descriptionMaxLength === 0 ? 'desc=full' : `desc≤${toolsCfg.descriptionMaxLength}`);
if (toolsCfg.includeOnly?.length) parts.push(`whitelist=${toolsCfg.includeOnly.length}`);
if (toolsCfg.exclude?.length) parts.push(`blacklist=${toolsCfg.exclude.length}`);
toolsInfo = parts.join(', ');
if (toolsCfg.disabled) {
toolsInfo = '\x1b[33mdisabled\x1b[0m (不注入工具定义,节省上下文)';
} else if (toolsCfg.passthrough) {
toolsInfo = '\x1b[36mpassthrough\x1b[0m (原始 JSON 嵌入)';
} else {
const parts: string[] = [];
parts.push(`schema=${toolsCfg.schemaMode}`);
parts.push(toolsCfg.descriptionMaxLength === 0 ? 'desc=full' : `desc≤${toolsCfg.descriptionMaxLength}`);
if (toolsCfg.includeOnly?.length) parts.push(`whitelist=${toolsCfg.includeOnly.length}`);
if (toolsCfg.exclude?.length) parts.push(`blacklist=${toolsCfg.exclude.length}`);
toolsInfo = parts.join(', ');
}
}
console.log('');

View File

@@ -316,7 +316,13 @@ export function createRequestLogger(opts: {
requestPayloads.delete(oldId);
}
const toolInfo = opts.hasTools ? ` tools=${opts.toolCount}` : '';
const toolMode = (() => {
const cfg = getConfig().tools;
if (cfg?.disabled) return '(跳过)';
if (cfg?.passthrough) return '(透传)';
return '';
})();
const toolInfo = opts.hasTools ? ` tools=${opts.toolCount}${toolMode}` : '';
const fmtTag = summary.apiFormat === 'openai' ? ' [OAI]' : summary.apiFormat === 'responses' ? ' [RSP]' : '';
console.log(`\x1b[36m⟶\x1b[0m [${requestId}] ${opts.method} ${opts.path}${fmtTag} | model=${opts.model} stream=${opts.stream}${toolInfo} msgs=${opts.messageCount}`);