<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Omansh Bhatnagar</title>
    <description>The latest articles on DEV Community by Omansh Bhatnagar (@claven07).</description>
    <link>https://dev.to/claven07</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4125081%2Fdd858202-e99b-4df7-b9e4-09b4e8f8ccb9.jpg</url>
      <title>DEV Community: Omansh Bhatnagar</title>
      <link>https://dev.to/claven07</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/claven07"/>
    <language>en</language>
    <item>
      <title>Building Session-Level Observability for DeepSeek Harness with a Community Plugin</title>
      <dc:creator>Omansh Bhatnagar</dc:creator>
      <pubDate>Mon, 14 Sep 2026 20:19:40 +0000</pubDate>
      <link>https://dev.to/claven07/building-session-level-observability-for-deepseek-harness-with-a-community-plugin-19n6</link>
      <guid>https://dev.to/claven07/building-session-level-observability-for-deepseek-harness-with-a-community-plugin-19n6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Agentic systems can become difficult to debug once a single user request turns into multiple model calls, agent steps, and tool executions.&lt;/p&gt;

&lt;p&gt;A final response tells us what the agent produced, but it doesn't necessarily tell us how it got there.&lt;/p&gt;

&lt;p&gt;For developers building and debugging agent workflows, useful questions include:&lt;/p&gt;

&lt;p&gt;How many agent steps were executed?&lt;br&gt;
How many LLM requests were made?&lt;br&gt;
How many requests failed?&lt;br&gt;
Which tools were called?&lt;br&gt;
Which tool took the longest?&lt;br&gt;
How long did the session run?&lt;br&gt;
What happens to the collected state when the session ends?&lt;/p&gt;

&lt;p&gt;This is where observability becomes important.&lt;/p&gt;

&lt;p&gt;In this article, I'll walk through how I built dsh-plugin-agent-insights, a community plugin for DeepSeek Harness that provides session-scoped observability without modifying the Harness core packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is dsh-plugin-agent-insights?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;dsh-plugin-agent-insights is a session-scoped observability plugin for DeepSeek Harness.&lt;/p&gt;

&lt;p&gt;It tracks:&lt;/p&gt;

&lt;p&gt;Area    Metrics&lt;br&gt;
Agent   Steps, LLM requests, failed LLM requests&lt;br&gt;
Tools   Total, successful, failed calls&lt;br&gt;
Performance Execution duration, slowest tool&lt;br&gt;
Session Start time, total duration&lt;br&gt;
Lifecycle   Disposal and cleanup&lt;/p&gt;

&lt;p&gt;The plugin is implemented as a Cordis service and integrates with Harness lifecycle events.&lt;/p&gt;

&lt;p&gt;Source:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Claven07" rel="noopener noreferrer"&gt;
        Claven07
      &lt;/a&gt; / &lt;a href="https://github.com/Claven07/dsh-plugin-agent-insights" rel="noopener noreferrer"&gt;
        dsh-plugin-agent-insights
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;dsh-plugin-agent-insights&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://www.npmjs.com/package/dsh-plugin-agent-insights" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/5b2dbb7a0a7b12664db423b2e8ec1659001c19ce6ed71774cffdcbb3101dcade/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6473682d706c7567696e2d6167656e742d696e7369676874732e737667" alt="npm version"&gt;&lt;/a&gt;
&lt;a href="https://github.com/Claven07/dsh-plugin-agent-insights/./LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/03391623decd61a53598edefa59b7abb6797c2b886861dd62bb76c7e257631f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f436c6176656e30372f6473682d706c7567696e2d6167656e742d696e7369676874732e737667" alt="license"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Session-scoped observability metrics and performance tracking plugin for the DeepSeek Harness ecosystem.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;dsh-plugin-agent-insights&lt;/code&gt; provides lightweight, non-invasive, session-scoped observability and performance tracking for DeepSeek Harness agents. It registers as a Cordis service (&lt;code&gt;ctx.agentInsights&lt;/code&gt;) and automatically hooks into runtime dispatch pipelines to collect granular metrics without modifying any core packages or interfering with agent execution.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Key Capabilities&lt;/h3&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tool Execution Metrics&lt;/strong&gt;: Captures total tool calls, successful calls, failed calls, precise execution duration via &lt;code&gt;performance.now()&lt;/code&gt;, and identifies the slowest tool invocation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM &amp;amp; Agent Metrics&lt;/strong&gt;: Tracks total agent steps closed, total model requests dispatched, and failed model requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session Duration Metrics&lt;/strong&gt;: Records session start timestamps and total elapsed session duration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global Slowest Tool Tracking&lt;/strong&gt;: Tracks the single slowest tool invocation across all active sessions without retaining references to the sessions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Leak Memory Architecture&lt;/strong&gt;: Stores session statistics in a &lt;code&gt;WeakMap&amp;lt;Session, SessionAgentInsights&amp;gt;&lt;/code&gt;, preventing memory retention…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Claven07/dsh-plugin-agent-insights" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Why Build It as a Plugin?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One reason to use a plugin architecture is to keep specialized functionality separate from core execution logic.&lt;/p&gt;

