fix(lib-vue): warn instead of throwing on duplicate useAgentTool registration#51
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
useAgentToolcallednavigator.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'sonScopeDisposehasn't run yet during client-side navigation (such as two portal blocks sharing a uuid). The throw escaped into the caller'ssetup()and blanked its render.Wrap the call in a
try/catch: on failure, log a clearconsole.warnand skip registering a disposer, so the caller'ssetup()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
registerToolerror (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.