@project-ava-supernova/core 0.2.115 → 0.2.117
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/agent/agent.d.ts +26 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +78 -3
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/claims-auditor.d.ts +24 -0
- package/dist/agent/claims-auditor.d.ts.map +1 -1
- package/dist/agent/claims-auditor.js +49 -0
- package/dist/agent/claims-auditor.js.map +1 -1
- package/dist/learning/course-check.d.ts +14 -0
- package/dist/learning/course-check.d.ts.map +1 -1
- package/dist/learning/course-check.js +16 -0
- package/dist/learning/course-check.js.map +1 -1
- package/dist/learning/course-store.d.ts +17 -0
- package/dist/learning/course-store.d.ts.map +1 -1
- package/dist/tools/course-tools.d.ts.map +1 -1
- package/dist/tools/course-tools.js +30 -3
- package/dist/tools/course-tools.js.map +1 -1
- package/package.json +1 -1
package/dist/agent/agent.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ export type AgentEvent = {
|
|
|
125
125
|
| {
|
|
126
126
|
type: 'response_truncated';
|
|
127
127
|
hadToolCall: boolean;
|
|
128
|
+
roomChars?: number;
|
|
128
129
|
} | {
|
|
129
130
|
type: 'interjection';
|
|
130
131
|
content: string;
|
|
@@ -222,6 +223,14 @@ export declare class Agent {
|
|
|
222
223
|
private readonly pendingInterjections;
|
|
223
224
|
private pauseRequested;
|
|
224
225
|
private runToolEvidence;
|
|
226
|
+
/**
|
|
227
|
+
* What the tools RETURNED this run, for the honesty gate's identifier
|
|
228
|
+
* check. Capped per result and in total: this exists to answer "did any
|
|
229
|
+
* tool ever mention this id", which needs the text but not all of it.
|
|
230
|
+
*/
|
|
231
|
+
private runToolOutput;
|
|
232
|
+
/** What the caller said this turn, as backing for identifiers they supplied. */
|
|
233
|
+
private runUserText;
|
|
225
234
|
/**
|
|
226
235
|
* The id of the turn currently running — one per run(), shared by every
|
|
227
236
|
* model call the turn makes, sent to our platform as X-Ava-Turn-Id.
|
|
@@ -467,6 +476,23 @@ export declare class Agent {
|
|
|
467
476
|
* there at all. Two locks, because we already broke this promise once by
|
|
468
477
|
* assuming one implicit one was enough.
|
|
469
478
|
*/
|
|
479
|
+
/**
|
|
480
|
+
* How much output to ask for, given what the input already costs.
|
|
481
|
+
*
|
|
482
|
+
* A model's output ceiling and its context window are not independent: the
|
|
483
|
+
* reply has to fit in what the prompt leaves behind. Asking for the full
|
|
484
|
+
* ceiling on a nearly-full window does not get it — the provider trims the
|
|
485
|
+
* answer to fit, mid-sentence and mid-tool-call, and reports nothing.
|
|
486
|
+
*
|
|
487
|
+
* Asking for the honest number instead means `finish_reason: length` fires
|
|
488
|
+
* where it should, our own truncation handling runs, and the remaining room
|
|
489
|
+
* can be SAID rather than discovered by bisection.
|
|
490
|
+
*/
|
|
491
|
+
private outputBudget;
|
|
492
|
+
/** The last budget asked for, so a cut-off can say how much room was left. */
|
|
493
|
+
private lastOutputBudget;
|
|
494
|
+
/** That budget in characters, which is the unit the caller actually thinks in. */
|
|
495
|
+
private get lastOutputBudgetChars();
|
|
470
496
|
private detectModeForSurface;
|
|
471
497
|
run(messages: Message[], onEvent: AgentEventHandler, signal?: AbortSignal): Promise<Message[]>;
|
|
472
498
|
private runInner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAqC,MAAM,uBAAuB,CAAC;AAEzF,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA6BhD,OAAO,KAAK,EAAE,UAAU,EAAW,MAAM,sB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C;IAmQrB,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAMjC,OAAO,CAAC,qBAAqB;IA4B7B,8DAA8D;IAC9D,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM;IAM/C;;;;OAIG;IACH;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,kBAAkB;IAyE1B,OAAO,CAAC,gBAAgB;IAyDxB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,OAAO,CAAC,4BAA4B;IA0DpC;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,iBAAiB;IA8DzB;;;;;;;OAOG;IACH,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE;IAI9C;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAoDvB"}
|
package/dist/agent/agent.js
CHANGED
|
@@ -779,6 +779,14 @@ export class Agent {
|
|
|
779
779
|
// Verifying tools that ran this run() (name + success), for the soft
|
|
780
780
|
// honesty gate (claims-auditor) at final-answer time. Reset per run.
|
|
781
781
|
runToolEvidence = [];
|
|
782
|
+
/**
|
|
783
|
+
* What the tools RETURNED this run, for the honesty gate's identifier
|
|
784
|
+
* check. Capped per result and in total: this exists to answer "did any
|
|
785
|
+
* tool ever mention this id", which needs the text but not all of it.
|
|
786
|
+
*/
|
|
787
|
+
runToolOutput = [];
|
|
788
|
+
/** What the caller said this turn, as backing for identifiers they supplied. */
|
|
789
|
+
runUserText = '';
|
|
782
790
|
/**
|
|
783
791
|
* The id of the turn currently running — one per run(), shared by every
|
|
784
792
|
* model call the turn makes, sent to our platform as X-Ava-Turn-Id.
|
|
@@ -1067,6 +1075,38 @@ export class Agent {
|
|
|
1067
1075
|
* there at all. Two locks, because we already broke this promise once by
|
|
1068
1076
|
* assuming one implicit one was enough.
|
|
1069
1077
|
*/
|
|
1078
|
+
/**
|
|
1079
|
+
* How much output to ask for, given what the input already costs.
|
|
1080
|
+
*
|
|
1081
|
+
* A model's output ceiling and its context window are not independent: the
|
|
1082
|
+
* reply has to fit in what the prompt leaves behind. Asking for the full
|
|
1083
|
+
* ceiling on a nearly-full window does not get it — the provider trims the
|
|
1084
|
+
* answer to fit, mid-sentence and mid-tool-call, and reports nothing.
|
|
1085
|
+
*
|
|
1086
|
+
* Asking for the honest number instead means `finish_reason: length` fires
|
|
1087
|
+
* where it should, our own truncation handling runs, and the remaining room
|
|
1088
|
+
* can be SAID rather than discovered by bisection.
|
|
1089
|
+
*/
|
|
1090
|
+
outputBudget(messages) {
|
|
1091
|
+
const ceiling = this.model.maxOutputTokens ?? 32_768;
|
|
1092
|
+
// The estimate is approximate and erring high costs a truncation, so keep
|
|
1093
|
+
// a margin under the window rather than racing it to the byte.
|
|
1094
|
+
const MARGIN_TOKENS = 4_000;
|
|
1095
|
+
const FLOOR_TOKENS = 1_024;
|
|
1096
|
+
const room = this.model.contextWindow - this.estimateTokenCount(messages) - MARGIN_TOKENS;
|
|
1097
|
+
const budget = Math.max(FLOOR_TOKENS, Math.min(ceiling, room));
|
|
1098
|
+
this.lastOutputBudget = budget;
|
|
1099
|
+
if (budget < ceiling) {
|
|
1100
|
+
logger.debug(`[agent] output budget ${budget} (ceiling ${ceiling}, window ${this.model.contextWindow}) — context is filling`);
|
|
1101
|
+
}
|
|
1102
|
+
return budget;
|
|
1103
|
+
}
|
|
1104
|
+
/** The last budget asked for, so a cut-off can say how much room was left. */
|
|
1105
|
+
lastOutputBudget = null;
|
|
1106
|
+
/** That budget in characters, which is the unit the caller actually thinks in. */
|
|
1107
|
+
get lastOutputBudgetChars() {
|
|
1108
|
+
return this.lastOutputBudget === null ? null : this.lastOutputBudget * 4;
|
|
1109
|
+
}
|
|
1070
1110
|
detectModeForSurface(messages) {
|
|
1071
1111
|
// What the caller declared beats what the text looks like. A surface that
|
|
1072
1112
|
// opened a room knows the answer; the tag is a fallback for the ones that
|
|
@@ -1094,6 +1134,16 @@ export class Agent {
|
|
|
1094
1134
|
this.runTurnId = randomUUID();
|
|
1095
1135
|
// Reset per-run tool evidence for the honesty gate (claims-auditor).
|
|
1096
1136
|
this.runToolEvidence = [];
|
|
1137
|
+
this.runToolOutput = [];
|
|
1138
|
+
// The caller's own words this turn. An id they SUPPLIED is not one she
|
|
1139
|
+
// invented, so the gate treats it as backing — flagging a brief's own
|
|
1140
|
+
// seed id would teach everyone to ignore the warning. Recent turns only:
|
|
1141
|
+
// an id remembered from six turns ago is exactly what is worth catching.
|
|
1142
|
+
this.runUserText = messages
|
|
1143
|
+
.filter((m) => m.role === 'user')
|
|
1144
|
+
.slice(-3)
|
|
1145
|
+
.map((m) => (typeof m.content === 'string' ? m.content : ''))
|
|
1146
|
+
.join('\n');
|
|
1097
1147
|
this.runClaimFlagged = false;
|
|
1098
1148
|
this.lastAudit = null;
|
|
1099
1149
|
this.honestyVerifyAttempted = false;
|
|
@@ -1860,7 +1910,15 @@ export class Agent {
|
|
|
1860
1910
|
// before it, looking exactly like she had decided to stop. Capped at
|
|
1861
1911
|
// 32K so one reply cannot eat a 1M-context window, and never more
|
|
1862
1912
|
// than the model can actually produce.
|
|
1863
|
-
|
|
1913
|
+
//
|
|
1914
|
+
// 26 Sep 2026: asking for the model's full ceiling regardless of how
|
|
1915
|
+
// much context was already spent is how a session silently strangles
|
|
1916
|
+
// itself. The provider quietly caps the reply to whatever room is
|
|
1917
|
+
// left, we never adjust, and nothing says so — so the same course was
|
|
1918
|
+
// sent sixteen times and guillotined at a different, invisible point
|
|
1919
|
+
// each time: 49k, 32k, 18k, 11k, 6k, 1.6k. From the inside that looks
|
|
1920
|
+
// like the tool breaking at random. It is arithmetic.
|
|
1921
|
+
max_tokens: this.outputBudget(messages),
|
|
1864
1922
|
// Every iteration of this loop is another call serving the SAME user
|
|
1865
1923
|
// turn. Tagging them all with one id is what lets a turn be costed as
|
|
1866
1924
|
// an outcome rather than as N unrelated calls.
|
|
@@ -1909,6 +1967,12 @@ export class Agent {
|
|
|
1909
1967
|
{
|
|
1910
1968
|
role: 'user',
|
|
1911
1969
|
content: 'Your reply was cut off at the output limit — it stopped mid-sentence and no tool call arrived, so nothing ran. '
|
|
1970
|
+
+ (this.lastOutputBudgetChars !== null
|
|
1971
|
+
// The number, not the advice, is what stops the bisecting. A
|
|
1972
|
+
// caller told only "make it smaller" halves blindly; a caller
|
|
1973
|
+
// told the actual room sizes the next call once and correctly.
|
|
1974
|
+
? `You have roughly ${this.lastOutputBudgetChars.toLocaleString()} characters of output room left in this session, and it SHRINKS as the conversation grows — so this will keep happening and getting worse, not better. Size the next call to fit inside that, with room to spare. `
|
|
1975
|
+
: '')
|
|
1912
1976
|
+ 'Continue from where you stopped, and make the next piece smaller: one lesson, one module, one tool call at a time. '
|
|
1913
1977
|
+ 'Do not repeat what you already wrote above.',
|
|
1914
1978
|
},
|
|
@@ -2771,7 +2835,12 @@ export class Agent {
|
|
|
2771
2835
|
// verifying tool this run, and append a visible caveat so the unverified
|
|
2772
2836
|
// claim doesn't stand as fact. Soft by design — annotates, never blocks.
|
|
2773
2837
|
if (toolCalls.length === 0 && typeof finalContent === 'string' && finalContent.trim()) {
|
|
2774
|
-
const audit = auditClaims({
|
|
2838
|
+
const audit = auditClaims({
|
|
2839
|
+
text: finalContent,
|
|
2840
|
+
toolsUsed: this.runToolEvidence,
|
|
2841
|
+
toolOutput: this.runToolOutput.join('\n'),
|
|
2842
|
+
userText: this.runUserText,
|
|
2843
|
+
});
|
|
2775
2844
|
this.lastAudit = audit;
|
|
2776
2845
|
if (audit.flagged) {
|
|
2777
2846
|
// Record for the verification_evidence dataset event (shape-only:
|
|
@@ -2829,7 +2898,7 @@ export class Agent {
|
|
|
2829
2898
|
if (finishReason === 'length') {
|
|
2830
2899
|
const hadToolCall = (message.tool_calls?.length ?? 0) > 0;
|
|
2831
2900
|
logger.warn(`[agent] response TRUNCATED at the output limit (model=${this.model.id}, max_tokens=${request.max_tokens ?? 'provider default'}, completion=${usage?.completion_tokens ?? '?'}, tool_calls=${message.tool_calls?.length ?? 0})`);
|
|
2832
|
-
onEvent({ type: 'response_truncated', hadToolCall });
|
|
2901
|
+
onEvent({ type: 'response_truncated', hadToolCall, ...(this.lastOutputBudgetChars !== null ? { roomChars: this.lastOutputBudgetChars } : {}) });
|
|
2833
2902
|
}
|
|
2834
2903
|
return {
|
|
2835
2904
|
message,
|
|
@@ -2900,6 +2969,12 @@ export class Agent {
|
|
|
2900
2969
|
});
|
|
2901
2970
|
// Record for the soft honesty gate: did a verifying tool succeed this run?
|
|
2902
2971
|
this.runToolEvidence.push({ name: toolName, ok: result.success });
|
|
2972
|
+
// And WHAT it said, so an identifier in the final report can be checked
|
|
2973
|
+
// against something rather than taken on trust. Bounded hard — a long
|
|
2974
|
+
// course body would otherwise carry the whole library into memory.
|
|
2975
|
+
if (this.runToolOutput.length < 400) {
|
|
2976
|
+
this.runToolOutput.push(result.output.slice(0, 8_000));
|
|
2977
|
+
}
|
|
2903
2978
|
// ── Tool-error + guidance emits ─────────────────────────────────────
|
|
2904
2979
|
// On failure, emit tool_error with the matched pattern key (if any),
|
|
2905
2980
|
// followed by error_guidance_applied if the pattern library produced
|