-
Notifications
You must be signed in to change notification settings - Fork 3.5k
renderCall/renderResult overrides silently ignored for built-in tools since v0.62.0 #2595
Description
What happened?
Since v0.62.0, registering a custom renderCall/renderResult for a built-in tool (via pi.registerTool with the same name) has no effect. This breaks the minimal-mode example extension.
Cause
The v0.62.0 rewrite of tool-execution.ts replaced shouldUseBuiltInRenderer() check with
isBuiltInDefinition():
// v0.62.0 — broken
isBuiltInDefinition(definition) {
return (
this.builtInToolDefinition !== undefined &&
definition.parameters === this.builtInToolDefinition.parameters // reference equality
);
}
// Then:
if (!this.toolDefinition || this.isBuiltInDefinition(this.toolDefinition)) {
return this.builtInToolDefinition.renderResult; // extension's renderResult ignored!
}Because all built-in tool definitions return the same module-level parameter schema singleton (e.g. readSchema), any extension that borrows the parameters via createReadTool().parameters or createReadToolDefinition().parameters will match this check and have its renderers silently ignored.
The pre-v0.62.0 implementation handled this correctly:
// Pre-v0.62.0 — correct
private shouldUseBuiltInRenderer(): boolean {
const isBuiltInName = this.toolName in allTools;
const hasCustomRenderers = this.toolDefinition?.renderCall || this.toolDefinition?.renderResult;
return isBuiltInName && !hasCustomRenderers; // checks actual renderer presence, not parameter identity
}Workaround
I've managed to work around this by modifying the minimal-mode extension to fail the reference equality check by spreading the borrowed parameters into a new object. For example:
parameters: createReadTool(cwd).parameters // doesn't work
parameters: { ...createReadTool(cwd).parameters } // worksThe fact that this works also suggests that the hypothesis above is correct.
Steps to reproduce
You can observe this by trying to use the example minimal-mode extension which does not work anymore, which is how I initially discovered the issue.
Expected behavior
The minimal-mode extension should let you cycle to a minimal view mode with Ctrl-O.
Version
0.62.0