Menu

Post image 1
Post image 2
1 / 2
0

Why my LangChain audit chain came back empty (and how to fix it in one line)

DEV Community·Pico·24 days ago
#H4IActei
#why#langchain#agents#audit#events#handler
Reading 0:00
15s threshold

I shipped a small demo last week. A LangChain.js agent invokes two tools, an AgentLairCallbackHandler posts a signed audit event for each tool call, the agent issues a Bonded Credibility Credential summarising the run. Curl the verifier URL, get valid:true . Three steps. The first version returned an empty event list every time. The repro Here is a minimal reproduction. The handler does one thing on tool start: POST to an audit endpoint and push the response into this.events . import { BaseCallbackHandler } from ' @langchain/core/callbacks/base ' ; class AuditHandler extends BaseCallbackHandler { name = ' AuditHandler ' ; events : any [] = []; async handleToolStart ( _t : any , input : string ) { const res = await fetch ( ' https://example.com/audit ' , { method : ' POST ' , body : JSON . stringify ({ input }), }); this . events . push ( await res . json ()); } } const handler = new AuditHandler (); await myTool . invoke ({ q : ' hello ' }, { callbacks : [ handler ] }); console . log ( handler . events .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More