ESM
import { createAgentTraceMiddleware, createToolTraceMiddleware } from "@arcgis/ai-components/agent-utils/middlewares/trace.js";

Functions

createAgentTraceMiddleware

Function
Since
ArcGIS Maps SDK for JavaScript 5.2

When a language model requests tool calls, this middleware sends a trace message for each call before the tool runs. Each message includes the tool name and arguments. Add the returned middleware to the middlewares array of an LLMAgent. The orchestrator forwards these messages as trace events; the assistant log displays them when logging is enabled.

Signature
createAgentTraceMiddleware (): AgentMiddleware
Returns
AgentMiddleware

An agent middleware that wraps model calls and sends trace messages.

createToolTraceMiddleware

Function
Type parameters
<TInput extends AgentData = AgentData, TOutput = unknown>
Since
ArcGIS Maps SDK for JavaScript 5.2

After a tool call completes successfully, this middleware sends a trace message. The message contains the result text when the result is a ToolMessage or string; otherwise, it contains the tool name. Add the returned middleware to the middlewares array of a FunctionTool. The orchestrator forwards these messages as trace events; the assistant log displays them when logging is enabled.

Signature
createToolTraceMiddleware <TInput extends AgentData = AgentData, TOutput = unknown>(): FunctionToolMiddleware<TInput, TOutput>
Returns
FunctionToolMiddleware<TInput, TOutput>

A function tool middleware that wraps tool calls and sends trace messages.