-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: clean up two explicit errors handled elsewhere #138
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for hardfunai canceled.
|
// Errors can be thrown when recursive call is cancelled | ||
if (errorMessage.includes('JSON')) { | ||
errorMessage = 'You clicked cancel - please try again'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer an error after introducing JSON streaming parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup
const lastMessage = messages[messages.length - 1]; | ||
const lastMessageRole = lastMessage.role; | ||
|
||
// if a user has initiated a wallet-based tool call, but not confirmed or denied it | ||
// we don't want to add more messages to the history | ||
const userRequestInProgress = | ||
messages.length > 1 && lastMessageRole === 'user'; | ||
|
||
if (isRequesting || userRequestInProgress) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now early return from the streaming store if we get into a bad state and don't call the .write()
method which triggered the error when a user entered more messages after starting a tx, but never completing that tool call in metamask.
oros/src/toolCallStreamStore.ts
Lines 64 to 66 in 1d3f3c4
if (!streamParser) { | |
return; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason for the write error in the streaming store is because:
- model generates a single tool call which gets added to the toolCallStream store the index for the tool call is 0
- the tool call stream store parses the streaming json for the tool call and removes the underlying parser once the tool call stream is finished from the model.
- another tool call is made but it's scoped to a different request, however the problem is that the index of the new tool call corresponds with the old tool call which had it's parser removed, so when the new tool call json args are being streamed this is when the errors gets thrown. The problem here is that the old tool call from the previous request is not removed/resolved yet, and there's no way for us to know that this reffers to a different request all together since all we get is an index for each tool call request from the model. and those indices are scoped per request. so the problem here is that we shouldn't allow users to submit more requests until the previous tool call is resolved/removed in some way.
Summary
Removes two explicit error checks