Skip to content

Commit 50fcc66

Browse files
nirgaclaude
andcommitted
fix: update test assertions for callback-based instrumentation
- Update agent test to use AgentExecutor.workflow span name - Fix LCEL test to handle nested JSON structure in tool input - All tests now passing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7759fb4 commit 50fcc66

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

packages/instrumentation-langchain/src/callback_handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class TraceloopCallbackHandler extends BaseCallbackHandler {
130130
[SpanAttributes.LLM_REQUEST_TYPE]: "completion",
131131
[SpanAttributes.LLM_REQUEST_MODEL]: modelName,
132132
"traceloop.span.kind": "task",
133-
"traceloop.workflow.name": runName || spanName,
133+
"traceloop.workflow.name": _runName || spanName,
134134
});
135135

136136
if (this.traceContent && prompts.length > 0) {

packages/instrumentation-langchain/test/instrumentation.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe("Test Langchain instrumentation", async function () {
151151
});
152152

153153
const spans = memoryExporter.getFinishedSpans();
154-
const agentSpan = spans.find((span) => span.name === "langchain.agent");
154+
const agentSpan = spans.find((span) => span.name === "AgentExecutor.workflow");
155155

156156
assert.ok(result);
157157
assert.ok(agentSpan);
@@ -160,7 +160,7 @@ describe("Test Langchain instrumentation", async function () {
160160
assert.ok(agentSpan.attributes["traceloop.entity.output"]);
161161
assert.strictEqual(
162162
JSON.parse(agentSpan.attributes["traceloop.entity.input"].toString())
163-
.args[0].input,
163+
.input,
164164
"Solve `5 * (10 + 2)`",
165165
);
166166
assert.deepEqual(
@@ -351,9 +351,12 @@ describe("Test Langchain instrumentation", async function () {
351351
assert.strictEqual(wikipediaSpan.attributes["traceloop.span.kind"], "task");
352352
assert.ok(wikipediaSpan.attributes["traceloop.entity.input"]);
353353
assert.ok(wikipediaSpan.attributes["traceloop.entity.output"]);
354+
355+
const inputData = JSON.parse(wikipediaSpan.attributes["traceloop.entity.input"].toString());
356+
const toolInput = JSON.parse(inputData.args[0]);
357+
354358
assert.strictEqual(
355-
JSON.parse(wikipediaSpan.attributes["traceloop.entity.input"].toString())
356-
.args[0],
359+
toolInput.input,
357360
'"Current Prime Minister of Malaysia" site:wikipedia.org',
358361
);
359362
assert.deepEqual(

0 commit comments

Comments
 (0)