Skip to content

Commit 6ce856c

Browse files
committed
Remove useless invoke subscriber
1 parent 0a5fffa commit 6ce856c

File tree

5 files changed

+43
-75
lines changed

5 files changed

+43
-75
lines changed

lib/subscribers/langgraph/config.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,6 @@
66
// `Pregel` is the base class of the `CompiledStateGraph` (and others),
77
// which is the class encapsulating a LangGraph agent.
88

9-
const graphInvoke = {
10-
path: './langgraph/graph-invoke.js',
11-
instrumentations: [
12-
// CommonJs
13-
{
14-
channelName: 'nr_invoke',
15-
module: { name: '@langchain/langgraph', versionRange: '>=1.0.0', filePath: 'dist/pregel/index.cjs' },
16-
functionQuery: {
17-
index: 1,
18-
methodName: 'invoke',
19-
kind: 'Async',
20-
}
21-
},
22-
// ESM
23-
{
24-
channelName: 'nr_invoke',
25-
module: { name: '@langchain/langgraph', versionRange: '>=1.0.0', filePath: 'dist/pregel/index.js' },
26-
functionQuery: {
27-
index: 1,
28-
methodName: 'invoke',
29-
kind: 'Async',
30-
}
31-
},
32-
]
33-
}
34-
359
const graphStream = {
3610
path: './langgraph/graph-stream.js',
3711
instrumentations: [
@@ -60,7 +34,6 @@ const graphStream = {
6034

6135
module.exports = {
6236
'@langchain/langgraph': [
63-
graphInvoke,
6437
graphStream
6538
]
6639
}

lib/subscribers/langgraph/graph-invoke.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/versioned/langgraph/graph-invoke.test.js

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ const test = require('node:test')
99
const assert = require('node:assert')
1010

1111
const { removeModules } = require('../../lib/cache-buster')
12-
const { assertSegments } = require('../../lib/custom-assertions')
12+
const { assertSegments, match } = require('../../lib/custom-assertions')
1313
const createOpenAIMockServer = require('../openai/mock-server')
1414
const helper = require('../../lib/agent_helper')
1515

1616
const config = {
1717
ai_monitoring: {
18-
enabled: true
18+
enabled: true,
19+
streaming: {
20+
enabled: true
21+
}
1922
}
2023
}
2124

@@ -80,24 +83,50 @@ test('should create span on successful CompiledStateGraph.invoke', async (t) =>
8083
const { agent, langgraphAgent } = t.nr
8184

8285
await helper.runInTransaction(agent, async (tx) => {
83-
let content
84-
try {
85-
const result = await langgraphAgent.invoke(
86-
{ messages: [{ role: 'user', content: 'You are a scientist.' }] }
87-
)
88-
content = result?.messages?.[1]?.content ?? ''
89-
} catch (err) {
90-
assert.fail(err)
91-
}
86+
const result = await langgraphAgent.invoke(
87+
{ messages: [{ role: 'user', content: 'You are a scientist.' }] }
88+
)
89+
const content = result?.messages?.[1]?.content
9290
assert.equal(content, '212 degrees Fahrenheit is equal to 100 degrees Celsius.', 'should output correct content')
93-
assertSegments(tx.trace, tx.trace.root, ['Llm/agent/LangGraph/invoke/LangGraphReactAgent'], {
91+
assertSegments(tx.trace, tx.trace.root, ['Llm/agent/LangGraph/stream/LangGraphReactAgent'], {
9492
exact: false
9593
})
9694

9795
tx.end()
9896
})
9997
})
10098

99+
test('should create LlmAgent event for CompiledStateGraph.invoke', async (t) => {
100+
const { agent, langgraphAgent } = t.nr
101+
102+
await helper.runInTransaction(agent, async (tx) => {
103+
const result = await langgraphAgent.invoke(
104+
{ messages: [{ role: 'user', content: 'You are a scientist.' }] }
105+
)
106+
const content = result?.messages?.[1]?.content
107+
assert.ok(content)
108+
// Check for LlmAgent event
109+
const events = agent.customEventAggregator.events.toArray()
110+
const agentEvents = events.filter((e) => e[0].type === 'LlmAgent')
111+
assert.ok(agentEvents.length > 0)
112+
113+
const [[{ type }, agentEvent]] = agentEvents
114+
assert.equal(type, 'LlmAgent')
115+
const [segment] = tx.trace.getChildren(tx.trace.root.id)
116+
117+
match(agentEvent, {
118+
id: /[a-f0-9]{36}/,
119+
name: 'LangGraphReactAgent',
120+
span_id: segment.id,
121+
trace_id: tx.traceId,
122+
ingest_source: 'Node',
123+
vendor: 'langgraph'
124+
})
125+
126+
tx.end()
127+
})
128+
})
129+
101130
test('should not create segment or events when ai_monitoring.enabled is false', async (t) => {
102131
const { agent, langgraphAgent } = t.nr
103132

test/versioned/langgraph/graph-stream.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ test('should add subcomponent attribute to span', async (t) => {
300300
})
301301
})
302302

303-
test('should create LlmError event when stream fails', async (t) => {
303+
test('should create LlmError event when given bad input', async (t) => {
304304
const { agent, langgraphAgent } = t.nr
305305

306306
await helper.runInTransaction(agent, async (tx) => {

test/versioned/langgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "@langchain/langgraph",
66
"minSupported": "1.0.0",
7-
"minAgentVersion": "13.11.0"
7+
"minAgentVersion": "13.12.0"
88
}
99
],
1010
"version": "0.0.0",

0 commit comments

Comments
 (0)