I’m working on a LangChain agent project and need to add human approval before certain operations execute. My agent should stop and wait for human confirmation through Slack messages or WebSocket connections before it performs critical tasks like database modifications or external API calls.
I tried looking into custom callbacks but I’m not sure if that’s the right approach. Since I’m using standard LangChain (not LangGraph), the interrupt features won’t work for my use case. HumanLayer doesn’t seem to have support for what I need right now.
What are some alternative methods to pause agent execution and get human input before proceeding? Any suggestions would be greatly appreciated.
redis pub/sub channels work perfectly here. your agent publishes approval requests to a channel, slack bot subscribes and sends notifications. when someone approves, the bot publishes back so your agent can continue. no polling needed and it plays nice with websockets.
Middleware interceptors worked perfectly for this. Instead of messing with agent code or cramming approval logic into each tool, I built a middleware layer between the agent and external services. It watches all outbound calls and catches anything matching your critical operation patterns. When it flags something, the middleware pauses the request, shoots you an approval notification however you want it, then keeps the connection open until you give the thumbs up. The agent just thinks it’s a normal API call that’s running slow. This keeps all the approval stuff separate from your agent code. You can tweak approval rules, add notification channels, or change the whole process without touching the agent. Works great if you’ve already got a service mesh or API gateway - just plug the approval logic right into your existing pipeline.
try a simple database flag system. when your agent hits something critical, it writes the action to a db table with status=‘pending_approval’. build a lightweight web interface or bot to monitor the table and send notifications. once approved, update the status and let your agent poll for changes. way simpler than complex workflows.
Database polling works but creates delays and race conditions that’ll kill you in production.
Hit this exact problem last year. We tried the custom tool wrapper first - worked great until multiple agents started running parallel ops. The approval logic got scattered everywhere and became impossible to maintain.
Then we switched to database flags with polling. Bad move. Polling every few seconds added lag, and we’d miss critical approvals when traffic spiked. Debugging approval states across different DB records was a total pain.
What actually fixed it? Treating approvals as external workflow triggers. Agent needs approval? Makes one HTTP call to kick off an approval workflow. The workflow handles Slack notifications, tracks responses, manages timeouts, then calls back with the decision.
Keeps the agent stateless. No polling, no complex state juggling, no approval logic spread everywhere. The workflow platform deals with all the messy human stuff while your agent just waits for a callback.
Latenode has this built in. You drag in an approval node, hook it to Slack, and it handles everything automatically. Your agent makes one API call and gets a clean response.
i totally understand your situation! in my case, i just throw a custom exception when needing approval and then handle it in the main loop. the agent pauses nicely without crashing, and it integrates well with slack for approvals. a bit of a hack, but it really works!
Exception handling works but gets messy at scale. I’ve hit this exact problem and found automation platforms crush custom code for approval flows.
The real issue? LangChain agents weren’t built for human-in-the-loop workflows. You end up writing tons of state management and notification code that breaks constantly.
I fixed this by routing critical ops through an automation workflow. When my agent needs approval, it triggers a workflow that pauses, sends Slack notifications, waits for responses, and feeds the decision back. The agent just continues like nothing happened.
This separates your AI logic from approval infrastructure. Agent stays clean, workflow handles the messy human stuff.
Latenode makes this dead simple - built-in approval nodes plus direct Slack and WebSocket connections. Just drag in an approval step and it handles everything.
I’ve had great success using custom tools with approval gates built right in. Instead of pausing the whole agent, wrapping critical operations in tools that manage approvals internally works well. When the agent invokes these tools, they check if approval is required based on predefined rules. If so, the tool communicates with your approval service and waits for a response. This approach keeps your agent code clean and places the approval logic where it belongs. You can configure which operations necessitate approval and establish distinct workflows for different tools. The agent remains unaware of the approvals; it functions as usual while handling approvals seamlessly through a separate microservice for notifications and tracking, making it cleaner than relying on exceptions.