エージェントの挙動は本番環境で初めてわかる
AIエージェントは従来のソフトウェアと異なり、入力が無限で非決定的な挙動を示すため、本番環境での監視・評価・継続的改善が重要である。
キーポイント
AIエージェントは従来ソフトウェアと異なり、自然言語による無限の入力空間を持つため、本番環境での挙動を事前に完全に予測できない
LLMはプロンプトの微妙な変化に敏感で非決定的な振る舞いを示すため、従来のテスト・監視手法では不十分
エージェントの本番監視には、推論チェーン、ツール呼び出し、検索操作などの多段階プロセスを追跡できる新しい観測性(observability)アプローチが必要
影響分析・編集コメントを表示
影響分析
この記事は、AIエージェントの本番導入における根本的な課題を明確に指摘し、従来のソフトウェア開発・運用パラダイムの限界を示している。エージェント特有の観測性要件が認識されることで、AIシステムの信頼性向上と実用的な展開が加速する可能性がある。
編集コメント
AIエージェントの実用化において「本番環境で初めて真の挙動がわかる」という現実を率直に語った貴重な現場視点。開発者必読の内容。
タイトル: エージェントが本番環境で何をするかは、実際に投入してみるまでわからない
従来のソフトウェアを本番環境にリリースするとき、何が起こるかはかなり予想がつきます。ユーザーはボタンをクリックし、フォームに入力し、予め決められたパスをたどります。テストスイートはコードパスの80〜90%をカバーし、監視ツールはエラーレート、応答時間、データベースクエリといったおなじみの項目を追跡します。何かが壊れたときは、スタックトレースやログを確認します。
エージェントの動作はこれとは異なります。エージェントは自然言語の入力を受け付け、可能なクエリの範囲は無限です。エージェントは大規模言語モデルによって駆動されており、プロンプトの微妙な違いに敏感で、同じ入力に対しても異なる出力を生成することがあります。さらに、開発時に完全に予測するのが難しい、多段階の推論チェーン、ツール呼び出し、検索操作を通じて意思決定を行います。
これは、エージェントのための本番環境監視には、従来のオブザーバビリティとは異なる機能が必要であることを意味します。この記事では、エージェントのオブザーバビリティがなぜ独自の課題を抱えるのか、何を監視すべきか、そして大規模にエージェントを展開しているチームから私たちが学んだことについて探っていきます。
エージェントが従来のソフトウェアと異なる理由
エージェントを本番環境に展開しているチームと協業する中で、監視アプローチに影響を与える2つの重要な違いを観察しました。
エージェントは無限の入力空間を持つ
従来のソフトウェアは、有限で制約された入力空間を持ちます。ユーザーはボタン、ドロップダウン、フォーム、特定のフォーマットを持つAPIコールを通じて操作します。決済フローを設計するとき、画面の正確な順序と可能なユーザー操作を知っています。失敗モードを列挙できるため、エラー処理は網羅的になり得ます。
これに対してエージェントは、主な入力として自然言語を受け付けます。自然言語には有効な入力の固定セットがありません。ユーザーは同じリクエストを無数の方法で表現できます。曖昧だったり具体的だったり、形式的だったりカジュアルだったり、1つのメッセージに複数の意図を組み合わせたり、1つのリクエストを複数のターンにまたがって伝えたりします。
カスタマーサポートエージェントを考えてみましょう。従来のソフトウェアでは、ユーザーは「注文履歴」に移動し、注文をクリックし、「返金をリクエスト」をクリックし、最後に事前定義されたオプションがあるフォームに入力します。パスは固定されており、テスト可能です。
エージェントの場合、ユーザーは次のように言うかもしれません:
「注文を返品したい」
「先週買った靴のお金を返してもらうのを手伝ってくれますか?」
「届いた商品が破損しているんですが、どうすればいいですか?」
「注文番号 #12345 返金お願いします」
これらはすべて同じ根本的な意図を表していますが、エージェントはそのバリエーションを理解し、関連情報を抽出し、適切なアクションを決定する必要があります。この無限の入力空間は、実際のユーザーがエージェントと対話し始めるまで、エージェントがどのように使用されるかを完全に予測できないことを意味します。
LLMは小さな変化に対して頑健ではない
2つ目の重要な違いは、LLMがプロンプトへの敏感性と非決定的な振る舞いを示すことです。入力の小さな変化でも異なる出力につながることがあり、同じ入力でも異なる結果を生むことがあります。
これにはいくつかの理由があります。LLMは生成中に確率的サンプリングを使用するため、ばらつきが生じます。最も重要なのは、LLMが言い回し、文脈、指示の順序の微妙な変化に対して異なる反応を示すことです。
この非決定性は、開発中に観察した振る舞いが、本番環境で起こることと一致しない可能性があることを意味します。テストでは確実に動作したプロンプトが、遭遇しなかったエッジケースで失敗するかもしれません。評価中にツールを正しく使用したエージェントが、言い回しがわずかに異なるユーザークエリに対して、時々間違ったツールを選択するかもしれません。
エージェントのための本番環境監視は異なる
従来のアプリケーションパフォーマンス監視(APM)ツールは、レイテンシ、トラフィック、エラー、飽和度といったメトリクスに焦点を当てます。それらはHTTPリクエスト、データベースクエリ、システムリソースを追跡します。これらは、可能なコードパスがわかっている構造化された決定的システムのために設計されています。
エージェントのオブザーバビリティには、それらを取り巻くシステムメトリクスだけでなく、入力と出力そのものを監視することが必要です。
自然言語インタラクションの監視
エージェントがユーザーと会話しているとき、主要なシグナルは会話そのものの中に存在します。以下をキャプチャする必要があります:
完全なプロンプト-レスポンスのペア: リクエストが発生したことだけでなく、ユーザーが何を尋ね、エージェントが何と応答したか
マルチターンの文脈: エージェントは1つの会話の一部として複数のやり取りにまたがって動作することが多いため、関連するインタラクションをグループ化する必要がある
エージェントの軌跡と中間ステップ: エージェントは最終的な出力に到達するために多段階のパスをたどり、ツールを呼び出し、選択肢を通じて推論することができます。最終的な応答だけでなく、軌跡の各ステップの可視性が必要です
これは従来のロギングとは質的に異なります。従来のWebリクエストは「POST /api/checkout 200 OK 342ms」と要約されるかもしれません。エージェントのインタラクションは、潜在的に数十のステップを含む自然言語の会話であり、それがうまくいったかどうかという問いは、ステータスコードからは答えられません。
大規模な人間の判断の課題
自然言語のインタラクションは、適切に評価するために人間の判断を必要とすることがよくあります。この応答は役に立ちますか?エージェントはユーザーの意図を理解しましたか?口調は適切でしたか?関連する情報を検索しましたか?
開発中はこれは管理可能です。トレースを手動で確認し、プロンプトを調整し、反復します。しかし本番環境では、数千、数百万のインタラクションを処理しているかもしれません。人間のレビュアーは1時間に50〜100のトレースを有意義に評価できますが、1日1,000リクエストの場合、完全な手動レビューには毎日10〜20時間の専任の人間の時間が必要になります。これは重要な疑問を提起します:手動レビューがスケールしないとき、どうやって人間の知性を本番データに適用するのか?
私たちは、2つの相補的なアプローチが効果的であることを発見しました。
構造化された人間のレビューのためのアノテーションキュー
アノテーションキューは、人間のレビューを可能な限り効率的にするのに役立ちます。レビュアーに本番ログを探し回らせるのではなく、アノテーションキューは事前定義された評価基準を用いて、構造化されたフォーマットで特定の実行を提示します。
効果的なアノテーションキューシステムでは、以下が可能です:
特定のトレースをレビューのためにルーティングする: すべてをレビューする代わりに、特定のサブセット(否定的なフィードバックがあった実行、高コストのインタラクション、特定の時間枠からのクエリなど)をキューに送る
レビュー基準を定義する: レビュアーが正確に何を評価すべきか(関連性、正確性、口調、安全性)を知るための評価基準を設定する
チームコラボレーションを可能にする: 複数のレビュアーが進捗追跡と役割割り当てを行いながらキューを処理できる
フィードバックループを作成する: レビューされたデータに修正を加えて注釈を付け、評価データセットに追加できる
アノテーションキューは、新しい失敗モードを理解しようとしたり、評価者のためのトレーニングデータを構築したり、専門的なクエリに関する専門家のドメインフィードバックを得たりしようとするときに特に価値があります。
考慮すべきトレードオフ: アノテーションキューには専任のレビュアーの時間が必要であり、改善サイクルに遅延をもたらす可能性があります。包括的なカバレッジを試みるよりも、特定の高価値なトレースに焦点を当てたときに最も効果的であることがわかりました。
人間の判断の代理としてのLLM
2つ目のアプローチは、人間の判断をスケールさせるためにLLM自体を使用することです。LLMは完璧な評価者ではありませんが、人間にはできない規模で多くの品質次元を評価できます。
特に、オンライン評価者を設定して、すべての実行またはサンプリングされたサブセットに対して、本番トラフィック上で自動的に実行させることができます。これらの評価者は以下をチェックできます:
参照不要の品質メトリクス: 正解の答えを必要としない、一貫性や口調などの属性
安全性とコンプライアンス: 応答に機密情報が含まれているか、ポリシーに違反しているか、有害な振る舞いを示しているか
フォーマット検証: 出力が期待される構造に従っているか、必要な要素を含んでいるか
トピック分類: ユーザーがどのようなカテゴリのリクエストをしているか
LLMは、人間のレビューを超える規模で自然言語を評価できます。人間が数十のトレースをレビューする間、LLM評価者は数千を評価し、潜在的な問題にフラグを立て、集計メトリクスを提供できます。
しかし、LLMベースの評価者には限界があります。
原文を表示
When you ship traditional software to production, you have a good sense of what to expect. Users click buttons, fill out forms, navigate through predetermined paths. Your test suite might cover 80-90% of code paths, and monitoring tools track the usual suspects: error rates, response times, database queries. When something breaks, you look at stack traces and logs.
Agents operate differently. They accept natural language input, where the space of possible queries is unbounded. They're powered by large language models that are sensitive to subtle variations in prompts and can produce different outputs for the same input. And they make decisions through multi-step reasoning chains, tool calls, and retrieval operations that are difficult to fully anticipate during development.
This means that production monitoring for agents requires different capabilities than traditional observability. In this post, we'll explore why agent observability has distinct challenges, what you need to monitor, and what we've learned from teams deploying agents at scale.
Why agents are different from traditional software
Working with teams deploying agents to production, we've observed two key distinctions that affect monitoring approaches.
Agents have an infinite input space
Traditional software has a finite, constrained input space. Users interact through buttons, dropdowns, forms, and API calls with specific formats. When you design a checkout flow, you know the exact sequence of screens and possible user actions. Your error handling can be comprehensive because you can enumerate the failure modes.
Agents, by contrast, accept natural language as their primary input. Natural language has no fixed set of valid inputs. Users can phrase the same request in countless ways — vague or specific, formal or casual, combining multiple intents in a single message or spreading a single request across multiple turns.
Consider a customer support agent. In traditional software, users would navigate to "Order History," click on an order, click "Request Refund," and finally fill out a form with predefined options. The path is fixed and testable.
With an agent, users might say:
"I want to return my order"
"Can you help me get my money back for the shoes I bought last week?"
"The item I received is damaged, what are my options?"
"order #12345 refund please"
Each represents the same underlying intent, but the agent needs to understand the variation, extract the relevant information, and determine the appropriate actions. This infinite input space means you cannot fully predict how your agent will be used until real users start interacting with it.
LLMs are not robust to small changes
The second key difference is that LLMs exhibit prompt sensitivity and non-deterministic behavior. Even small variations in input can lead to different outputs, and the same input can sometimes produce different results.
This happens for several reasons. LLMs use probabilistic sampling during generation, which introduces variance. Most importantly, LLMs respond differently to subtle changes in phrasing, context, or instruction ordering.
This non-determinism means that the behavior you observe in development may not match what happens in production. A prompt that works reliably in testing might fail on edge cases you didn't encounter. An agent that correctly uses tools during evaluation might occasionally select the wrong tool for user queries with slightly different phrasing.
Production monitoring for agents is different
Traditional Application Performance Monitoring (APM) tools focus on metrics like latency, traffic, errors, and saturation. They track HTTP requests, database queries, and system resources. They're designed for structured, deterministic systems where you know the possible code paths.
Agent observability requires monitoring the inputs and outputs themselves, not just the system metrics around them.
Monitoring natural language interactions
When your agent is having conversations with users, the primary signal lives in the conversations themselves. You need to capture:
Complete prompt-response pairs: Not just that a request happened, but what the user asked and what the agent responded
Multi-turn context: Agents often operate across multiple exchanges as part of one conversation, so you need to group related interactions together
Agent trajectory and intermediate steps: Agents can take multi-step paths to reach a final output, calling tools and reasoning through options. You need visibility into each step of the trajectory, not just the final response
This is qualitatively different from traditional logging. A traditional web request might be summarized as "POST /api/checkout 200 OK 342ms." An agent interaction is a natural language conversation with potentially dozens of steps — and the question of whether it went well isn't answerable from the status code.
The challenge of human judgment at scale
Natural language interactions often require human judgment to evaluate properly. Is this response helpful? Did the agent understand the user's intent? Was the tone appropriate? Did it retrieve relevant information?
During development, this is manageable — you review traces manually, tweak prompts, and iterate. But in production, you might be handling thousands or millions of interactions. Human reviewers can meaningfully assess 50-100 traces per hour, but at 1,000 requests per day, full manual review would require 10-20 hours of dedicated human time, daily. This raises an important question: how do you bring human intelligence to production data when manual review doesn't scale?
We've found two complementary approaches effective.
Annotation queues for structured human review
Annotation queues help make human review as efficient as possible. Rather than asking reviewers to hunt through production logs, an annotation queue presents specific runs in a structured format with a predefined rubric.
An effective annotation queue system lets you:
Route specific traces for review: Instead of reviewing everything, send particular subsets to the queue (runs with negative feedback, high-cost interactions, or queries from a specific time window)
Define review criteria: Set up rubrics so reviewers know exactly what to evaluate (relevance, correctness, tone, safety)
Enable team collaboration: Multiple reviewers can work through queues with progress tracking and role assignments
Create feedback loops: Reviewed data can be annotated with corrections and added to evaluation datasets
Annotation queues are especially valuable when you're trying to understand a new failure mode, build up training data for evaluators, or get expert domain feedback on specialized queries.
Trade-offs to consider: Annotation queues require dedicated reviewer time and can introduce latency into the improvement cycle. We've found they work best when focused on specific high-value traces rather than attempting comprehensive coverage.
LLMs as a proxy for human judgment
The second approach is to use LLMs themselves to scale human judgment. While LLMs aren't perfect evaluators, they can assess many quality dimensions at a scale that humans cannot.
In particular, you can configure online evaluators to run automatically on production traffic, either on all runs or on a sampled subset. These evaluators can check:
Reference-free quality metrics: Attributes like coherence and tone that don't require a ground truth answer
Safety and compliance: Whether responses contain sensitive information, violate policies, or exhibit harmful behavior
Format validation: Whether outputs follow expected structures or contain required elements
Topic classification: What categories of requests users are making
LLMs can assess natural language at a scale beyond human review. While humans might review dozens of traces, an LLM evaluator can assess thousands, flagging potential issues and providing aggregate metrics.
However, LLM-based evaluations also introduce their own costs and constraints:
Latency: Evaluators can add a few seconds of latency per trace, which may be acceptable for async batch evaluation but not for synchronous user feedback
Cost: Evaluating all traces can add to your inference costs, which is why we typically recommend sampling 10-20% of traffic
Accuracy: Off-the-shelf evaluators may not reflect what "good" means for your specific app. Custom LLM-as-judge evaluators aligned to your use case are often necessary, but ensuring they agree with human judgment can also be difficult. We built Align Evals to help teams validate their custom evaluators are calibrated against human labels before you trust them at scale.
Evaluation drift: As production traffic shifts, evaluators may need retuning or replacement
For these reasons, we recommend combining automated evaluation with periodic human review rather than relying solely on LLM evaluators.
Tools for production agent observability
Building effective production observability for agents requires a specific set of capabilities, most of which general-purpose monitoring tools weren't designed to provide. Based on patterns we observed across dozens of production deployments, we built the following into LangSmith.
Insights Agent: Discovering usage and error patterns
One of the more challenging aspects in production is simply understanding what users are doing with your agent.
When we analyzed how teams were using production traces, we found they needed a way to automatically discover patterns without specifying what to look for upfront. This motivated us to build Insights Agent, which uses an automated clustering system that groups similar traces to identify:
Usage patterns: What are the most common types of requests users make? Which features or capabilities are they trying to use?
Error modes: Where is the agent making mistakes? Are there common failure patterns like incorrect tool selection, retrieval failures, or misunderstanding user intent?
Edge cases: What unexpected queries are users sending that you didn't account for?
Insights Agent can be configured to group traces by usage patterns, failure modes, or custom attributes specific to your domain. You can also filter the analysis to specific subsets (time windows, user cohorts, feature areas) and save configurations for repeated analysis.
For example, a product manager at a company with an embedded copilot might ask: "What parts of our product are users trying to use the copilot for most often?" Insights Agent can analyze thousands of traces, group them by intent, and surface the top usage categories.
An engineer debugging quality issues might ask: "Where is my agent selecting the wrong tools?" Insights Agent can identify common patterns in tool selection failures and provide representative examples.
This automated pattern discovery helps make the volume of production traces more manageable and actionable.
Online Evaluations: Continuous quality monitoring
We mentioned online evaluations earlier as a way to scale human judgment. Let's look at how they work in practice.
With online evaluations, you set up evaluators that run automatically on production traces. You can configure:
Which traces to evaluate: All traces, sampled percentages (typically 10-20%), or specific filtered subsets
What to evaluate: Quality metrics, safety checks, format validation, or custom criteria
When to alert: Thresholds that trigger notifications when metrics degrade
Online evaluations serve several purposes beyond traditional "testing":
Quality monitoring: You can track how often the agent produces helpful, relevant, correct responses over time. This allows you to detect when quality degrades due to model updates, data drift, or new user patterns.
Topic tagging: You can automatically classify production queries into categories for product analytics. This gives you visibility into what users are actually trying to accomplish.
Trajectory eval
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み