Skip to content

fix(lib-vue): warn instead of throwing on duplicate useAgentTool registration#51

Merged
albanm merged 1 commit into
mainfrom
fix-agent-tool-idempotent
Jun 30, 2026
Merged

fix(lib-vue): warn instead of throwing on duplicate useAgentTool registration#51
albanm merged 1 commit into
mainfrom
fix-agent-tool-idempotent

Conversation

@BatLeDev

Copy link
Copy Markdown
Member

useAgentTool called navigator.modelContext.registerTool() with no guard. registerTool() throws when a tool name is already registered — e.g. two components register the same name, or a previous instance's onScopeDispose hasn't run yet during client-side navigation (such as two portal blocks sharing a uuid). The throw escaped into the caller's setup() and blanked its render.

Wrap the call in a try/catch: on failure, log a clear console.warn and skip registering a disposer, so the caller's setup() always completes.

Why: a duplicate tool name is a usage error to fix at the source. The library should surface it loudly rather than crash the consuming component's render.

Heads-up: any registerTool error (including a malformed descriptor, not just a duplicate name) is now logged instead of thrown — intentional, to never break the caller's render, but it means descriptor mistakes surface as a warning rather than an exception.

…stration

navigator.modelContext.registerTool() throws when a tool name is already
registered. useAgentTool registers synchronously in setup(), so when a new
instance mounts before the previous one's onScopeDispose runs — e.g.
client-side navigation between two components that register the same tool name
(such as two portal pages whose application blocks share a uuid) — the throw
escapes and blanks the caller's render.

Catch the error, log it as a warning, and skip registration so the caller's
setup() completes. A duplicate tool name is a usage error to fix at the source;
the library surfaces it loudly rather than masking it by swapping registrations.
@github-actions github-actions Bot added the fix label Jun 30, 2026
@albanm albanm merged commit b7df676 into main Jun 30, 2026
4 checks passed
@albanm albanm deleted the fix-agent-tool-idempotent branch June 30, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants