@illuma-ai/agents 1.0.96 → 1.0.98

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.
@@ -596,30 +596,38 @@ describe('Pre-invocation utilization gate', () => {
596
596
  expect(emergency.length).toBeLessThan(2000); // Emergency summaries are compact
597
597
  });
598
598
 
599
- it('injects delegation hint at >70% utilization for agents with task tool', () => {
600
- const utilization = 75;
601
- const hasTaskTool = true;
602
-
603
- if (utilization > 70 && hasTaskTool) {
604
- const delegationHint = new HumanMessage({
605
- content:
606
- '[System] Context window is at 75% capacity. Consider delegating complex sub-tasks ' +
607
- 'to the task tool to maintain context availability.',
608
- });
609
- expect(delegationHint.content).toContain('75%');
610
- expect(delegationHint.content).toContain('task tool');
599
+ it('does NOT inject token budget hints at any utilization level', () => {
600
+ // Token budget hints were removed to prevent LLM voluntary bail-out.
601
+ // Context overflow is handled mechanically by pruning + auto-continuation.
602
+ // See: docs/context-overflow-architecture.md
603
+ const utilizationLevels = [50, 70, 85, 95, 101];
604
+ for (const utilization of utilizationLevels) {
605
+ const messages = buildConversation(10, 200);
606
+ // No message should contain raw token numbers or budget percentages
607
+ for (const msg of messages) {
608
+ const content =
609
+ typeof msg.content === 'string'
610
+ ? msg.content
611
+ : JSON.stringify(msg.content);
612
+ expect(content).not.toMatch(/CONTEXT BUDGET/);
613
+ expect(content).not.toMatch(/\d+ of \d+ tokens/);
614
+ }
611
615
  }
612
616
  });
613
617
 
614
- it('does not inject delegation hint below 70%', () => {
615
- const utilization = 65;
616
- let delegationInjected = false;
617
-
618
- if (utilization > 70) {
619
- delegationInjected = true;
618
+ it('post-prune note does not contain token numbers', () => {
619
+ // After pruning, a context note is injected but it must not
620
+ // expose any token counts or budget percentages to the LLM
621
+ const { buildPostPruneNote } = require('@/utils/contextPressure');
622
+ const noteWithSummary = buildPostPruneNote(10, true);
623
+ const noteWithout = buildPostPruneNote(10, false);
624
+ for (const note of [noteWithSummary, noteWithout]) {
625
+ expect(note).not.toBeNull();
626
+ expect(note).not.toMatch(/\d+%/);
627
+ expect(note).not.toMatch(/\d+ of \d+ tokens/);
628
+ expect(note).not.toMatch(/BUDGET/i);
629
+ expect(note).toContain('task');
620
630
  }
621
-
622
- expect(delegationInjected).toBe(false);
623
631
  });
624
632
  });
625
633
 
@@ -20,7 +20,7 @@ config({
20
20
  import { HumanMessage, ToolMessage } from '@langchain/core/messages';
21
21
  import type { RunnableConfig } from '@langchain/core/runnables';
22
22
  import type * as t from '@/types';
23
- import { Providers, Constants, GraphEvents } from '@/common';
23
+ import { Providers, Constants, GraphEvents, EdgeType } from '@/common';
24
24
  import { StandardGraph } from '@/graphs/Graph';
25
25
  import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
26
26
  import { ToolEndHandler, ModelEndHandler } from '@/events';
@@ -118,13 +118,13 @@ describeIf('Agent Handoff E2E with Bedrock', () => {
118
118
  {
119
119
  from: 'supervisor_abc123',
120
120
  to: 'agent_W47hBnn2RoVZEOy5595GC',
121
- edgeType: 'handoff',
121
+ edgeType: EdgeType.HANDOFF,
122
122
  // No description - should auto-generate from agent name + description
123
123
  },
124
124
  {
125
125
  from: 'supervisor_abc123',
126
126
  to: 'agent_X92kLmn4TpQR8vw3221HD',
127
- edgeType: 'handoff',
127
+ edgeType: EdgeType.HANDOFF,
128
128
  // No description
129
129
  },
130
130
  ];
@@ -203,8 +203,8 @@ describeIf('Agent Handoff E2E with Bedrock', () => {
203
203
  ];
204
204
 
205
205
  const edges: t.GraphEdge[] = [
206
- { from: 'router', to: 'sales_agent', edgeType: 'handoff' },
207
- { from: 'router', to: 'support_agent', edgeType: 'handoff' },
206
+ { from: 'router', to: 'sales_agent', edgeType: EdgeType.HANDOFF },
207
+ { from: 'router', to: 'support_agent', edgeType: EdgeType.HANDOFF },
208
208
  ];
209
209
 
210
210
  const { contentParts: _contentParts, aggregateContent } =
@@ -321,8 +321,8 @@ describeIf('Agent Handoff E2E with Bedrock', () => {
321
321
  ];
322
322
 
323
323
  const edges: t.GraphEdge[] = [
324
- { from: 'router', to: 'sales_agent', edgeType: 'handoff' },
325
- { from: 'router', to: 'support_agent', edgeType: 'handoff' },
324
+ { from: 'router', to: 'sales_agent', edgeType: EdgeType.HANDOFF },
325
+ { from: 'router', to: 'support_agent', edgeType: EdgeType.HANDOFF },
326
326
  ];
327
327
 
328
328
  const { contentParts: _contentParts, aggregateContent } =
@@ -4,7 +4,7 @@ import { HumanMessage, ToolMessage } from '@langchain/core/messages';
4
4
  import type { ToolCall } from '@langchain/core/messages/tool';
5
5
  import type { RunnableConfig } from '@langchain/core/runnables';
6
6
  import type * as t from '@/types';
7
- import { Providers, Constants } from '@/common';
7
+ import { Providers, Constants, EdgeType } from '@/common';
8
8
  import { StandardGraph } from '@/graphs/Graph';
9
9
  import { Run } from '@/run';
10
10
 
@@ -94,7 +94,7 @@ describe('Agent Handoffs Tests', () => {
94
94
  {
95
95
  from: 'agent_a',
96
96
  to: 'agent_b',
97
- edgeType: 'handoff',
97
+ edgeType: EdgeType.HANDOFF,
98
98
  description: 'Transfer to agent B',
99
99
  },
100
100
  ];
@@ -128,7 +128,7 @@ describe('Agent Handoffs Tests', () => {
128
128
  {
129
129
  from: 'agent_a',
130
130
  to: 'agent_b',
131
- edgeType: 'handoff',
131
+ edgeType: EdgeType.HANDOFF,
132
132
  description: 'Transfer to agent B when needed',
133
133
  },
134
134
  ];
@@ -192,7 +192,7 @@ describe('Agent Handoffs Tests', () => {
192
192
  {
193
193
  from: 'agent_a',
194
194
  to: 'agent_b',
195
- edgeType: 'handoff',
195
+ edgeType: EdgeType.HANDOFF,
196
196
  },
197
197
  ];
198
198
 
@@ -223,13 +223,13 @@ describe('Agent Handoffs Tests', () => {
223
223
  {
224
224
  from: 'agent_a',
225
225
  to: 'agent_b',
226
- edgeType: 'handoff',
226
+ edgeType: EdgeType.HANDOFF,
227
227
  description: 'Transfer to agent B',
228
228
  },
229
229
  {
230
230
  from: 'agent_b',
231
231
  to: 'agent_a',
232
- edgeType: 'handoff',
232
+ edgeType: EdgeType.HANDOFF,
233
233
  description: 'Transfer to agent A',
234
234
  },
235
235
  ];
@@ -268,12 +268,12 @@ describe('Agent Handoffs Tests', () => {
268
268
  {
269
269
  from: 'agent_a',
270
270
  to: 'agent_b',
271
- edgeType: 'handoff',
271
+ edgeType: EdgeType.HANDOFF,
272
272
  },
273
273
  {
274
274
  from: 'agent_b',
275
275
  to: 'agent_a',
276
- edgeType: 'handoff',
276
+ edgeType: EdgeType.HANDOFF,
277
277
  },
278
278
  ];
279
279
 
@@ -334,13 +334,13 @@ describe('Agent Handoffs Tests', () => {
334
334
  {
335
335
  from: 'agent_a',
336
336
  to: 'agent_b',
337
- edgeType: 'handoff',
337
+ edgeType: EdgeType.HANDOFF,
338
338
  description: 'Transfer to agent B',
339
339
  },
340
340
  {
341
341
  from: 'agent_b',
342
342
  to: 'agent_c',
343
- edgeType: 'handoff',
343
+ edgeType: EdgeType.HANDOFF,
344
344
  description: 'Transfer to agent C',
345
345
  },
346
346
  ];
@@ -395,19 +395,19 @@ describe('Agent Handoffs Tests', () => {
395
395
  {
396
396
  from: 'router',
397
397
  to: 'agent_a',
398
- edgeType: 'handoff',
398
+ edgeType: EdgeType.HANDOFF,
399
399
  description: 'Transfer to agent A for task A',
400
400
  },
401
401
  {
402
402
  from: 'router',
403
403
  to: 'agent_b',
404
- edgeType: 'handoff',
404
+ edgeType: EdgeType.HANDOFF,
405
405
  description: 'Transfer to agent B for task B',
406
406
  },
407
407
  {
408
408
  from: 'router',
409
409
  to: 'agent_c',
410
- edgeType: 'handoff',
410
+ edgeType: EdgeType.HANDOFF,
411
411
  description: 'Transfer to agent C for task C',
412
412
  },
413
413
  ];
@@ -449,13 +449,13 @@ describe('Agent Handoffs Tests', () => {
449
449
  {
450
450
  from: 'router',
451
451
  to: 'agent_a',
452
- edgeType: 'handoff',
452
+ edgeType: EdgeType.HANDOFF,
453
453
  description: 'Transfer to agent A',
454
454
  },
455
455
  {
456
456
  from: 'router',
457
457
  to: 'agent_b',
458
- edgeType: 'handoff',
458
+ edgeType: EdgeType.HANDOFF,
459
459
  description: 'Transfer to agent B',
460
460
  },
461
461
  ];
@@ -519,7 +519,7 @@ describe('Agent Handoffs Tests', () => {
519
519
  {
520
520
  from: 'agent_a',
521
521
  to: 'agent_b',
522
- edgeType: 'handoff',
522
+ edgeType: EdgeType.HANDOFF,
523
523
  description: 'Transfer to agent B with instructions',
524
524
  prompt: 'Provide specific instructions for agent B',
525
525
  promptKey: 'instructions',
@@ -551,7 +551,7 @@ describe('Agent Handoffs Tests', () => {
551
551
  {
552
552
  from: 'agent_a',
553
553
  to: 'agent_b',
554
- edgeType: 'handoff',
554
+ edgeType: EdgeType.HANDOFF,
555
555
  prompt: 'Instructions for handoff',
556
556
  // promptKey not specified, should default to 'instructions'
557
557
  },
@@ -581,7 +581,7 @@ describe('Agent Handoffs Tests', () => {
581
581
  {
582
582
  from: 'agent_a',
583
583
  to: 'agent_b',
584
- edgeType: 'handoff',
584
+ edgeType: EdgeType.HANDOFF,
585
585
  description: 'Transfer to agent B',
586
586
  prompt: 'Additional context for agent B',
587
587
  promptKey: 'context',
@@ -638,7 +638,7 @@ describe('Agent Handoffs Tests', () => {
638
638
  {
639
639
  from: 'agent_a',
640
640
  to: 'agent_a',
641
- edgeType: 'handoff',
641
+ edgeType: EdgeType.HANDOFF,
642
642
  description: 'Self-handoff (should be allowed but unusual)',
643
643
  },
644
644
  ];
@@ -724,7 +724,7 @@ describe('Agent Handoffs Tests', () => {
724
724
  {
725
725
  from: 'agent_a',
726
726
  to: 'agent_b',
727
- edgeType: 'handoff',
727
+ edgeType: EdgeType.HANDOFF,
728
728
  description: 'Transfer to agent B',
729
729
  },
730
730
  ];
@@ -759,12 +759,12 @@ describe('Agent Handoffs Tests', () => {
759
759
  {
760
760
  from: 'agent_a',
761
761
  to: 'agent_b',
762
- edgeType: 'handoff',
762
+ edgeType: EdgeType.HANDOFF,
763
763
  },
764
764
  {
765
765
  from: 'agent_b',
766
766
  to: 'agent_c',
767
- edgeType: 'handoff',
767
+ edgeType: EdgeType.HANDOFF,
768
768
  },
769
769
  ];
770
770
 
@@ -806,12 +806,12 @@ describe('Agent Handoffs Tests', () => {
806
806
  {
807
807
  from: 'agent_a',
808
808
  to: 'agent_c',
809
- edgeType: 'handoff',
809
+ edgeType: EdgeType.HANDOFF,
810
810
  },
811
811
  {
812
812
  from: 'agent_b',
813
813
  to: 'agent_c',
814
- edgeType: 'handoff',
814
+ edgeType: EdgeType.HANDOFF,
815
815
  },
816
816
  ];
817
817
 
@@ -853,7 +853,7 @@ describe('Agent Handoffs Tests', () => {
853
853
  {
854
854
  from: 'router',
855
855
  to: 'data_analyst',
856
- edgeType: 'handoff',
856
+ edgeType: EdgeType.HANDOFF,
857
857
  description: 'Transfer to data analyst',
858
858
  prompt: 'Instructions for the analyst about what to analyze',
859
859
  promptKey: 'instructions',
@@ -939,7 +939,7 @@ describe('Agent Handoffs Tests', () => {
939
939
  {
940
940
  from: 'flight_assistant',
941
941
  to: 'hotel_assistant',
942
- edgeType: 'handoff',
942
+ edgeType: EdgeType.HANDOFF,
943
943
  description: 'Transfer to hotel booking',
944
944
  },
945
945
  ];
@@ -970,7 +970,7 @@ describe('Agent Handoffs Tests', () => {
970
970
  {
971
971
  from: 'agent_with_underscores',
972
972
  to: 'AgentWithCamelCase',
973
- edgeType: 'handoff',
973
+ edgeType: EdgeType.HANDOFF,
974
974
  },
975
975
  ];
976
976
 
@@ -1007,7 +1007,7 @@ describe('Agent Handoffs Tests', () => {
1007
1007
  {
1008
1008
  from: 'supervisor',
1009
1009
  to: 'data_analyst',
1010
- edgeType: 'handoff',
1010
+ edgeType: EdgeType.HANDOFF,
1011
1011
  // No description provided - should auto-generate from agent name + description
1012
1012
  },
1013
1013
  ];
@@ -1042,7 +1042,7 @@ describe('Agent Handoffs Tests', () => {
1042
1042
  {
1043
1043
  from: 'supervisor',
1044
1044
  to: 'writer',
1045
- edgeType: 'handoff',
1045
+ edgeType: EdgeType.HANDOFF,
1046
1046
  },
1047
1047
  ];
1048
1048
 
@@ -1075,7 +1075,7 @@ describe('Agent Handoffs Tests', () => {
1075
1075
  {
1076
1076
  from: 'supervisor',
1077
1077
  to: 'agent_b',
1078
- edgeType: 'handoff',
1078
+ edgeType: EdgeType.HANDOFF,
1079
1079
  description: 'Custom handoff description that takes priority',
1080
1080
  },
1081
1081
  ];
@@ -1118,9 +1118,9 @@ describe('Agent Handoffs Tests', () => {
1118
1118
  ];
1119
1119
 
1120
1120
  const edges: t.GraphEdge[] = [
1121
- { from: 'router', to: 'sales', edgeType: 'handoff' },
1122
- { from: 'router', to: 'support', edgeType: 'handoff' },
1123
- { from: 'router', to: 'billing', edgeType: 'handoff' },
1121
+ { from: 'router', to: 'sales', edgeType: EdgeType.HANDOFF },
1122
+ { from: 'router', to: 'support', edgeType: EdgeType.HANDOFF },
1123
+ { from: 'router', to: 'billing', edgeType: EdgeType.HANDOFF },
1124
1124
  ];
1125
1125
 
1126
1126
  const run = await Run.create(createTestConfig(agents, edges));
@@ -1176,7 +1176,7 @@ describe('Agent Handoffs Tests', () => {
1176
1176
  ];
1177
1177
 
1178
1178
  const edges: t.GraphEdge[] = [
1179
- { from: 'agent_a', to: 'agent_b', edgeType: 'handoff' },
1179
+ { from: 'agent_a', to: 'agent_b', edgeType: EdgeType.HANDOFF },
1180
1180
  ];
1181
1181
 
1182
1182
  const run = await Run.create(createTestConfig(agents, edges));
@@ -1215,7 +1215,7 @@ describe('Agent Handoffs Tests', () => {
1215
1215
  {
1216
1216
  from: 'agent_a',
1217
1217
  to: 'agent_b',
1218
- edgeType: 'handoff',
1218
+ edgeType: EdgeType.HANDOFF,
1219
1219
  description: 'Transfer to B',
1220
1220
  },
1221
1221
  ];
@@ -1255,7 +1255,7 @@ describe('Agent Handoffs Tests', () => {
1255
1255
  ];
1256
1256
 
1257
1257
  const edges: t.GraphEdge[] = [
1258
- { from: 'agent_a', to: 'agent_b', edgeType: 'handoff' },
1258
+ { from: 'agent_a', to: 'agent_b', edgeType: EdgeType.HANDOFF },
1259
1259
  ];
1260
1260
 
1261
1261
  const run = await Run.create(createTestConfig(agents, edges));
@@ -3,7 +3,7 @@ import { HumanMessage, ToolMessage } from '@langchain/core/messages';
3
3
  import type { ToolCall } from '@langchain/core/messages/tool';
4
4
  import type { RunnableConfig } from '@langchain/core/runnables';
5
5
  import type * as t from '@/types';
6
- import { Providers, Constants } from '@/common';
6
+ import { Providers, Constants, EdgeType } from '@/common';
7
7
  import { StandardGraph } from '@/graphs/Graph';
8
8
  import { Run } from '@/run';
9
9
 
@@ -77,7 +77,7 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
77
77
  {
78
78
  from: 'supervisor',
79
79
  to: 'specialist',
80
- edgeType: 'handoff',
80
+ edgeType: EdgeType.HANDOFF,
81
81
  description: 'Transfer to specialist for detailed analysis',
82
82
  },
83
83
  ];
@@ -166,7 +166,7 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
166
166
  {
167
167
  from: 'agent_a',
168
168
  to: 'agent_b',
169
- edgeType: 'handoff',
169
+ edgeType: EdgeType.HANDOFF,
170
170
  },
171
171
  ];
172
172
 
@@ -223,7 +223,7 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
223
223
  {
224
224
  from: 'coordinator',
225
225
  to: 'analyst',
226
- edgeType: 'handoff',
226
+ edgeType: EdgeType.HANDOFF,
227
227
  description: 'Transfer to analyst for deep analysis',
228
228
  },
229
229
  ];
@@ -297,7 +297,7 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
297
297
  {
298
298
  from: 'agent_a',
299
299
  to: 'agent_b',
300
- edgeType: 'handoff',
300
+ edgeType: EdgeType.HANDOFF,
301
301
  },
302
302
  ];
303
303
 
@@ -360,7 +360,7 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
360
360
  {
361
361
  from: 'supervisor',
362
362
  to: 'bedrock_specialist',
363
- edgeType: 'handoff',
363
+ edgeType: EdgeType.HANDOFF,
364
364
  description: 'Transfer to Bedrock specialist',
365
365
  },
366
366
  ];
@@ -450,12 +450,12 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
450
450
  {
451
451
  from: 'router',
452
452
  to: 'processor',
453
- edgeType: 'handoff',
453
+ edgeType: EdgeType.HANDOFF,
454
454
  },
455
455
  {
456
456
  from: 'processor',
457
457
  to: 'reviewer',
458
- edgeType: 'handoff',
458
+ edgeType: EdgeType.HANDOFF,
459
459
  },
460
460
  ];
461
461
 
@@ -538,7 +538,7 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
538
538
  {
539
539
  from: 'agent_a',
540
540
  to: 'agent_b',
541
- edgeType: 'handoff',
541
+ edgeType: EdgeType.HANDOFF,
542
542
  },
543
543
  ];
544
544
 
@@ -603,7 +603,7 @@ describe('Thinking-Enabled Agent Handoff Tests', () => {
603
603
  {
604
604
  from: 'agent_a',
605
605
  to: 'agent_b',
606
- edgeType: 'handoff',
606
+ edgeType: EdgeType.HANDOFF,
607
607
  },
608
608
  ];
609
609