MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / handleToolEnd

Function handleToolEnd

packages/core/src/tracing/langchain/index.ts:321–335  ·  view source on GitHub ↗
(output: unknown, runId: string)

Source from the content-addressed store, hash-verified

319
320 // Tool End Handler
321 handleToolEnd(output: unknown, runId: string) {
322 const span = spanMap.get(runId);
323 if (span?.isRecording()) {
324 if (recordOutputs) {
325 // LangChain tools may return ToolMessage objects — extract the content
326 const outputObj = output as Record<string, unknown> | undefined;
327 const content =
328 outputObj && typeof outputObj === 'object' && 'content' in outputObj ? outputObj.content : output;
329 span.setAttributes({
330 [GEN_AI_TOOL_OUTPUT_ATTRIBUTE]: typeof content === 'string' ? content : JSON.stringify(content),
331 });
332 }
333 exitSpan(runId);
334 }
335 },
336
337 // Tool Error Handler
338 handleToolError(error: Error, runId: string) {

Callers

nothing calls this directly

Calls 4

exitSpanFunction · 0.85
getMethod · 0.65
isRecordingMethod · 0.65
setAttributesMethod · 0.65

Tested by

no test coverage detected