&lt;p&gt;Observability is a good example.&lt;/p&gt;

&lt;p&gt;Different applications may require:&lt;/p&gt;

&lt;p&gt;basic metrics&lt;br&gt;
performance profiling&lt;br&gt;
tracing&lt;br&gt;
token accounting&lt;br&gt;
dashboards&lt;br&gt;
custom telemetry&lt;/p&gt;

&lt;p&gt;Rather than making all of these features part of the core framework, a plugin can observe the framework's lifecycle and maintain its own state.&lt;/p&gt;

&lt;p&gt;DeepSeek Harness&lt;br&gt;
       │&lt;br&gt;
       ├── Agent execution&lt;br&gt;
       ├── Tool execution&lt;br&gt;
       ├── Sessions&lt;br&gt;
       └── Lifecycle events&lt;br&gt;
                │&lt;br&gt;
                ▼&lt;br&gt;
       Agent Insights&lt;br&gt;
                │&lt;br&gt;
        ┌───────┼────────┐&lt;br&gt;
        ▼       ▼        ▼&lt;br&gt;
      Agent    Tools   Sessions&lt;br&gt;
      Metrics  Metrics Metrics&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding the Harness Lifecycle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The plugin integrates with several lifecycle points:&lt;/p&gt;

&lt;p&gt;agent/request&lt;/p&gt;

&lt;p&gt;Used to observe LLM request attempts.&lt;/p&gt;

&lt;p&gt;agent/request-error&lt;/p&gt;

&lt;p&gt;Used to record failed model requests.&lt;/p&gt;

&lt;p&gt;tools/execute&lt;/p&gt;

&lt;p&gt;Used to measure tool execution duration and outcome.&lt;/p&gt;

&lt;p&gt;session/event&lt;/p&gt;

&lt;p&gt;Used to observe session events and count completed steps.&lt;/p&gt;

&lt;p&gt;session/disposed&lt;/p&gt;

&lt;p&gt;Used to produce a final session summary and clean up session state.&lt;/p&gt;

&lt;p&gt;This separation allows the plugin to observe different parts of the agent lifecycle without owning those operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Measuring Tool Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the most useful metrics is tool latency.&lt;/p&gt;

&lt;p&gt;The plugin wraps the tool execution around next():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;startTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;durationMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;startTime&lt;/span&gt;

  &lt;span class="c1"&gt;// Record execution metric&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For each tool call, the plugin records:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;callId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;durationMs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;isError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;errorMessage&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This makes it possible to identify slow tools and distinguish successful executions from failures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tracking Agent Requests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every LLM request associated with a session increments the session's request counter.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalLlmRequests&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Failed requests are tracked independently:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;failedLlmRequests&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This provides a simple distinction between:&lt;/p&gt;

