@poncho-ai/harness 0.61.1 → 0.61.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @poncho-ai/harness@0.61.1 build /home/runner/work/poncho-ai/poncho-ai/packages/harness
2
+ > @poncho-ai/harness@0.61.2 build /home/runner/work/poncho-ai/poncho-ai/packages/harness
3
3
  > node scripts/embed-docs.js && tsup src/index.ts --format esm --dts
4
4
 
5
5
  [embed-docs] Generated poncho-docs.ts with 4 topics
@@ -8,9 +8,9 @@
8
8
  CLI tsup v8.5.1
9
9
  CLI Target: es2022
10
10
  ESM Build start
11
- ESM dist/index.js 580.50 KB
11
+ ESM dist/index.js 581.91 KB
12
12
  ESM dist/isolate-F2PPSUL6.js 53.82 KB
13
- ESM ⚡️ Build success in 227ms
13
+ ESM ⚡️ Build success in 239ms
14
14
  DTS Build start
15
- DTS ⚡️ Build success in 7778ms
15
+ DTS ⚡️ Build success in 7703ms
16
16
  DTS dist/index.d.ts 110.56 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @poncho-ai/harness
2
2
 
3
+ ## 0.61.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c881cd2`](https://github.com/cesr/poncho-ai/commit/c881cd2cafd4cb70f9614601dd233aafac334b8c) Thanks [@cesr](https://github.com/cesr)! - Telemetry: make context compaction observable and tag subagent runs.
8
+ - When auto-compaction fires mid-run, stamp the active `invoke_agent` span with
9
+ `poncho.compaction.occurred` / `tokens_before` / `tokens_after` /
10
+ `context_window` / `trigger`. Compaction rewrites the message prefix — which
11
+ wipes the per-model prompt cache and forces the next turn to re-create a large
12
+ cached span cold — so "which turns compacted, and what did that cost" was
13
+ previously invisible at the span level. No-op when telemetry is suppressed
14
+ (no active span).
15
+ - Subagent runs spawned by the orchestrator now carry
16
+ `telemetryAttributes` (`poncho.run.kind: "subagent"`, `latitude.tags`,
17
+ and a `latitude.metadata` link to the parent conversation) so subagent spend
18
+ segments out of the parent chat/job on the trace instead of being
19
+ indistinguishable from it.
20
+
3
21
  ## 0.61.1
4
22
 
5
23
  ### Patch Changes
package/dist/index.js CHANGED
@@ -11461,6 +11461,13 @@ ${textContent}` };
11461
11461
  const tokensAfterCompaction = estimateTotalTokens(systemPrompt, messages, toolDefsJsonForEstimate);
11462
11462
  latestContextTokens = tokensAfterCompaction;
11463
11463
  toolOutputEstimateSinceModel = 0;
11464
+ trace.getActiveSpan()?.setAttributes({
11465
+ "poncho.compaction.occurred": true,
11466
+ "poncho.compaction.tokens_before": effectiveTokens,
11467
+ "poncho.compaction.tokens_after": tokensAfterCompaction,
11468
+ "poncho.compaction.context_window": contextWindow,
11469
+ "poncho.compaction.trigger": compactionConfig.trigger
11470
+ });
11464
11471
  yield pushEvent({
11465
11472
  type: "compaction:completed",
11466
11473
  tokensBefore: effectiveTokens,
@@ -13707,7 +13714,17 @@ var AgentOrchestrator = class {
13707
13714
  messages: harnessMessages,
13708
13715
  abortSignal: childAbortController.signal,
13709
13716
  // Inherit the parent run's telemetry choice (e.g. incognito).
13710
- suppressTelemetry: conversation.subagentMeta?.suppressTelemetry
13717
+ suppressTelemetry: conversation.subagentMeta?.suppressTelemetry,
13718
+ // Distinguish subagent turns from the parent chat/job on the trace:
13719
+ // `poncho.run.kind` is the queryable attribute PonchOS already sets on
13720
+ // foreground/job runs, and `latitude.tags` (JSON-array string) is what
13721
+ // Latitude reads into its filterable tags field, so subagent spend can
13722
+ // be segmented out. `latitude.metadata` links back to the parent.
13723
+ telemetryAttributes: {
13724
+ "poncho.run.kind": "subagent",
13725
+ "latitude.tags": '["subagent"]',
13726
+ ...conversation.parentConversationId ? { "latitude.metadata": JSON.stringify({ parentConversationId: conversation.parentConversationId }) } : {}
13727
+ }
13711
13728
  })) {
13712
13729
  if (event.type === "run:started") {
13713
13730
  latestRunId = event.runId;
@@ -14200,7 +14217,14 @@ ${resultBody}`,
14200
14217
  messages: continuationMessages,
