fix(loader): the duplicate-tool-name error names one side twice, at line 0 #12
Labels
No labels
area/engine
clarity/clear
enhancement
security
size/M
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
basepeak-ai/gptscript#12
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When two tools collide,
pkg/loader/loader.go:314-318reports:For tools that came out of an MCP bundle, both line numbers are 0 and both
locations are the same string, so the message reads
which names one side twice and locates neither.
Why the zeros
pkg/mcp/loader.gonever setsSourceon the tools it synthesises — there isno
Sourceassignment in the file at all.loader.go:262-264then fills inpart of it for every tool:
Source.LineNois not among them, so it keeps its zero value. An MCP-expandedtool has no line to point at, because it was never parsed from a file — and
Locationis overwritten withbase.Locationfor both sides of the collision,so the two operands are identical by construction.
Why it is worth fixing
This is the diagnostic for a whole defect class, and it currently carries no
information. bpai#1077 is the live example: gptscript expands a bundle into
<toolRefName>_<rawName>(pkg/mcp/loader.go:150,namespacedToolName)inside
processMCP(loader.go:251) — before this check — so an agent or aproject custom tool named
bpcrm_searchcollides with a sub-tool of thebpcrmbundle. What the user sees is that nothing in the project works, andthe error names neither the bundle nor their own tool as the other side.
Fixing the message does not fix bpai#1077 — the collision still happens.
It turns "nothing works and the message is useless" into a five-second
diagnosis, for that bug and for every other member of the class.
Suggested shape
Two pieces of information are missing and both are available at the call site:
existingandtoolare distinct objects; themessage should describe both, not print one twice.
have a bundle — the namespace
namespacedToolNameprefixed it with. Namingthat ("from MCP bundle
bpcrm" vs "declared in<file>line N") is whatmakes the message actionable.
Degrading gracefully when
LineNo == 0is the minimum: printing "lines 0 and0" is worse than omitting the line numbers entirely.
Precedent in this fork:
b9cd975("fix(loader): name the MCP tool a loadfailure belongs to", #11) is the same kind of fix on the neighbouring error
path.
Related
render may reserve the namespaced child names from
Status.Tool.Params, atthe cost of making program assembly depend on controller status that is stale
by construction. This issue is independent of that decision and worth doing
either way.