chore(pi-claude-cli): include prompt head + custom names in rewrite diagnostic

User reports "no custom tool refs to rewrite (tools=18)" — meaning Context.tools
is populated but the prompt body doesn't contain any of the names. Need the
first 200 chars of the prompt and a sample of custom-tool names to figure out
whether the engine's customPrompt is reaching us at all or whether names
differ from what we expect.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-25 17:09:24 -07:00
parent 39622f0398
commit bd6a327daf

View File

@@ -448,7 +448,7 @@ function rewriteCustomToolReferences(
): string { ): string {
if (!prompt || !tools || tools.length === 0) { if (!prompt || !tools || tools.length === 0) {
console.error( console.error(
`[pi-claude-cli] system prompt rewrite skipped (tools=${tools?.length ?? 0})`, `[pi-claude-cli] system prompt rewrite skipped (tools=${tools?.length ?? 0}, promptLen=${prompt?.length ?? 0})`,
); );
return prompt; return prompt;
} }
@@ -481,8 +481,13 @@ function rewriteCustomToolReferences(
`[pi-claude-cli] system prompt: rewrote ${totalRewrites} custom tool ref(s) [${rewritten.join(", ")}]`, `[pi-claude-cli] system prompt: rewrote ${totalRewrites} custom tool ref(s) [${rewritten.join(", ")}]`,
); );
} else { } else {
const customNames = tools
.filter((t) => !BUILT_IN_PI_TOOLS.has(t.name))
.map((t) => t.name)
.slice(0, 6);
const promptHead = prompt.slice(0, 200).replace(/\n/g, " ");
console.error( console.error(
`[pi-claude-cli] system prompt: no custom tool refs to rewrite (tools=${tools.length})`, `[pi-claude-cli] system prompt: no custom tool refs to rewrite (tools=${tools.length}, promptLen=${prompt.length}, customNamesSample=[${customNames.join(",")}], promptHead="${promptHead}")`,
); );
} }
return result; return result;