LangChain has introduced AI Search in LangSmith, allowing developers to search AI agent traces using natural-language descriptions of specific behaviours. The feature helps developers locate agent interactions that conventional keyword searches or metadata filters might not identify.

AI Search examines recorded agent interactions and returns traces that match a developer’s query. It can identify instances where an agent incorrectly reports completing a task, produces an unwanted response, or exposes PII.

According to LangChain’s announcement, the feature uses a decision model to examine trace content rather than relying solely on text similarity. Developers can also combine natural-language queries with existing filters to narrow searches to traces containing errors or specific tags.

OpenTelemetry’s error-recording specifications recommend identifying failed operations through exceptions or reported errors, with error classification depending on the operation’s context. However, an operation can complete without reporting an execution error even when an AI agent has not fulfilled the user’s request.

An agent might successfully call an external tool and claim that a task is complete without performing the requested work. Identifying this behaviour requires examining the interaction history and the agent’s actions, rather than relying solely on error attributes.

How LangSmith AI Search works

AI agent traces contain information about user requests, model responses, tool calls, and intermediate execution steps. Locating specific behaviours within these records can require developers to inspect individual traces or configure evaluators to detect predefined conditions.

SmithDB, LangChain’s database for agent observability, converts incoming traces into standardised trajectories containing messages, tool calls, and results in chronological order. This process removes duplicated conversation histories and allows AI Search to process traces from different supported frameworks using a common format.

The system supports traces generated through different frameworks and SDKs, including LangChain, LangGraph, OpenAI, Anthropic, the Vercel AI SDK, and OpenTelemetry.

When a developer submits a query, SmithDB first applies structured filters to narrow the set of candidate trajectories. A decision model then examines the remaining records to determine whether the specified behaviour occurred.

Unlike keyword searches or vector searches based on semantic similarity, AI Search evaluates whether the recorded interaction matches a described behaviour. LangChain said this helps distinguish between an agent that completed a task and one that only claimed to have completed it.

The system processes multiple trajectories in parallel, with SmithDB retrieving and preparing additional records while the decision model examines the current batch. Matching results are streamed back as they are identified, rather than requiring developers to wait for the entire search to finish.

Debugging long agent executions

Long-running agent sessions can contain thousands of messages and tool outputs, particularly when coding agents execute shell commands, read files, or delegate tasks to subagents. These execution histories can exceed the amount of information a decision model processes in a single search.

According to LangChain, an examination of 150 randomly selected conversations from its open-source coding agent, Open SWE, found that a small number of conversations exceeded one million tokens. The median conversation contained approximately 72,000 tokens.

In the median conversation, approximately 2,000 tokens came from user messages and the agent’s replies, while tool outputs accounted for about 85% of the content. These outputs primarily consisted of file reads and shell commands.

AI Search addresses these large records by applying an 8,000-token budget to each trajectory before passing it to the decision model. User messages and agent responses receive priority, followed by intermediate model messages, tool results, and system messages.

Messages that exceed the available token budget are trimmed, while subsequent messages are excluded. As a result, the decision model does not examine every detail of longer sessions, particularly when relevant information appears in lower-priority tool outputs.

LangChain acknowledged that detecting behaviours such as an agent ignoring a tool error requires access to the corresponding tool result. The company is investigating query-dependent context selection and additional checks when the decision model has insufficient information.

AI Search builds on LangSmith Trajectories, introduced in September, which presents agent interactions, tool calls, and subagent activity chronologically. After locating a matching session, developers can review its trajectory and access the underlying traces to inspect individual operations, retries, and execution details.

In its earlier Trajectories announcement, LangChain used a hypothetical support-agent scenario to demonstrate the debugging process. The scenario involved an agent reusing an outdated tool result instead of retrieving current information, with the trajectory showing where the agent’s actions diverged from the expected workflow.

How AI Search fits into distributed tracing

OpenTelemetry provides standardized instrumentation for collecting and correlating traces, metrics, and logs across distributed applications. Its documentation explains how trace and span identifiers connect operations across services, while its logging specification supports correlating log records with the corresponding traces.

OpenTelemetry’s generative AI semantic conventions also cover model interactions, tool calls and results, and token usage. These conventions provide a standardised way to represent aspects of AI-agent execution in telemetry data when the relevant operations are instrumented.

LangSmith’s AI Search focuses on querying recorded agent trajectories using natural-language descriptions of behaviour. According to LangChain, SmithDB can process traces from OpenTelemetry and other supported agent frameworks, converting them into a common format before evaluating them against developers’ queries.

Detailed agent instrumentation also raises considerations around sensitive information. OpenTelemetry’s generative AI conventions cover data such as input messages, output messages, and tool-call arguments, which can contain personal or confidential information. Recording such content therefore requires appropriate controls over telemetry collection and handling.

LangChain identifies detecting PII exposure as one application of AI Search. However, searching traces for exposed information is separate from preventing sensitive data from being recorded in the first place.

According to LangChain, AI Search is available in public beta on LangSmith Cloud in Google Cloud’s US, EU, and APAC regions, at no additional charge for the feature. Organisation administrators can enable it through LangSmith’s settings.

(Photo by Immo Wegmann)

See also: OpenTelemetry Java agent 2.32.0 previews 3.0 telemetry defaults

Banner for Cyber Security Expo by TechEx events.

Want to learn more about cybersecurity from industry leaders? Check out Cyber Security & Cloud Expo taking place in Amsterdam, California, and London. The comprehensive event is part of TechEx and is co-located with other leading technology events including the AI & Big Data Expo. Click here for more information.

Developer Tech News is powered by TechForge Media. Explore other upcoming enterprise technology events and webinars here.