-
Notifications
You must be signed in to change notification settings - Fork 43
fix: duplicate wrap tracer #398
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,5 +81,30 @@ describe('plugin/langchain/test/llm.test.ts', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.expectLog(/Executing FooNode thread_id is 1/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.expectLog(/traceId=test-trace-id/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should persistRun be triggered when graph.invoke is called', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { LangGraphTracer } = require('../lib/tracing/LangGraphTracer'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const persistRunCalls: any[] = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const originalPersistRun = LangGraphTracer.prototype.persistRun; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mm(LangGraphTracer.prototype, 'persistRun', function(this: any, run: any) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| persistRunCalls.push(run); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return originalPersistRun.call(this, run); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.mockLog(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mm(Tracer.prototype, 'traceId', 'test-persist-run-trace-id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await app.httpRequest().get('/llm/graph'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(persistRunCalls.length > 0, 'persistRun should be called at least once'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hasCorrectTraceId = persistRunCalls.some(run => run.trace_id === 'test-persist-run-trace-id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(hasCorrectTraceId, 'persistRun should receive correct trace_id from invoke call'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+85
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find plugin/langchain -type f \( -name "*LangGraphTracer*" -o -name "*.ts" -o -name "*.js" \) | head -20Repository: eggjs/tegg Length of output: 1098 🏁 Script executed: rg -l "class LangGraphTracer|persistRun" plugin/langchain --type ts --type jsRepository: eggjs/tegg Length of output: 135 🏁 Script executed: cat -n plugin/langchain/test/llm.test.ts | head -120Repository: eggjs/tegg Length of output: 4329 🏁 Script executed: cat -n plugin/langchain/lib/tracing/LangGraphTracer.tsRepository: eggjs/tegg Length of output: 852 🏁 Script executed: find plugin/langchain/test/fixtures -name "*Controller*" -o -name "*Graph*" | xargs grep -l "graph" 2>/dev/nullRepository: eggjs/tegg Length of output: 222 🏁 Script executed: cat -n plugin/langchain/test/fixtures/apps/langchain/app/modules/bar/controller/AppController.tsRepository: eggjs/tegg Length of output: 1980 🏁 Script executed: rg -n "invoke|persistRun" plugin/langchain/lib/graph --type ts -A 2 -B 2Repository: eggjs/tegg Length of output: 36 🏁 Script executed: rg "BaseTracer" plugin/langchain -A 5 -B 5 --type tsRepository: eggjs/tegg Length of output: 1107 Add explicit wait for Since Suggested fix await app.httpRequest().get('/llm/graph');
+ await new Promise<void>((resolve, reject) => {
+ const start = Date.now();
+ const timer = setInterval(() => {
+ if (persistRunCalls.length > 0) {
+ clearInterval(timer);
+ resolve();
+ return;
+ }
+ if (Date.now() - start > 1000) {
+ clearInterval(timer);
+ reject(new Error('persistRun should be called at least once'));
+ }
+ }, 10);
+ });
+
assert(persistRunCalls.length > 0, 'persistRun should be called at least once');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.expectLog(/agent_run/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.expectLog(/traceId=test-persist-run-trace-id/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.