how to implicitly deny tool approvals when users submit messages in human-in-the-loop? #7493
Unanswered
nikitatome
asked this question in
Help
Replies: 1 comment
-
You should process the messages before you create the UI stream: export async function processToolOutput(args: {
messages: AppUIMessage[]
}): Promise<{ messages: AppUIMessage[]; parts: InferUIMessageChunk<AppUIMessage>[] }> {
const result: { messages: AppUIMessage[]; parts: InferUIMessageChunk<AppUIMessage>[] } = {
messages: args.messages,
parts: [],
};
...
}
const processToolResult = await processToolOutput({
messages: messages,
});
messages = processToolResult.messages;
const uiMessageStream = createUIMessageStream<AppUIMessage>({
originalMessages: messages,
execute: async ({ writer }) => {
for (const part of processToolResult.parts) {
writer.write(part);
}
const chatStream = streamText({ As soon as you create the stream you write the parts you prepared when processing the messages. There you can modify the messages to implicitly deny and queue the parts you need to write so the UI is up to date. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We have a confirmation interface in our v5 app implemented similar to the v4 human-in-the-loop guide. If the user submits a new message, then we want to implicitly deny the tool call. However it's unclear what the proper way is to do this.
If we add the tool result, then the backend will continue it's execution and stream a response back. Ideally we'd like to add the tool result and submit the new message simultaneously from the front end, before the backend resumes execution.
Alternatively, we could process messages with incomplete tool calls on the backend. However, the stream writer only has access to the current ui message, so we're unable to stream the updated older messages to the front end.
Beta Was this translation helpful? Give feedback.
All reactions