@visibe.ai/node 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,6 +45,8 @@ class LangChainCallback {
|
|
|
45
45
|
this.pendingLLMCalls = new Map();
|
|
46
46
|
this.pendingToolCalls = new Map();
|
|
47
47
|
this.stepCounter = 0;
|
|
48
|
+
// Set to false in subclasses that emit their own agent_start spans (e.g. LangGraphCallback).
|
|
49
|
+
this._emitRootAgentStart = true;
|
|
48
50
|
// Token / call / cost accumulators — read by patchCompiledStateGraph / patchRunnableSequence.
|
|
49
51
|
this.totalInputTokens = 0;
|
|
50
52
|
this.totalOutputTokens = 0;
|
|
@@ -173,6 +175,14 @@ class LangChainCallback {
|
|
|
173
175
|
if (!this.runIdToSpanId.has(runId)) {
|
|
174
176
|
this.runIdToSpanId.set(runId, this.nextSpanId());
|
|
175
177
|
}
|
|
178
|
+
// Emit agent_start for the root chain so LLM spans have a real parent and
|
|
179
|
+
// the agents breakdown is populated. Subclasses that manage their own
|
|
180
|
+
// agent_start spans (LangGraphCallback) set _emitRootAgentStart = false.
|
|
181
|
+
if (this._emitRootAgentStart && !_parentRunId) {
|
|
182
|
+
const spanId = this.runIdToSpanId.get(runId);
|
|
183
|
+
const agentName = _name ?? _chain?.name ?? this.agentName;
|
|
184
|
+
this.visibe.batcher.add(this.traceId, this.visibe.buildAgentStartSpan({ spanId, agentName }));
|
|
185
|
+
}
|
|
176
186
|
}
|
|
177
187
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
178
188
|
async handleChainEnd(_outputs, _runId) { }
|
|
@@ -12,6 +12,9 @@ class LangGraphCallback extends langchain_1.LangChainCallback {
|
|
|
12
12
|
constructor(options) {
|
|
13
13
|
super(options);
|
|
14
14
|
this.nodeNames = new Set(options.nodeNames ?? []);
|
|
15
|
+
// LangGraphCallback emits its own agent_start spans per node — suppress the
|
|
16
|
+
// base-class root-chain emission to avoid a spurious 'LangGraph' agent span.
|
|
17
|
+
this._emitRootAgentStart = false;
|
|
15
18
|
}
|
|
16
19
|
// Override handleChainStart to emit agent_start spans for LangGraph nodes.
|
|
17
20
|
//
|
|
@@ -41,6 +41,8 @@ export class LangChainCallback {
|
|
|
41
41
|
this.pendingLLMCalls = new Map();
|
|
42
42
|
this.pendingToolCalls = new Map();
|
|
43
43
|
this.stepCounter = 0;
|
|
44
|
+
// Set to false in subclasses that emit their own agent_start spans (e.g. LangGraphCallback).
|
|
45
|
+
this._emitRootAgentStart = true;
|
|
44
46
|
// Token / call / cost accumulators — read by patchCompiledStateGraph / patchRunnableSequence.
|
|
45
47
|
this.totalInputTokens = 0;
|
|
46
48
|
this.totalOutputTokens = 0;
|
|
@@ -169,6 +171,14 @@ export class LangChainCallback {
|
|
|
169
171
|
if (!this.runIdToSpanId.has(runId)) {
|
|
170
172
|
this.runIdToSpanId.set(runId, this.nextSpanId());
|
|
171
173
|
}
|
|
174
|
+
// Emit agent_start for the root chain so LLM spans have a real parent and
|
|
175
|
+
// the agents breakdown is populated. Subclasses that manage their own
|
|
176
|
+
// agent_start spans (LangGraphCallback) set _emitRootAgentStart = false.
|
|
177
|
+
if (this._emitRootAgentStart && !_parentRunId) {
|
|
178
|
+
const spanId = this.runIdToSpanId.get(runId);
|
|
179
|
+
const agentName = _name ?? _chain?.name ?? this.agentName;
|
|
180
|
+
this.visibe.batcher.add(this.traceId, this.visibe.buildAgentStartSpan({ spanId, agentName }));
|
|
181
|
+
}
|
|
172
182
|
}
|
|
173
183
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
184
|
async handleChainEnd(_outputs, _runId) { }
|
|
@@ -8,6 +8,9 @@ export class LangGraphCallback extends LangChainCallback {
|
|
|
8
8
|
constructor(options) {
|
|
9
9
|
super(options);
|
|
10
10
|
this.nodeNames = new Set(options.nodeNames ?? []);
|
|
11
|
+
// LangGraphCallback emits its own agent_start spans per node — suppress the
|
|
12
|
+
// base-class root-chain emission to avoid a spurious 'LangGraph' agent span.
|
|
13
|
+
this._emitRootAgentStart = false;
|
|
11
14
|
}
|
|
12
15
|
// Override handleChainStart to emit agent_start spans for LangGraph nodes.
|
|
13
16
|
//
|
package/package.json
CHANGED