&lt;p&gt;Total requests&lt;br&gt;
      │&lt;br&gt;
      ├── Successful&lt;br&gt;
      └── Failed&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session-Level Metrics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The plugin aggregates all of this information at the session level.&lt;/p&gt;

&lt;p&gt;A session snapshot can contain:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;sessionId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;sessionStartTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;sessionDurationMs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;totalSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;totalLlmRequests&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;failedLlmRequests&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;totalToolCalls&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;successfulToolCalls&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;failedToolCalls&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;toolExecutions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;slowestTool&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This gives developers a compact view of an entire agent session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Managing Session State&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Session-specific metrics are stored using:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nb"&gt;WeakMap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SessionAgentInsights&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This allows each session to have independent metrics without maintaining a permanent strong reference to every session.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;/p&gt;

&lt;p&gt;Session A → Metrics A&lt;br&gt;
Session B → Metrics B&lt;br&gt;
Session C → Metrics C&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cleaning Up on Session Disposal&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Collecting metrics isn't enough.&lt;/p&gt;

&lt;p&gt;Long-running agent processes can create many sessions, so lifecycle cleanup is important.&lt;/p&gt;

&lt;p&gt;When:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;session/disposed

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;fires, the plugin:&lt;/p&gt;

&lt;p&gt;retrieves the session metrics,&lt;br&gt;
calculates the final duration,&lt;br&gt;
optionally logs a summary,&lt;br&gt;
removes the session entry.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Session completed

8 steps
5 LLM requests
1 failed request
12 tool calls
2 failed tools
14.32s duration
Slowest tool: database-query

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Observability Should Not Break the Agent&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A key design principle was:&lt;/p&gt;

&lt;p&gt;The observability layer should never become another failure point.&lt;/p&gt;

&lt;p&gt;If recording a metric fails, the original agent operation should continue normally.&lt;/p&gt;

