open-agents-ai 0.187.237 → 0.187.238
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.
- package/dist/index.js +60 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -270794,6 +270794,32 @@ ${memoryLines.join("\n")}`
|
|
|
270794
270794
|
maxTokens: effectiveMaxTokens,
|
|
270795
270795
|
timeoutMs: this.options.requestTimeoutMs
|
|
270796
270796
|
};
|
|
270797
|
+
{
|
|
270798
|
+
const ctxChars = compacted.reduce((s2, m2) => {
|
|
270799
|
+
let c7 = typeof m2.content === "string" ? m2.content.length : 100;
|
|
270800
|
+
if (m2.tool_calls)
|
|
270801
|
+
for (const tc of m2.tool_calls)
|
|
270802
|
+
c7 += tc.function.arguments?.length ?? 0;
|
|
270803
|
+
return s2 + c7;
|
|
270804
|
+
}, 0);
|
|
270805
|
+
const estTokens = Math.ceil(ctxChars / 4);
|
|
270806
|
+
const limits = this.contextLimits();
|
|
270807
|
+
this.emit({
|
|
270808
|
+
type: "debug_context",
|
|
270809
|
+
content: `Turn ${turn}: ${compacted.length} msgs, ~${estTokens} tokens (threshold: ${limits.compactionThreshold}), headroom: ${limits.compactionThreshold - estTokens}`,
|
|
270810
|
+
turn,
|
|
270811
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
270812
|
+
contextSnapshot: {
|
|
270813
|
+
messageCount: compacted.length,
|
|
270814
|
+
estimatedTokens: estTokens,
|
|
270815
|
+
compactionThreshold: limits.compactionThreshold,
|
|
270816
|
+
toolCallCount,
|
|
270817
|
+
keepRecent: limits.keepRecent,
|
|
270818
|
+
littlemanOutcomes: this._littlemanToolOutcomes.length,
|
|
270819
|
+
headroom: limits.compactionThreshold - estTokens
|
|
270820
|
+
}
|
|
270821
|
+
});
|
|
270822
|
+
}
|
|
270797
270823
|
let response;
|
|
270798
270824
|
try {
|
|
270799
270825
|
response = this.options.streamEnabled && this.hasStreamingSupport() ? await this.streamingRequest(chatRequest, turn) : await this.backend.chatCompletion(chatRequest);
|
|
@@ -272975,6 +273001,20 @@ Do NOT re-run it. Use the result you already have and proceed to the next step.`
|
|
|
272975
273001
|
break;
|
|
272976
273002
|
}
|
|
272977
273003
|
}
|
|
273004
|
+
const succCount = this._littlemanToolOutcomes.filter((o2) => o2.succeeded).length;
|
|
273005
|
+
const failCount = this._littlemanToolOutcomes.filter((o2) => !o2.succeeded).length;
|
|
273006
|
+
this.emit({
|
|
273007
|
+
type: "debug_littleman",
|
|
273008
|
+
turn,
|
|
273009
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
273010
|
+
content: `Littleman: ${this._littlemanToolOutcomes.length} tracked outcomes (${succCount} ok, ${failCount} err)`,
|
|
273011
|
+
littlemanAction: {
|
|
273012
|
+
detection: "none",
|
|
273013
|
+
recentSuccesses: succCount,
|
|
273014
|
+
recentFailures: failCount,
|
|
273015
|
+
intervention: this.pendingUserMessages.length > 0 ? this.pendingUserMessages[this.pendingUserMessages.length - 1]?.slice(0, 120) ?? null : null
|
|
273016
|
+
}
|
|
273017
|
+
});
|
|
272978
273018
|
}
|
|
272979
273019
|
/**
|
|
272980
273020
|
* Infer what the model should do next from the most recent messages.
|
|
@@ -328589,6 +328629,26 @@ ${entry.fullContent}`
|
|
|
328589
328629
|
break;
|
|
328590
328630
|
case "complete":
|
|
328591
328631
|
break;
|
|
328632
|
+
// -- Live observability hooks --
|
|
328633
|
+
case "debug_context":
|
|
328634
|
+
if (config.verbose) {
|
|
328635
|
+
const snap = event.contextSnapshot;
|
|
328636
|
+
if (snap) {
|
|
328637
|
+
contentWrite(() => renderInfo(
|
|
328638
|
+
`\x1B[38;5;243m[ctx] ${snap.messageCount} msgs | ~${snap.estimatedTokens} tok | headroom: ${snap.headroom} | tools: ${snap.toolCallCount} | littleman: ${snap.littlemanOutcomes} tracked\x1B[0m`
|
|
328639
|
+
));
|
|
328640
|
+
}
|
|
328641
|
+
}
|
|
328642
|
+
break;
|
|
328643
|
+
case "debug_littleman":
|
|
328644
|
+
if (config.verbose && event.littlemanAction) {
|
|
328645
|
+
const lm = event.littlemanAction;
|
|
328646
|
+
const intervention = lm.intervention ? ` | INTERVENTION: ${lm.intervention}` : "";
|
|
328647
|
+
contentWrite(() => renderInfo(
|
|
328648
|
+
`\x1B[38;5;178m[littleman] ${lm.recentSuccesses} ok, ${lm.recentFailures} err${intervention}\x1B[0m`
|
|
328649
|
+
));
|
|
328650
|
+
}
|
|
328651
|
+
break;
|
|
328592
328652
|
}
|
|
328593
328653
|
});
|
|
328594
328654
|
const sessionId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
package/package.json
CHANGED