Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

32.2 KB
Raw Blame
<!doctype html><html lang=en dir=ltr class="blog-wrapper blog-post-page mj-root plugin-blog plugin-id-default" data-has-hydrated=false><head><meta charset=UTF-8><meta name=generator content="Docusaurus v3.10.0"><title data-rh=true>Your agent returned 200 OK. It may still have failed | Mercury Agent</title><meta data-rh=true name=viewport content="width=device-width, initial-scale=1.0"/><meta data-rh=true property=og:url content=https://mercuryagent.sh/blog/agent-observability-first-wrong-step /><meta data-rh=true property=og:locale content=en /><meta data-rh=true name=docusaurus_locale content=en /><meta data-rh=true name=docusaurus_tag content=default /><meta data-rh=true name=docsearch:language content=en /><meta data-rh=true name=docsearch:docusaurus_tag content=default /><meta data-rh=true name=theme-color content=#0a0d10 media="(prefers-color-scheme: dark)"/><meta data-rh=true name=theme-color content=#fbfbf8 media="(prefers-color-scheme: light)"/><meta data-rh=true name=description content="What to record in an AI agent run to find its first wrong step, and what Mercury records today. Based on OpenTelemetry's GenAI agent spans and a code review."/><meta data-rh=true property=og:description content="What to record in an AI agent run to find its first wrong step, and what Mercury records today. Based on OpenTelemetry's GenAI agent spans and a code review."/><meta data-rh=true name=keywords content="ai agent observability,trace ai agent,debug ai agent,opentelemetry genai agent spans,agent tool call tracing,ai agent first wrong step"/><meta data-rh=true property=og:type content=article /><meta data-rh=true property=article:published_time content=2026-10-31T00:00:00.000Z /><meta data-rh=true property=article:author content=https://github.com/tashiriskhan /><meta data-rh=true property=article:tag content=Engineering,Runtime /><meta data-rh=true property=og:image content="https://mercuryagent.sh/img/og/blog/agent-observability-first-wrong-step.jpg?v=2"/><meta data-rh=true property=og:image:secure_url content="https://mercuryagent.sh/img/og/blog/agent-observability-first-wrong-step.jpg?v=2"/><meta data-rh=true property=og:image:type content=image/jpeg /><meta data-rh=true property=og:image:width content=1200 /><meta data-rh=true property=og:image:height content=630 /><meta data-rh=true property=og:image:alt content="Your agent returned 200 OK. It may still have failed. Engineering · 7 min read. Mercury Blog"/><meta data-rh=true name=twitter:card content=summary_large_image /><meta data-rh=true name=twitter:image content="https://mercuryagent.sh/img/og/blog/agent-observability-first-wrong-step.jpg?v=2"/><meta data-rh=true name=twitter:image:alt content="Your agent returned 200 OK. It may still have failed. Engineering · 7 min read. Mercury Blog"/><meta data-rh=true property=og:title content="Your agent returned 200 OK. It may still have failed"/><meta data-rh=true name=twitter:title content="Your agent returned 200 OK. It may still have failed"/><meta data-rh=true property=article:section content=Engineering /><meta data-rh=true name=twitter:label1 content=Topic /><meta data-rh=true name=twitter:data1 content=Engineering /><meta data-rh=true name=twitter:label2 content="Reading time"/><meta data-rh=true name=twitter:data2 content="7 min read"/><link data-rh=true rel=icon href=/img/logo-light.png /><link data-rh=true rel=canonical href=https://mercuryagent.sh/blog/agent-observability-first-wrong-step /><link data-rh=true rel=alternate href=https://mercuryagent.sh/blog/agent-observability-first-wrong-step hreflang=en /><link data-rh=true rel=alternate href=https://mercuryagent.sh/blog/agent-observability-first-wrong-step hreflang=x-default /><link data-rh=true rel=alternate type=text/markdown href=/blog/agent-observability-first-wrong-step.md title="Markdown version"/><script data-rh=true type=application/ld+json>{"@context":"https://schema.org","@id":"https://mercuryagent.sh/blog/agent-observability-first-wrong-step","@type":"BlogPosting","author":{"@type":"Person","description":"Contributor, Mercury","image":"https://github.com/tashiriskhan.png","name":"Tashir Khan","url":"https://github.com/tashiriskhan"},"datePublished":"2026-10-31T00:00:00.000Z","description":"What to record in an AI agent run to find its first wrong step, and what Mercury records today. Based on OpenTelemetry's GenAI agent spans and a code review.","headline":"Your agent returned 200 OK. It may still have failed","image":{"@id":"https://mercuryagent.sh/assets/images/cover-c2e93124d66c296e2d00df4555aca896.jpg","@type":"ImageObject","caption":"title image for the blog post: Your agent returned 200 OK. It may still have failed","contentUrl":"https://mercuryagent.sh/assets/images/cover-c2e93124d66c296e2d00df4555aca896.jpg","url":"https://mercuryagent.sh/assets/images/cover-c2e93124d66c296e2d00df4555aca896.jpg"},"isPartOf":{"@id":"https://mercuryagent.sh/blog","@type":"Blog","name":"Mercury Blog"},"keywords":["ai agent observability","trace ai agent","debug ai agent","opentelemetry genai agent spans","agent tool call tracing","ai agent first wrong step"],"mainEntityOfPage":"https://mercuryagent.sh/blog/agent-observability-first-wrong-step","name":"Your agent returned 200 OK. It may still have failed","url":"https://mercuryagent.sh/blog/agent-observability-first-wrong-step"}</script><script data-rh=true type=application/ld+json>{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","item":"https://mercuryagent.sh/","name":"Mercury","position":1},{"@type":"ListItem","item":"https://mercuryagent.sh/blog","name":"Blog","position":2},{"@type":"ListItem","item":"https://mercuryagent.sh/blog/tags/engineering","name":"Engineering","position":3},{"@type":"ListItem","item":"https://mercuryagent.sh/blog/agent-observability-first-wrong-step","name":"Your agent returned 200 OK. It may still have failed","position":4}]}</script><link rel=alternate type=application/rss+xml href=/blog/rss.xml title="Mercury Blog RSS Feed"><link rel=alternate type=application/atom+xml href=/blog/atom.xml title="Mercury Blog Atom Feed"><link rel=alternate type=application/json href=/blog/feed.json title="Mercury Blog JSON Feed"><meta name=twitter:site content=@mercuryagent><meta property=og:site_name content="Mercury Agent"><meta name=application-name content="Mercury Agent"><link rel=preconnect href=https://fonts.googleapis.com><link rel=preconnect href=https://fonts.gstatic.com crossorigin=anonymous><link rel=stylesheet href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap"><link rel=apple-touch-icon href=/img/logo-light.png><script src=https://analytics.cosmicstack.org/js/pa--flkUFvdfmsPSUtRivKAK.js async></script><script src=/js/plausible-init.js></script><link rel=stylesheet href=/assets/css/styles.b525f68d.css /><script src=/assets/js/runtime~main.c3075c62.js defer></script><script src=/assets/js/main.69097411.js defer></script></head><body><svg style="display: none;"><defs>
<symbol id=theme-svg-external-link viewBox="0 0 24 24"><path fill=currentColor d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></symbol>
</defs></svg>
<script>!function(){var t=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme-ebb")}catch(t){}}();document.documentElement.setAttribute("data-theme",t||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")),document.documentElement.setAttribute("data-theme-choice",t||"system")}(),function(){try{for(var[t,e]of new URLSearchParams(window.location.search).entries())if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss-ebb")}catch(t){}return!1}())</script><div id=__docusaurus><link rel=preload as=image href=/img/logo-light.png /><link rel=preload as=image href=/img/logo-dark.png /><link rel=preload as=image href=https://github.com/tashiriskhan.png /><link rel=preload as=image href=/assets/images/cover-c2e93124d66c296e2d00df4555aca896.jpg fetchpriority=high /><div role=region aria-label="Skip to main content"><a class=skipToContent_fXgn href=#__docusaurus_skipToContent_fallback>Skip to main content</a></div><div class="theme-announcement-bar announcementBar_mb4j" role=banner><div class=announcementBarPlaceholder_vyr4></div><div class="content_knG7 announcementBarContent_xLdY">☿ Mercury 1.5.0 is out with <strong>Mercury Desktop</strong> for macOS, Windows and Linux, remote access you control, and updates that roll back on their own. <a href=/download>Download it →</a></div><button type=button aria-label=Close class="clean-btn close closeButton_CVFx announcementBarClose_gvF7"><svg viewBox="0 0 15 15" width=14 height=14><g stroke=currentColor stroke-width=3.1><path d="M.75.75l13.5 13.5M14.25.75L.75 14.25"/></g></svg></button></div><nav aria-label=Main class="theme-layout-navbar navbar navbar--fixed-top"><div class=navbar__inner><div class="theme-layout-navbar-left navbar__items"><button aria-label="Toggle navigation bar" aria-expanded=false class="navbar__toggle clean-btn" type=button><svg width=30 height=30 viewBox="0 0 30 30" aria-hidden=true><path stroke=currentColor stroke-linecap=round stroke-miterlimit=10 stroke-width=2 d="M4 7h22M4 15h22M4 23h22"/></svg></button><a class=navbar__brand href=/><div class=navbar__logo><img src=/img/logo-light.png alt="Mercury Agent" class="themedComponent_mlkZ themedComponent--light_NVdE"/><img src=/img/logo-dark.png alt="Mercury Agent" class="themedComponent_mlkZ themedComponent--dark_xIcU"/></div><b class="navbar__title text--truncate">Mercury</b></a><a class="navbar__item navbar__link" href=/docs>Docs</a><a class="navbar__item navbar__link" href=/docs/integrations/coding-workspace>Code</a><a class="navbar__item navbar__link" href=/docs/integrations/mercury-bots>Bots</a><a class="navbar__item navbar__link" href=/cloud>Cloud</a><a href=https://skills.mercuryagent.sh target=_blank rel="noopener noreferrer" class="navbar__item navbar__link">Skills<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><a aria-current=page class="navbar__item navbar__link navbar__link--active" href=/blog>Blog</a><a class="navbar__item navbar__link" href=/docs/releases>Changelog</a></div><div class="theme-layout-navbar-right navbar__items navbar__items--right"><a href=https://github.com/cosmicstack-labs/mercury-agent target=_blank rel="noopener noreferrer" class="navbar__item navbar__link navbar-github" aria-label="Mercury Agent on GitHub"></a><a class="navbar__item navbar__link navbar-cta" href=/download>Download</a><div class="toggle_vylO colorModeToggle_DEke"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type=button disabled title="system mode" aria-label="Switch between dark and light mode (currently system mode)"><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP lightToggleIcon_pyhR"><path fill=currentColor d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"/></svg><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP darkToggleIcon_wfgR"><path fill=currentColor d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"/></svg><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP systemToggleIcon_QzmC"><path fill=currentColor d="m12 21c4.971 0 9-4.029 9-9s-4.029-9-9-9-9 4.029-9 9 4.029 9 9 9zm4.95-13.95c1.313 1.313 2.05 3.093 2.05 4.95s-0.738 3.637-2.05 4.95c-1.313 1.313-3.093 2.05-4.95 2.05v-14c1.857 0 3.637 0.737 4.95 2.05z"/></svg></button></div><div class=navbarSearchContainer_Bca1><div class="navbar__search searchBarContainer_NW3z" dir=ltr><input placeholder=Search aria-label=Search class="navbar__search-input searchInput_YFbd" value="" /><div class="loadingRing_RJI3 searchBarLoadingRing_YnHq"><div></div><div></div><div></div><div></div></div></div></div></div></div><div role=presentation class=navbar-sidebar__backdrop></div></nav><div id=__docusaurus_skipToContent_fallback class="theme-layout-main main-wrapper mainWrapper_z2l0"><main class=mj-post><div class=mj-progress role=progressbar aria-label="Reading progress" aria-valuemin=0 aria-valuemax=100 aria-valuenow=0><span style=transform:scaleX(0)></span></div><button type=button class=mj-progress-pill aria-label="7 min left. Back to top" tabindex=-1><svg viewBox="0 0 20 20" width=18 height=18 aria-hidden=true><circle cx=10 cy=10 r=8 class=mj-ring-bg /><circle cx=10 cy=10 r=8 class=mj-ring style=stroke-dashoffset:50.27 /></svg><span>7 min left</span></button><header class=mj-post-head><a class=mj-back href=/blog>← Blog</a><a class=mj-post-cat href=/blog/tags/engineering>Engineering</a><h1 class=mj-post-title>Your agent returned 200 OK. It may still have failed</h1><p class=mj-post-dek>What to record in an AI agent run to find its first wrong step, and what Mercury records today. Based on OpenTelemetry's GenAI agent spans and a code review.<div class=mj-post-byline><div class=mj-post-authors><a class=mj-post-author href=/blog/authors/tashiriskhan><img src=https://github.com/tashiriskhan.png alt="" width=36 height=36 /><span><strong>Tashir Khan</strong><em>Contributor, Mercury</em></span></a></div><div class=mj-meta><time datetime=2026-10-31T00:00:00.000Z>Oct 31, 2026</time><span aria-hidden=true>·</span><span>7<!-- --> min read</span></div></div></header><div class=mj-post-banner><img src=/assets/images/cover-c2e93124d66c296e2d00df4555aca896.jpg alt="" width=1600 height=900 fetchpriority=high decoding=async /></div><div class="mj-post-layout has-toc"><aside class=mj-post-toc aria-label="On this page"><div class=mj-toc-head><p>On this page</p><span class=mj-toc-left>7 min left</span></div><div class=mj-toc-meter aria-hidden=true><span style=transform:scaleX(0)></span></div><div class=tableOfContentsInline_prmo><ul class=table-of-contents><li><a href=#why-normal-monitoring-misses-agent-failures>Why normal monitoring misses agent failures</a><li><a href=#the-unit-of-debugging-is-the-first-wrong-step>The unit of debugging is the first wrong step</a><li><a href=#what-a-useful-agent-trace-records>What a useful agent trace records</a><li><a href=#three-cautions>Three cautions</a><li><a href=#what-mercury-records-today>What Mercury records today</a><li><a href=#what-we-would-instrument-first>What we would instrument first</a><li><a href=#what-it-means-for-you>What it means for you</a></ul></div></aside><article class="mj-prose markdown"><p>An agent can finish a run with a fluent, confident answer and still have done the wrong thing. It may have picked the wrong tool, pulled a stale fact into context, or called the same tool five times with the same arguments. Uptime and error logs won't show any of that. This post looks at what a run needs to record so that you can find the first step where it went wrong, and what Mercury records today.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=why-normal-monitoring-misses-agent-failures>Why normal monitoring misses agent failures<a href=#why-normal-monitoring-misses-agent-failures class=hash-link aria-label="Direct link to Why normal monitoring misses agent failures" title="Direct link to Why normal monitoring misses agent failures" translate=no>​</a></h2>
<p>A normal service either fails or it doesn't. An agent can return a successful response and still fail the task. A 200 OK means the request was handled. It does not mean the task succeeded. <a href=https://www.snowflake.com/en/artificial-intelligence/agents/agent-evaluation target=_blank rel="noopener noreferrer" class="">Snowflake's agent evaluation guide</a> puts the gap plainly: a correct final answer is only the last part of the run. It also separates two jobs. Evaluation measures quality against defined tasks. Monitoring watches live behaviour through traces, logs, latency, cost, tool failures and user feedback.</p>
<p>Microsoft's <a href=https://learn.microsoft.com/en-us/azure/foundry/concepts/observability target=_blank rel="noopener noreferrer" class="">Foundry observability documentation</a> describes tracing as capturing LLM calls, tool invocations, agent decisions and dependencies between services. New Relic's <a href=https://newrelic.com/blog/observability/ai-agent-observability target=_blank rel="noopener noreferrer" class="">agent observability write-up</a> makes the same point from the vendor side: without trace-level data, you can see that something went wrong but not why.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=the-unit-of-debugging-is-the-first-wrong-step>The unit of debugging is the first wrong step<a href=#the-unit-of-debugging-is-the-first-wrong-step class=hash-link aria-label="Direct link to The unit of debugging is the first wrong step" title="Direct link to The unit of debugging is the first wrong step" translate=no>​</a></h2>
<p>The final output is the symptom. The cause is usually an early step: a tool chosen when another was needed, a retrieved document that was out of date, or an argument that looked reasonable and wasn't. By the time the answer is wrong, that step is several calls back.</p>
<p>In this post, the first wrong step means the earliest consequential deviation: the first step whose effect changed what came after it in a way that mattered to the outcome. A step that was odd but harmless does not count.</p>
<p>So the question for a trace is not "what did the agent do?" It is "where is the earliest consequential deviation, and what did the agent have in front of it at that point?" A trace that can't answer that will show you a long, plausible transcript and leave you to read all of it.</p>
<p>Here is a made-up run to show the difference. The user asks for last month's invoice total. Step 1 searches the wrong folder and gets a file from the previous year. Step 2 reads it, sums the totals, and reports a figure. Step 3 writes a fluent summary. The final answer looks right, and every tool call returned <code>ok</code>. A transcript shows three clean steps. A trace with timestamps, arguments and parent links shows that step 1 was the first consequential deviation, and that step 2 never had a chance to fix it. The run was never going to produce the right number, so the fix belongs at step 1, not in the summary.</p>
<p>This example is illustrative, not a recorded Mercury incident.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=what-a-useful-agent-trace-records>What a useful agent trace records<a href=#what-a-useful-agent-trace-records class=hash-link aria-label="Direct link to What a useful agent trace records" title="Direct link to What a useful agent trace records" translate=no>​</a></h2>
<p>The clearest published model I found is OpenTelemetry's draft GenAI agent conventions. The <a href=https://raw.githubusercontent.com/open-telemetry/semantic-conventions/v1.41.0/docs/gen-ai/gen-ai-agent-spans.md target=_blank rel="noopener noreferrer" class="">v1.41.0 agent span spec</a> defines operation names including <code>invoke_agent</code>, <code>execute_tool</code>, <code>create_agent</code> and <code>invoke_workflow</code>. The <a href=https://opentelemetry.io/blog/2026/genai-observability/index.md target=_blank rel="noopener noreferrer" class="">OpenTelemetry GenAI blog</a> shows the resulting tree: an <code>invoke_agent</code> span with child spans for each model call and each tool call. It also records token counts such as <code>gen_ai.usage.input_tokens</code> and <code>gen_ai.usage.output_tokens</code>, plus finish reasons and latency histograms.</p>
<p>Mapped to the questions you need to answer:</p>
<table><thead><tr><th>Question<th>What to record<tbody><tr><td>Which tool was chosen?<td>The chosen tool, its arguments, and the tools available at that step<tr><td>Did the call work?<td>The result, error type, latency, and whether the result entered subsequent context<tr><td>Is it looping?<td>Repeated calls with the same arguments, or revisited goals<tr><td>Where did work pass?<td>Handoffs to sub-agents, and what context went with them<tr><td>What changed in context?<td>Items added, dropped or summarised between steps<tr><td>What did it cost?<td>Token usage and money per model call, so a runaway loop shows up as a number<tr><td>Where did it first go wrong?<td>Ordered steps with timestamps and parent links, so you can walk back from the bad output</table>
<p>The last row is the one that matters most. Parent links and timestamps are what turn a transcript into something you can walk backwards through.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=three-cautions>Three cautions<a href=#three-cautions class=hash-link aria-label="Direct link to Three cautions" title="Direct link to Three cautions" translate=no>​</a></h2>
<p><strong>Traces show what happened, not whether it was right.</strong> You still need evaluations over whole runs. Snowflake notes that production traces are often the raw material for later evaluations, so the two work together.</p>
<p><strong>Full content is useful and risky.</strong> Tool arguments and results can contain personal data, credentials or customer records. The OpenTelemetry GenAI blog notes that content capture is opt-in for this reason. Redaction and retention need an explicit design, not a default that someone forgets to change.</p>
<p><strong>The standard is not final.</strong> The OpenTelemetry agent spans are marked as development status, and vendor dashboards may use different attribute names. Treat these conventions as the best current reference, not as settled.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=what-mercury-records-today>What Mercury records today<a href=#what-mercury-records-today class=hash-link aria-label="Direct link to What Mercury records today" title="Direct link to What Mercury records today" translate=no>​</a></h2>
<p>We read the code paths in <code>src/core/agent.ts</code>, <code>src/core/context-window.ts</code> and <code>src/utils/logger.ts</code> at commit <code>c969d77</code> on <code>main</code>. We did not run a live session, so the findings below are from code review.</p>
<p>It helps to separate two kinds of observability. Live observability is what you can see while a run is happening. Persisted observability is what survives the run, so you can debug it afterwards. Mercury has some of the first and, from what we found, very little of the second.</p>
<p><strong>Live observability:</strong></p>
<ul>
<li class=""><strong>Live tool events.</strong> Each tool start and finish is pushed to the interface with its duration. We did not find a persistent record of these events.</li>
<li class=""><strong>A per-turn usage log.</strong> At the end of a turn, Mercury logs the provider, model, input, cached and output tokens, step count, tool-call count and elapsed time. The logger is pino, and its level is <code>silent</code> unless you run with <code>--verbose</code> or set <code>LOG_LEVEL</code>.</li>
</ul>
<p><strong>Persisted observability:</strong></p>
<ul>
<li class=""><strong>A turn-end tool trace.</strong> Each tool call becomes one line: the tool name, one summarised argument capped at 80 characters, and an outcome such as <code>ok (12 lines)</code> or an error message. These lines are written into the session so the next turn can see them. The trace is capped by line count. We did not find the per-turn usage log kept anywhere by default.</li>
<li class=""><strong>Redaction of errors.</strong> Errors pass through a <code>redactDeep</code> helper before they are logged, so keys in provider errors are masked.</li>
</ul>
<p>Measured against the table above, we did not find the following:</p>
<ul>
<li class="">Call IDs, timestamps, durations or step indexes in the stored trace. You can read the order, but not the timing.</li>
<li class="">A record of the tools available at each step.</li>
<li class="">A parent link from a delegated task to the work it produced.</li>
<li class="">Per-model-call token usage or cost. Usage is recorded per turn.</li>
<li class="">A record of context changes, such as compaction and tool-result summarising. These appear to happen in memory.</li>
<li class="">Full arguments. The stored trace caps them at 80 characters, so you often can't reconstruct exactly what was sent.</li>
<li class="">An OpenTelemetry dependency in <code>package.json</code>, or an audit log.</li>
</ul>
<p>So the honest version is this. From the code we read, Mercury can show roughly what it did in the last turn. We did not find a way to show the first wrong step of a bad run from what it stores. This is the same gap our October 17 permissions post described from the other side: we can't audit access we don't record.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=what-we-would-instrument-first>What we would instrument first<a href=#what-we-would-instrument-first class=hash-link aria-label="Direct link to What we would instrument first" title="Direct link to What we would instrument first" translate=no>​</a></h2>
<p>The smallest change that closes the biggest gap is to give every tool call a stable ID, a start time, a duration and a parent turn ID, and to write those to the session store instead of only the summary line. That alone lets you order a run, time it, and link each call to the turn that made it. Per-model-call token usage comes next, then content capture behind an explicit, off-by-default setting with redaction.</p>
<p>We have not built this yet. It is a plan, not a shipped feature.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=what-it-means-for-you>What it means for you<a href=#what-it-means-for-you class=hash-link aria-label="Direct link to What it means for you" title="Direct link to What it means for you" translate=no>​</a></h2>
<p>If you run agents in production, check three things before you need them. Can you tell which tool call came first in a bad run? Can you see how long each call took? Can you see what a single run cost, call by call? If the answer to any of these is no, that is a gap to close before the next failure.</p>
<p>If you cannot reconstruct the run after it fails, a successful response can hide more than it proves.</article></div><footer class=mj-post-foot><div class=mj-tools aria-label="Share and export"><button type=button>Copy as Markdown</button><a href=/blog/agent-observability-first-wrong-step.md>View .md</a><button type=button>Copy link</button><a href="https://x.com/intent/post?url=https%3A%2F%2Fmercuryagent.sh%2Fblog%2Fagent-observability-first-wrong-step&text=Your%20agent%20returned%20200%20OK.%20It%20may%20still%20have%20failed" target=_blank rel="noopener noreferrer">Share on X</a><a href="https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmercuryagent.sh%2Fblog%2Fagent-observability-first-wrong-step" target=_blank rel="noopener noreferrer">LinkedIn</a></div><div class=mj-post-tags><a href=/blog/tags/engineering>Engineering</a><a href=/blog/tags/runtime>Runtime</a></div><nav class=mj-pager aria-label="More posts"><a href=/blog/mercury-desktop-tour><small>Newer</small>A tour of Mercury Desktop: one app, every Mercury you run</a><a class=is-next href=/blog/running-an-agent-overnight><small>Older</small>Running an agent overnight: what breaks first</a></nav><section class=mj-more><h2>More from the blog</h2><ul><li><a href=/blog/what-is-a-personal-ai-assistant>What Is a Personal AI Assistant? 10 Real Tasks in 2026</a><time datetime=2026-11-11T00:00:00.000Z>Nov 11, 2026</time><li><a href=/blog/six-ai-agents-compared-for-real-work>9 Safest, Most Secure, and Permission-Aware AI Agents for Real-World Tasks</a><time datetime=2026-11-05T00:00:00.000Z>Nov 5, 2026</time><li><a href=/blog/mercury-1-5>Mercury 1.5: Mercury Desktop</a><time datetime=2026-11-03T00:00:00.000Z>Nov 3, 2026</time></ul></section></footer></main></div><footer class="theme-layout-footer footer"><div class="container container-fluid"><div class="row footer__links"><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Product</div><ul class="footer__items clean-list"><li class=footer__item><a class=footer__link-item href=/download>Download</a><li class=footer__item><a class=footer__link-item href=/#install>Install on a server</a><li class=footer__item><a class=footer__link-item href=/docs/integrations/coding-workspace>Mercury Code</a><li class=footer__item><a class=footer__link-item href=/docs/integrations/mercury-bots>Mercury Bots</a><li class=footer__item><a class=footer__link-item href=/cloud>Mercury Cloud</a><li class=footer__item><a class=footer__link-item href=/blog>Blog</a><li class=footer__item><a class=footer__link-item href=/docs/releases>Changelog</a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Trust</div><ul class="footer__items clean-list"><li class=footer__item><a class=footer__link-item href=/docs/reference/permissions>Permissions model</a><li class=footer__item><a class=footer__link-item href=/docs/reference/second-brain>Second Brain memory</a><li class=footer__item><a class=footer__link-item href=/docs/reference/completion-architecture>Completion contract</a><li class=footer__item><a class=footer__link-item href=/#compare>Honest comparison</a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Docs</div><ul class="footer__items clean-list"><li class=footer__item><a class=footer__link-item href=/docs>Getting started</a><li class=footer__item><a class=footer__link-item href=/docs/cli-commands/cli-commands>CLI commands</a><li class=footer__item><a class=footer__link-item href=/docs/reference/built-in-tools>Built-in tools</a><li class=footer__item><a class=footer__link-item href=/docs/reference/configuration>Configuration</a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Community</div><ul class="footer__items clean-list"><li class=footer__item><a href=https://github.com/cosmicstack-labs/mercury-agent target=_blank rel="noopener noreferrer" class=footer__link-item>GitHub<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://github.com/cosmicstack-labs/mercury-agent/issues target=_blank rel="noopener noreferrer" class=footer__link-item>Issues<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://skills.mercuryagent.sh target=_blank rel="noopener noreferrer" class=footer__link-item>Skills registry<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://www.npmjs.com/package/@cosmicstack/mercury-agent target=_blank rel="noopener noreferrer" class=footer__link-item>npm<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a></ul></div></div><div class="footer__bottom text--center"><div class=footer__copyright>© 2026 Cosmic Stack · Mercury Agent is MIT-licensed open source.</div></div></div></footer></div></body>