&lt;p&gt;For this reason, internal metric collection is isolated with error handling.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Record metric&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;`[agent-insights] Failed to record metric: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The plugin observes execution rather than becoming responsible for execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The plugin supports configuration through the Harness plugin system:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;insert&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agent-insights&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dsh-plugin-agent-insights&lt;/span&gt;
      &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;maxToolHistoryPerSession&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;
        &lt;span class="na"&gt;logSummaryOnDisposed&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;maxToolHistoryPerSession&lt;/p&gt;

&lt;p&gt;Controls the number of individual tool execution records retained per session.&lt;/p&gt;

&lt;p&gt;logSummaryOnDisposed&lt;/p&gt;

&lt;p&gt;Controls whether a summary is logged when the session ends.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Programmatic Usage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The plugin can also be mounted programmatically:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Context&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@deepseek-ai/cordis&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;AgentInsights&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dsh-plugin-agent-insights&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;plugin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AgentInsights&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;maxToolHistoryPerSession&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;logSummaryOnDisposed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Metrics can then be accessed through:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;metrics&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;agentInsights&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMetrics&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The plugin exposes three primary APIs:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;getMetrics&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;getSlowestTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt;
&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The plugin can be added to a profile using the Harness CLI:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dsh plugin &lt;span class="nt"&gt;--profile&lt;/span&gt; &amp;lt;name&amp;gt; add dsh-plugin-agent-insights

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Its cordis.patch.yml provides the corresponding profile integration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The plugin includes its own build and testing workflow:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm run build
pnpm run typecheck
pnpm run &lt;span class="nb"&gt;test
&lt;/span&gt;pnpm run prepublishOnly

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Keeping the plugin independently testable makes it easier to develop without coupling its validation process to unrelated Harness functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Could Be Built on Top of This?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These metrics could serve as the foundation for more advanced observability features:&lt;/p&gt;

&lt;p&gt;performance dashboards&lt;br&gt;
tool latency analysis&lt;br&gt;
agent failure analysis&lt;br&gt;
session comparisons&lt;br&gt;
regression detection&lt;br&gt;
custom telemetry integrations&lt;br&gt;
distributed tracing&lt;/p&gt;

&lt;p&gt;The current plugin is intentionally focused on the fundamentals: collecting useful information while staying out of the agent's execution path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lessons Learned&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lifecycle hooks are powerful extension points&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;They allow functionality to be added without modifying core packages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Instrumentation should observe, not control&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The plugin should never become responsible for the operation it is measuring.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cleanup is part of observability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Metrics need a lifecycle just like the sessions they describe.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Telemetry must fail gracefully&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A metrics failure should never become an agent failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;dsh-plugin-agent-insights demonstrates one practical way to extend DeepSeek Harness through its plugin and lifecycle architecture.&lt;/p&gt;

&lt;p&gt;It provides visibility into:&lt;/p&gt;

&lt;p&gt;agent steps&lt;br&gt;
LLM requests&lt;br&gt;
LLM failures&lt;br&gt;
tool executions&lt;br&gt;
tool failures&lt;br&gt;
tool latency&lt;br&gt;
slowest tools&lt;br&gt;
session duration&lt;br&gt;
session lifecycle&lt;/p&gt;

&lt;p&gt;The larger goal is to show how specialized capabilities can be developed around the Harness ecosystem while keeping the core execution path clean.&lt;/p&gt;

&lt;p&gt;The plugin is available as a community project for experimentation, feedback, and further development.&lt;/p&gt;

&lt;p&gt;Plugin:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Claven07" rel="noopener noreferrer"&gt;
        Claven07
      &lt;/a&gt; / &lt;a href="https://github.com/Claven07/dsh-plugin-agent-insights" rel="noopener noreferrer"&gt;
        dsh-plugin-agent-insights
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;dsh-plugin-agent-insights&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/dsh-plugin-agent-insights" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/5b2dbb7a0a7b12664db423b2e8ec1659001c19ce6ed71774cffdcbb3101dcade/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6473682d706c7567696e2d6167656e742d696e7369676874732e737667" alt="npm version"&gt;&lt;/a&gt;
&lt;a href="https://github.com/Claven07/dsh-plugin-agent-insights/./LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/03391623decd61a53598edefa59b7abb6797c2b886861dd62bb76c7e257631f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f436c6176656e30372f6473682d706c7567696e2d6167656e742d696e7369676874732e737667" alt="license"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Session-scoped observability metrics and performance tracking plugin for the DeepSeek Harness ecosystem.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;dsh-plugin-agent-insights&lt;/code&gt; provides lightweight, non-invasive, session-scoped observability and performance tracking for DeepSeek Harness agents. It registers as a Cordis service (&lt;code&gt;ctx.agentInsights&lt;/code&gt;) and automatically hooks into runtime dispatch pipelines to collect granular metrics without modifying any core packages or interfering with agent execution.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Key Capabilities&lt;/h3&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tool Execution Metrics&lt;/strong&gt;: Captures total tool calls, successful calls, failed calls, precise execution duration via &lt;code&gt;performance.now()&lt;/code&gt;, and identifies the slowest tool invocation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM &amp;amp; Agent Metrics&lt;/strong&gt;: Tracks total agent steps closed, total model requests dispatched, and failed model requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session Duration Metrics&lt;/strong&gt;: Records session start timestamps and total elapsed session duration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global Slowest Tool Tracking&lt;/strong&gt;: Tracks the single slowest tool invocation across all active sessions without retaining references to the sessions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Leak Memory Architecture&lt;/strong&gt;: Stores session statistics in a &lt;code&gt;WeakMap&amp;lt;Session, SessionAgentInsights&amp;gt;&lt;/code&gt;, preventing memory retention…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Claven07/dsh-plugin-agent-insights" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>deepseek</category>
      <category>ai</category>
      <category>opensource</category>
      <category>devtools</category>
    </item>
  </channel>
</rss>
