Creating a “Human in the Loop” tool
“Human in the Loop” tools are implemented using Inngest’swaitForEvent() step method:
ask_developer tool will wait up to 4 hours for a "developer.response" event to be received, pausing the execution of the AgentKit network.
The incoming "developer.response" event will be matched against the data.ticketId field of the event that trigger the AgentKit network.
For this reason, the AgentKit network will need to be wrapped in an Inngest function as demonstrated in the next section.
Example: Support Agent with Human in the Loop
Let’s consider a Support Agent Network automously triaging and solving tickets:You can find the complete example code in the
examples/support-agent-human-in-the-loop
directory.
Transforming your AgentKit network into an Inngest function
First, you’ll need to create an Inngest Client:src/inngest/client.ts
src/inngest/agent-network.ts
network.run() is now performed by the Inngest function.
Don’t forget to register the function with createServer’s functions property.
Add a ask_developer tool to the network
Our AgentKit network is now ran inside an Inngest function triggered by the "app/support.ticket.created" event which carries
the data.ticketId field.
The Technical Support Agent will now use the ask_developer tool to ask a developer for input on a technical issue:
ask_developer tool will now wait for a "developer.response" event to be received (ex: from a Slack message), and match it against the data.ticketId field.
The result of the ask_developer tool will be returned to the Technical Support Agent.
Look at the Inngest step.waitForEvent() documentation for more details and examples.
Try it out
Support Agent with "Human in the loop"
This Support AgentKit Network is composed of two Agents (Customer Support and
Technical Support) and a Supervisor Agent that routes the ticket to the
correct Agent. The Technical Support Agent can wait for a developer response
when facing complex technical issues.