-
Notifications
You must be signed in to change notification settings - Fork 46
docs: add human-in-the-loop page for AI Transport #3078
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
docs: add human-in-the-loop page for AI Transport #3078
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
aebe2c1 to
ea0ac8d
Compare
mschristensen
left a comment
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.
Thanks Greg, needs a rebase but commented on the HITL doc page. Some good ideas in there but have flagged some bits for discussion, let me know if you want to catch up on the approach.
| meta_keywords: "human in the loop, HITL, AI agent authorization, tool call approval, JWT claims, capabilities, admin approval, agentic workflows, AI safety, human oversight" | ||
| --- | ||
|
|
||
| Human-in-the-loop (HITL) enables human oversight of AI agent actions. When an agent needs to perform sensitive operations, such as modifying data, making purchases, or accessing restricted resources, the action is paused and routed to an authorized human for approval before execution. |
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.
| Human-in-the-loop (HITL) enables human oversight of AI agent actions. When an agent needs to perform sensitive operations, such as modifying data, making purchases, or accessing restricted resources, the action is paused and routed to an authorized human for approval before execution. | |
| Human-in-the-loop (HITL) enables human oversight of AI agent actions. When an agent needs to perform sensitive operations, such as modifying data, performing sensitive actions, or accessing restricted resources, the action is paused and routed to an authorized human for approval before execution. |
|
|
||
| AI agents are increasingly capable of taking autonomous actions, but certain operations require human judgment: | ||
|
|
||
| - **Safety**: Prevent unintended consequences from AI decisions. |
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.
I know we need to update the other pages, but I think you (correctly) argued in the past that we should not use bold prefixes in bullets, which smells like an LLM
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.
You're right! I asked Claude to review my work and improve where needed. I may have missed this! Updated.
| - **Trust**: Build user confidence by keeping humans in control of critical actions. | ||
| - **Accountability**: Create clear audit trails of who approved what actions. | ||
|
|
||
| HITL doesn't slow down AI — it ensures the right actions happen at the right time with appropriate oversight. |
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.
This feels like typical AI word salad, how about:
| HITL doesn't slow down AI — it ensures the right actions happen at the right time with appropriate oversight. | |
| HITL puts a human approval step in front of agent actions that carry risk or uncertainty. |
|
|
||
| ## Why human-in-the-loop matters <a id="why-hitl"/> | ||
|
|
||
| AI agents are increasingly capable of taking autonomous actions, but certain operations require human judgment: |
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.
An additional point thats not captured here - sometimes HITL is useful when the agent needs to more clarification or human input before taking further action.
| Human-in-the-loop authorization follows a request-approval pattern over Ably channels: | ||
|
|
||
| 1. The AI agent determines a tool call requires human approval. | ||
| 2. The agent publishes an authorization request to a dedicated channel. |
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.
Hmm, I'm not sure we need to use a dedicated channel (with capabilities on hitl:* etc). Why not just sent the HITL request from the agent on the same channel? The agent is going to do a lookup when it gets the response from the user anyway to determine if it is allowed to make that decision, so I don't think these needs to be enforced at the Ably channel level?
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.
I had to make a few changes elsewhere as the page was more focused on dedicated channel capabilities etc. So I've stuck it (and the couple changes recommended above) into a single fixup: d2c24d0
This may change depending on your feedback below though.
|
|
||
| ## Request human approval <a id="request"/> | ||
|
|
||
| When an agent identifies an action requiring human oversight, it publishes a request to a HITL channel. The request should include sufficient context for the approver to make an informed decision, including the action name, parameters, a human-readable reason, and the risk level. |
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.
I think this is a bit overly opinionated - I don't think all HITL loops need to carry a risk level or a reason?
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.
I've removed the opinionated bits from this section including updating the code:
|
|
||
| When an agent identifies an action requiring human oversight, it publishes a request to a HITL channel. The request should include sufficient context for the approver to make an informed decision, including the action name, parameters, a human-readable reason, and the risk level. | ||
|
|
||
| Include an expiry time to prevent stale requests from being approved after circumstances have changed. The `requestId` enables correlation between requests and responses when handling multiple concurrent approval flows. |
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.
Again I think this is getting too opinionated about how to implement HITL flows. Instead, this doc should focus on the core Ably primitives you would rely on to implement HITL.
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.
I think this was covered in the comment above.
| ``` | ||
| </Code> | ||
|
|
||
| ## Review and decide <a id="review"/> |
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.
Same here. I think the doc should just cover an agent sending a HITL request to a user, and obtaining the response from the user (with verified identity/role etc) and taking an action accordingly.
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.
I've removed all the opinionated work from this section: 901564a
|
|
||
| The agent listens for human decisions and acts accordingly. When a response arrives, the agent retrieves the pending request using the `requestId`, verifies the approver's identity and role from the trusted JWT claims, and either executes the action or notifies the user of the rejection. | ||
|
|
||
| Logging all decisions with the approver's identity and role creates an audit trail. This is essential for compliance, debugging, and understanding how the system is being used over time. |
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.
Application logging is a customer's concern, unrelated to Ably, and doesn't need to be documented here.
However, an Ably primitive that might be relevant to audit trails is integration rules, which I think would be valid to call out here (although I think a brief mention and link to integration rule docs is sufficient, rather than a full fledged example).
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.
Updated in the last 3 fixups.
| ``` | ||
| </Code> | ||
|
|
||
| ## Handle timeouts <a id="timeout"/> |
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.
Again I think this is an implementation question, possible suitable for a guide, but not for feature documentation.
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.
Agreed, I've removed this section in 0a3c7a1
|
This looks like it needs the base branch changing |
4bf0fe2 to
4cade76
Compare
|
Thank you @mschristensen I've updated from your feedback. @paddybyers I think Mike rebased the release branch with main, which then left my PR here outdated. But I didn't see as was off yesterday. All rebased now. Thanks for flagging. |
mschristensen
left a comment
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.
Thanks Greg, looks good, a few last comments
| │ subscribe: approval-response │ publish: approval-response | ||
| │ │ | ||
| ▼ ▼ | ||
| ``` |
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.
I think we should remove this ASCII diagram, until we have nicely designed ones. I created a ticket: https://ably.atlassian.net/browse/AIT-257
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.
Thank you. I didn't think the ASCII would be a releaseable piece to show but more something that could assist design on any images we'd need to create.
| ▼ ▼ | ||
| ``` | ||
|
|
||
| ## Verify approver permissions <a id="verify"/> |
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.
This section appears twice. This one should be removed.
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.
Yep! I think I forgot to remove when I moved things around: 2abee1a
|
|
||
| ## Verify approver permissions <a id="verify"/> | ||
|
|
||
| Use the trusted `userClaim` from the JWT to verify the approver has sufficient permissions for the specific action. Different actions may require different authorization levels — a moderator might approve content-related actions while financial operations require an admin. |
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 shouldn't use an em-dash, which is a tell-tale sign of AI generated content
| Use the trusted `userClaim` from the JWT to verify the approver has sufficient permissions for the specific action. Different actions may require different authorization levels — a moderator might approve content-related actions while financial operations require an admin. | |
| Use the trusted `userClaim` from the JWT to verify the approver has sufficient permissions for the specific action. Different actions may require different authorization levels - for example, a moderator might approve content-related actions while financial operations require an admin. |
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.
Updated!
| if (!pending) return; | ||
|
|
||
| // The clientId is verified by Ably - this is the trusted approver identity | ||
| const approverId = message.clientId; |
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 havent shown how to use identified clients or, as used later in this doc, roles. We should document a minimal example of the JWT claims, like we do in the accepting user input docs, and include relevant links to the sessions & identity docs
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.
I've added a new h3 within Process the decision called Verify approver identity. Let me know what you think: 3a0588e
| ``` | ||
| </Code> | ||
|
|
||
| ## Complete example <a id="example"/> |
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 haven't included this in other docs pages, and I'm not convinced it's necessary; the docs up to this point should be easy enough to follow that it's not required. A complete example imposes certain decisions on the implementation which prior docs aimed to discuss in more nuanced detail, allowing the reader to decide what is appropriate for them. This seems more suitable for a guide.
However, let me know if you disagree (and if you do, we should consider whether other docs pages need an equivalent section, and we should ticket that).
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.
You're right, it shouldn't be here. I've now removed: d1bfedb
We're going to cover this type of thing in the guides so there's no need in feature pages.
b4b4b2e to
87ebceb
Compare
| 2. The agent publishes an authorization request to the conversation channel. | ||
| 3. An authorized user receives and reviews the request. | ||
| 4. The human approves or rejects the request. | ||
| 5. The agent receives the decision, verifies the responder's role via [user claims](/docs/ai-transport/features/sessions-identity/identifying-users-and-agents#user-claims), and proceeds accordingly. |
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 mechanism could be either role (via user claims) or just the verified identity (via identified clients), so I think it's ok to just state:
| 5. The agent receives the decision, verifies the responder's role via [user claims](/docs/ai-transport/features/sessions-identity/identifying-users-and-agents#user-claims), and proceeds accordingly. | |
| 5. The agent receives the decision, verifies the responder's identity or role and proceeds accordingly. |
...since the detail is covered later in the document.
|
|
||
| <Code> | ||
| ```javascript | ||
| const channel = ably.channels.get('conversation:session-123'); |
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.
| const channel = ably.channels.get('conversation:session-123'); | |
| const channel = ably.channels.get('{{RANDOM_CHANNEL_NAME}}'); |
| Human-in-the-loop authorization follows a request-approval pattern over Ably channels: | ||
|
|
||
| 1. The AI agent determines a tool call requires human approval. | ||
| 2. The agent publishes an authorization request to the conversation channel. |
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.
Everywhere we say "conversation channel", I think we should just say "channel"
| 2. The agent publishes an authorization request to the conversation channel. | |
| 2. The agent publishes an authorization request to the channel. |
|
|
||
| ## Request human approval <a id="request"/> | ||
|
|
||
| When an agent identifies an action requiring human oversight, it publishes a request to the conversation channel. The request should include sufficient context for the approver to make an informed decision. The `requestId` enables correlation between requests and responses when handling multiple concurrent approval flows. |
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.
| When an agent identifies an action requiring human oversight, it publishes a request to the conversation channel. The request should include sufficient context for the approver to make an informed decision. The `requestId` enables correlation between requests and responses when handling multiple concurrent approval flows. | |
| When an agent identifies an action requiring human oversight, it publishes a request to the channel. The request should include sufficient context for the approver to make an informed decision. The `requestId` enables correlation between requests and responses when handling multiple concurrent approval flows. |
Document how to implement human oversight of AI agent actions using Ably channels and capabilities for authorization workflows.
761aa6e to
9915388
Compare
Description
Add documentation for human-in-the-loop (HITL) workflows in AI Transport, covering how to implement human oversight of AI agent actions.
Topics covered: