@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.12.5-dev.202609260125.8a6a403",
3
+ "version": "0.12.5-dev.202609261222.09a30ca",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -770,96 +770,83 @@ describe("session-agent-loop overflow recovery (JARVIS-110)", () => {
770
770
  });
771
771
 
772
772
  // ── Test 1 ────────────────────────────────────────────────────────
773
- // BUG: When the agent loop makes progress (adds messages to history)
774
- // before hitting context_too_large, the convergence loop's progress
775
- // check must recognize that the loop appended messages. If it fails to,
776
- // the reducer is never invoked — the error is surfaced immediately
777
- // without any compaction attempt.
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
- mockReducerStepFn = (msgs: Message[]) => {
788
- reducerCalled = true;
789
- return {
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
- tier: "forced_compaction",
792
- state: {
793
- appliedTiers: ["forced_compaction"],
794
- injectionMode: "full",
795
- exhausted: false,
796
- },
797
- estimatedTokens: 50_000,
798
- compactionResult: {
799
- compacted: true,
800
- messages: msgs,
801
- compactedPersistedMessages: 5,
802
- summaryText: "Summary",
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
- // Run 1 makes progress (a tool turn) then the following provider call
817
- // rejects with a context_too_large error; after the convergence reducer
818
- // compacts, the rerun recovers with plain text.
819
- const { provider } = createMockProvider([
820
- toolUseResponse("tu-progress", "bash", { command: "ls" }),
821
- new Error("prompt is too long: 242201 tokens > 200000 maximum"),
822
- textResponse("recovered after compaction"),
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
- const ctx = makeCtx({
826
- loopProvider: provider,
827
- loopTools: [
828
- {
829
- name: "bash",
830
- description: "Run a shell command",
831
- input_schema: {
832
- type: "object",
833
- properties: { command: { type: "string" } },
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
- toolExecutor: async () => ({
838
- content: "file1.ts\nfile2.ts",
839
- isError: false,
840
- }),
841
- contextWindowManager: {
842
- updateConfig: () => {},
843
- shouldCompact: () => ({ needed: false, estimatedTokens: 0 }),
844
- maybeCompact: async () => ({ compacted: false }),
845
- } as unknown as Conversation["contextWindowManager"],
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
- await runAgentLoopImpl(ctx, "hello", "msg-1", (msg) => events.push(msg));
841
+ await runAgentLoopImpl(ctx, "hello", "msg-1", (msg) => events.push(msg));
849
842
 
850
- // BUG: Currently the reducer is NOT called when progress was made before
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
- // BUG: Currently a conversation_error IS emitted instead of retrying.
856
- // After PR 2 fix, there should be no conversation_error.
857
- const conversationError = events.find(
858
- (e) => e.type === "conversation_error",
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