How is the use human-in-the-loop hook used with the respond part specifically? Let's just say I were to ask a question, and then send me to the moon, and that triggers a respond (like a human loop component) which has a thing that's like "respond, what's the weather today?" What's getting passed to the backend? Is it both the first message and what I put in the response, or is it just the respond? How does that work?
#UseHumanInTheLoop
1 messages · Page 1 of 1 (latest)
This solution has been AI generated
When you call respond(...) inside useHumanInTheLoop, the backend receives your human response as the action's arguments, and the original message/context is preserved via message threading. It’s not sent as a separate field again; it’s referenced via parentMessageId so the backend has the full context.
What gets sent to the backend
- The human response you pass to
respond(data)is serialized and sent as the action'sargs. - The request includes identifiers that link it to the original message/thread.
- Example payload structure:
{
"actionExecutionId": "<id>",
"actionName": "<your-action-name>",
"args": "<JSON string of the data you passed to respond()>",
"parentMessageId": "<links to original message>",
"status": "executing|inProgress|complete"
}
Backend endpoint: a POST to the remote action executor (e.g., /actions/execute) with the full execution payload.
Original message and context
- The original user message (and full history) is preserved via
parentMessageIdand thread continuity. - Practically: the backend explicitly receives your human-in-the-loop response in
args, and can retrieve the original context via the message/thread reference.
Example usage
useHumanInTheLoop({
name: "approval",
description: "Get human approval",
render: ({ args, respond, status }) => (
<div>
<button onClick={() => respond({ approved: true })}>Approve</button>
<button onClick={() => respond({ approved: false })}>Deny</button>
</div>
),
});
In this example, the backend receives { approved: true } as args, plus the IDs that link back to the original message and thread.
Was this helpful?
If this solution worked for you, please click on the appropriate option below to help us improve: