@vellumai/assistant 0.12.5-dev.202609260125.8a6a403 → 0.12.5-dev.202609261222.09a30ca
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/package.json
CHANGED
|
@@ -770,96 +770,83 @@ describe("session-agent-loop overflow recovery (JARVIS-110)", () => {
|
|
|
770
770
|
});
|
|
771
771
|
|
|
772
772
|
// ── Test 1 ────────────────────────────────────────────────────────
|
|
773
|
-
//
|
|
774
|
-
// before hitting context_too_large
|
|
775
|
-
//
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
// Expected behavior (PR 2 fix): After progress + context_too_large,
|
|
780
|
-
// the system should still attempt compaction before surfacing error.
|
|
781
|
-
test.todo(
|
|
782
|
-
"context too large after progress triggers compaction retry instead of immediate failure",
|
|
783
|
-
async () => {
|
|
784
|
-
const events: AssistantEvent[] = [];
|
|
785
|
-
let reducerCalled = false;
|
|
773
|
+
// Verifies overflow recovery fires even when the agent made tool-use progress
|
|
774
|
+
// before hitting context_too_large. The convergence path must not skip
|
|
775
|
+
// compaction just because messages were appended earlier in the turn.
|
|
776
|
+
test("context too large after progress triggers compaction retry instead of immediate failure", async () => {
|
|
777
|
+
const events: AssistantEvent[] = [];
|
|
778
|
+
let reducerCalled = false;
|
|
786
779
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
780
|
+
mockReducerStepFn = (msgs: Message[]) => {
|
|
781
|
+
reducerCalled = true;
|
|
782
|
+
return {
|
|
783
|
+
messages: msgs,
|
|
784
|
+
tier: "forced_compaction",
|
|
785
|
+
state: {
|
|
786
|
+
appliedTiers: ["forced_compaction"],
|
|
787
|
+
injectionMode: "full",
|
|
788
|
+
exhausted: false,
|
|
789
|
+
},
|
|
790
|
+
estimatedTokens: 50_000,
|
|
791
|
+
compactionResult: {
|
|
792
|
+
compacted: true,
|
|
790
793
|
messages: msgs,
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
previousEstimatedInputTokens: 190_000,
|
|
804
|
-
estimatedInputTokens: 50_000,
|
|
805
|
-
maxInputTokens: 200_000,
|
|
806
|
-
thresholdTokens: 160_000,
|
|
807
|
-
compactedMessages: 10,
|
|
808
|
-
summaryCalls: 1,
|
|
809
|
-
summaryInputTokens: 500,
|
|
810
|
-
summaryOutputTokens: 200,
|
|
811
|
-
summaryModel: "mock-model",
|
|
812
|
-
},
|
|
813
|
-
};
|
|
794
|
+
compactedPersistedMessages: 5,
|
|
795
|
+
summaryText: "Summary",
|
|
796
|
+
previousEstimatedInputTokens: 190_000,
|
|
797
|
+
estimatedInputTokens: 50_000,
|
|
798
|
+
maxInputTokens: 200_000,
|
|
799
|
+
thresholdTokens: 160_000,
|
|
800
|
+
compactedMessages: 10,
|
|
801
|
+
summaryCalls: 1,
|
|
802
|
+
summaryInputTokens: 500,
|
|
803
|
+
summaryOutputTokens: 200,
|
|
804
|
+
summaryModel: "mock-model",
|
|
805
|
+
},
|
|
814
806
|
};
|
|
807
|
+
};
|
|
815
808
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
809
|
+
// Run 1 makes progress (a tool turn) then the following provider call
|
|
810
|
+
// rejects with a context_too_large error; after the convergence reducer
|
|
811
|
+
// compacts, the rerun recovers with plain text.
|
|
812
|
+
const { provider } = createMockProvider([
|
|
813
|
+
toolUseResponse("tu-progress", "bash", { command: "ls" }),
|
|
814
|
+
new Error("prompt is too long: 242201 tokens > 200000 maximum"),
|
|
815
|
+
textResponse("recovered after compaction"),
|
|
816
|
+
]);
|
|
824
817
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
},
|
|
818
|
+
const ctx = makeCtx({
|
|
819
|
+
loopProvider: provider,
|
|
820
|
+
loopTools: [
|
|
821
|
+
{
|
|
822
|
+
name: "bash",
|
|
823
|
+
description: "Run a shell command",
|
|
824
|
+
input_schema: {
|
|
825
|
+
type: "object",
|
|
826
|
+
properties: { command: { type: "string" } },
|
|
835
827
|
},
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
}
|
|
828
|
+
},
|
|
829
|
+
],
|
|
830
|
+
toolExecutor: async () => ({
|
|
831
|
+
content: "file1.ts\nfile2.ts",
|
|
832
|
+
isError: false,
|
|
833
|
+
}),
|
|
834
|
+
contextWindowManager: {
|
|
835
|
+
updateConfig: () => {},
|
|
836
|
+
shouldCompact: () => ({ needed: false, estimatedTokens: 0 }),
|
|
837
|
+
maybeCompact: async () => ({ compacted: false }),
|
|
838
|
+
} as unknown as Conversation["contextWindowManager"],
|
|
839
|
+
});
|
|
847
840
|
|
|
848
|
-
|
|
841
|
+
await runAgentLoopImpl(ctx, "hello", "msg-1", (msg) => events.push(msg));
|
|
849
842
|
|
|
850
|
-
|
|
851
|
-
// context_too_large. The error is surfaced immediately.
|
|
852
|
-
// After PR 2 fix, the reducer SHOULD be called to attempt compaction.
|
|
853
|
-
expect(reducerCalled).toBe(true);
|
|
843
|
+
expect(reducerCalled).toBe(true);
|
|
854
844
|
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
expect(conversationError).toBeUndefined();
|
|
861
|
-
},
|
|
862
|
-
);
|
|
845
|
+
const conversationError = events.find(
|
|
846
|
+
(e) => e.type === "conversation_error",
|
|
847
|
+
);
|
|
848
|
+
expect(conversationError).toBeUndefined();
|
|
849
|
+
});
|
|
863
850
|
|
|
864
851
|
// ── Test 2 ────────────────────────────────────────────────────────
|
|
865
852
|
// When estimation says we're within budget but the provider rejects, the
|