14201
14218
  abortSignal: childAbortController.signal,
14202
14219
  // Inherit the parent run's telemetry choice (e.g. incognito).
14203
- suppressTelemetry: conversation.subagentMeta?.suppressTelemetry
14220
+ suppressTelemetry: conversation.subagentMeta?.suppressTelemetry,
14221
+ // Tag the subagent continuation the same way as the initial run (see
14222
+ // the fan-out call above) so its spend segments out of the parent's.
14223
+ telemetryAttributes: {
14224
+ "poncho.run.kind": "subagent",
14225
+ "latitude.tags": '["subagent"]',
14226
+ "latitude.metadata": JSON.stringify({ parentConversationId })
14227
+ }
14204
14228
  })) {
14205
14229
  if (event.type === "run:started") {
14206
14230
  const active = this.activeConversationRuns.get(conversationId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poncho-ai/harness",
3
- "version": "0.61.1",
3
+ "version": "0.61.2",
4
4
  "description": "Agent execution runtime - conversation loop, tool dispatch, streaming",
5
5
  "repository": {
6
6
  "type": "git",
package/src/harness.ts CHANGED
@@ -3115,6 +3115,21 @@ Code is wrapped in an async IIFE — use \`return\` to return a value to the too
3115
3115
  const tokensAfterCompaction = estimateTotalTokens(systemPrompt, messages, toolDefsJsonForEstimate);
3116
3116
  latestContextTokens = tokensAfterCompaction;
3117
3117
  toolOutputEstimateSinceModel = 0;
3118
+ // Stamp the compaction onto the active OTel span (the invoke_agent
3119
+ // root, active here because run() executes inside its context) so
3120
+ // observability backends can find compacted turns and measure the
3121
+ // cost they cause — a compaction rewrites the message prefix, which
3122
+ // wipes the per-model prompt cache and forces the next turn to
3123
+ // re-create a large cached span cold. Without this, "which turns
3124
+ // compacted, and what did it cost" is invisible at the span level.
3125
+ // No-op when telemetry is off (no active span).
3126
+ trace.getActiveSpan()?.setAttributes({
3127
+ "poncho.compaction.occurred": true,
3128
+ "poncho.compaction.tokens_before": effectiveTokens,
3129
+ "poncho.compaction.tokens_after": tokensAfterCompaction,
3130
+ "poncho.compaction.context_window": contextWindow,
3131
+ "poncho.compaction.trigger": compactionConfig.trigger,
3132
+ });
3118
3133
  yield pushEvent({
3119
3134
  type: "compaction:completed",
3120
3135
  tokensBefore: effectiveTokens,
@@ -862,6 +862,18 @@ export class AgentOrchestrator {
862
862
  abortSignal: childAbortController.signal,
863
863
  // Inherit the parent run's telemetry choice (e.g. incognito).
864
864
  suppressTelemetry: conversation.subagentMeta?.suppressTelemetry,
865
+ // Distinguish subagent turns from the parent chat/job on the trace:
866
+ // `poncho.run.kind` is the queryable attribute PonchOS already sets on
867
+ // foreground/job runs, and `latitude.tags` (JSON-array string) is what
868
+ // Latitude reads into its filterable tags field, so subagent spend can
869
+ // be segmented out. `latitude.metadata` links back to the parent.
870
+ telemetryAttributes: {
871
+ "poncho.run.kind": "subagent",
872
+ "latitude.tags": "[\"subagent\"]",
873
+ ...(conversation.parentConversationId
874
+ ? { "latitude.metadata": JSON.stringify({ parentConversationId: conversation.parentConversationId }) }
875
+ : {}),
876
+ },
865
877
  })) {
866
878
  if (event.type === "run:started") {
867
879
  latestRunId = event.runId;
@@ -1452,6 +1464,13 @@ export class AgentOrchestrator {
1452
1464
  abortSignal: childAbortController.signal,
1453
1465
  // Inherit the parent run's telemetry choice (e.g. incognito).
1454
1466
  suppressTelemetry: conversation.subagentMeta?.suppressTelemetry,
1467
+ // Tag the subagent continuation the same way as the initial run (see
1468
+ // the fan-out call above) so its spend segments out of the parent's.
1469
+ telemetryAttributes: {
1470
+ "poncho.run.kind": "subagent",
1471
+ "latitude.tags": "[\"subagent\"]",
1472
+ "latitude.metadata": JSON.stringify({ parentConversationId }),
1473
+ },
1455
1474
  })) {
1456
1475
  if (event.type === "run:started") {
1457
1476
  const active = this.activeConversationRuns.get(conversationId);