llm.rb 15.0.3 → 15.2.0

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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +433 -3
  3. data/README.md +188 -71
  4. data/bin/llm.rb +50 -7
  5. data/data/alibaba.json +912 -823
  6. data/data/anthropic.json +234 -187
  7. data/data/bedrock.json +3702 -2058
  8. data/data/deepinfra.json +1288 -951
  9. data/data/deepseek.json +87 -53
  10. data/data/google.json +670 -670
  11. data/data/mistral.json +501 -460
  12. data/data/moonshot.json +43 -248
  13. data/data/openai.json +1008 -914
  14. data/data/openrouter.json +14417 -0
  15. data/data/xai.json +213 -201
  16. data/data/zai.json +242 -149
  17. data/docs/deepdive/advanced/compaction.md +5 -5
  18. data/docs/deepdive/advanced/context.md +8 -6
  19. data/docs/deepdive/advanced/guard.md +2 -2
  20. data/docs/deepdive/features/builtin_tools.md +93 -22
  21. data/docs/deepdive/features/{repl.md → console.md} +28 -28
  22. data/docs/deepdive/features/database.md +3 -3
  23. data/docs/deepdive/fundamentals/agents.md +13 -12
  24. data/docs/deepdive/fundamentals/providers.md +91 -6
  25. data/docs/deepdive/fundamentals/skills.md +14 -6
  26. data/docs/deepdive/fundamentals/stream.md +4 -4
  27. data/docs/deepdive/fundamentals/tools.md +63 -31
  28. data/docs/deepdive/reference/cost.md +2 -2
  29. data/docs/deepdive/reference/model_registry.md +2 -2
  30. data/docs/deepdive/reference/tracer.md +15 -13
  31. data/docs/deepdive.md +2 -2
  32. data/lib/llm/active_record/acts_as_agent.rb +9 -5
  33. data/lib/llm/agent.rb +40 -15
  34. data/lib/llm/{repl → console}/bar.rb +3 -3
  35. data/lib/llm/{repl → console}/buffer.rb +24 -9
  36. data/lib/llm/{repl → console}/color.rb +2 -2
  37. data/lib/llm/{repl → console}/command.rb +12 -12
  38. data/lib/llm/{repl → console}/commands/exit.rb +4 -4
  39. data/lib/llm/{repl → console}/commands/help.rb +1 -1
  40. data/lib/llm/{repl/commands/compact.rb → console/commands/keep.rb} +11 -9
  41. data/lib/llm/{repl → console}/commands/model.rb +2 -2
  42. data/lib/llm/{repl → console}/input/cache.rb +2 -2
  43. data/lib/llm/{repl → console}/input/char.rb +2 -2
  44. data/lib/llm/{repl → console}/input/row.rb +1 -1
  45. data/lib/llm/{repl → console}/input.rb +18 -10
  46. data/lib/llm/console/markdown/parser.rb +78 -0
  47. data/lib/llm/{repl → console}/markdown/table.rb +8 -5
  48. data/lib/llm/{repl → console}/markdown.rb +13 -30
  49. data/lib/llm/console/node.rb +69 -0
  50. data/lib/llm/{repl → console}/status.rb +11 -11
  51. data/lib/llm/{repl → console}/stream.rb +36 -9
  52. data/lib/llm/{repl → console}/walker.rb +1 -1
  53. data/lib/llm/{repl → console}/window.rb +17 -17
  54. data/lib/llm/{repl.rb → console.rb} +39 -19
  55. data/lib/llm/context/deserializer.rb +2 -1
  56. data/lib/llm/context.rb +29 -13
  57. data/lib/llm/cost.rb +13 -0
  58. data/lib/llm/function/async/reactor.rb +20 -1
  59. data/lib/llm/function/fork/task.rb +14 -10
  60. data/lib/llm/function.rb +1 -1
  61. data/lib/llm/json_adapter.rb +40 -28
  62. data/lib/llm/message.rb +7 -0
  63. data/lib/llm/provider.rb +31 -10
  64. data/lib/llm/providers/alibaba.rb +1 -1
  65. data/lib/llm/providers/anthropic.rb +1 -1
  66. data/lib/llm/providers/bedrock/models.rb +2 -2
  67. data/lib/llm/providers/bedrock.rb +1 -1
  68. data/lib/llm/providers/deepseek.rb +1 -1
  69. data/lib/llm/providers/google.rb +1 -1
  70. data/lib/llm/providers/ollama.rb +1 -1
  71. data/lib/llm/providers/openai/responses.rb +2 -1
  72. data/lib/llm/providers/openai.rb +2 -1
  73. data/lib/llm/providers/openrouter.rb +87 -0
  74. data/lib/llm/schema/leaf.rb +34 -2
  75. data/lib/llm/schema.rb +4 -2
  76. data/lib/llm/sequel/agent.rb +9 -5
  77. data/lib/llm/skill.rb +7 -1
  78. data/lib/llm/stream.rb +8 -3
  79. data/lib/llm/tool/param.rb +5 -1
  80. data/lib/llm/tool.rb +5 -0
  81. data/lib/llm/tools/bundle.rb +53 -0
  82. data/lib/llm/tools/edit-file.rb +7 -2
  83. data/lib/llm/tools/exec.rb +78 -0
  84. data/lib/llm/tools/git.rb +27 -26
  85. data/lib/llm/tools/mkdir.rb +12 -19
  86. data/lib/llm/tools/read_file.rb +69 -9
  87. data/lib/llm/tools/rg.rb +20 -24
  88. data/lib/llm/tools/ruby.rb +17 -25
  89. data/lib/llm/tools/utils.rb +75 -2
  90. data/lib/llm/tools/write_file.rb +4 -1
  91. data/lib/llm/tracer/logger.rb +2 -2
  92. data/lib/llm/tracer/pretty_logger.rb +4 -4
  93. data/lib/llm/tracer/telemetry.rb +2 -2
  94. data/lib/llm/tracer.rb +33 -0
  95. data/lib/llm/transport/curb.rb +5 -3
  96. data/lib/llm/transport/http.rb +5 -2
  97. data/lib/llm/transport/persistent_http.rb +6 -4
  98. data/lib/llm/transport/utils.rb +8 -6
  99. data/lib/llm/version.rb +1 -1
  100. data/lib/llm.rb +18 -12
  101. data/llm.gemspec +8 -8
  102. metadata +80 -37
  103. data/lib/llm/repl/node.rb +0 -44
  104. data/lib/llm/tools/shell.rb +0 -55
data/data/zai.json CHANGED
@@ -8,6 +8,83 @@
8
8
  "name": "Z.AI",
9
9
  "doc": "https://docs.z.ai/guides/overview/pricing",
10
10
  "models": {
11
+ "glm-4.7": {
12
+ "id": "glm-4.7",
13
+ "name": "GLM-4.7",
14
+ "description": "Mature GLM model for dependable coding, reasoning, and structured agent tasks",
15
+ "family": "glm",
16
+ "attachment": false,
17
+ "reasoning": true,
18
+ "reasoning_options": [
19
+ {
20
+ "type": "toggle"
21
+ }
22
+ ],
23
+ "tool_call": true,
24
+ "interleaved": {
25
+ "field": "reasoning_content"
26
+ },
27
+ "temperature": true,
28
+ "knowledge": "2025-04",
29
+ "release_date": "2025-12-22",
30
+ "last_updated": "2025-12-22",
31
+ "modalities": {
32
+ "input": [
33
+ "text"
34
+ ],
35
+ "output": [
36
+ "text"
37
+ ]
38
+ },
39
+ "open_weights": true,
40
+ "limit": {
41
+ "context": 204800,
42
+ "output": 131072
43
+ },
44
+ "cost": {
45
+ "input": 0.6,
46
+ "output": 2.2,
47
+ "cache_read": 0.11,
48
+ "cache_write": 0
49
+ }
50
+ },
51
+ "glm-4.5-air": {
52
+ "id": "glm-4.5-air",
53
+ "name": "GLM-4.5-Air",
54
+ "description": "Lighter GLM-4.5 variant for fast coding assistance and cheaper agents",
55
+ "family": "glm-air",
56
+ "attachment": false,
57
+ "reasoning": true,
58
+ "reasoning_options": [
59
+ {
60
+ "type": "toggle"
61
+ }
62
+ ],
63
+ "tool_call": true,
64
+ "temperature": true,
65
+ "knowledge": "2025-04",
66
+ "release_date": "2025-07-28",
67
+ "last_updated": "2025-07-28",
68
+ "modalities": {
69
+ "input": [
70
+ "text"
71
+ ],
72
+ "output": [
73
+ "text"
74
+ ]
75
+ },
76
+ "open_weights": true,
77
+ "limit": {
78
+ "context": 131072,
79
+ "output": 98304
80
+ },
81
+ "cost": {
82
+ "input": 0.2,
83
+ "output": 1.1,
84
+ "cache_read": 0.03,
85
+ "cache_write": 0
86
+ }
87
+ },
11
88
  "glm-4.6": {
12
89
  "id": "glm-4.6",
13
90
  "name": "GLM-4.6",
@@ -45,6 +122,87 @@
45
122
  "cache_write": 0
46
123
  }
47
124
  },
125
+ "glm-4.6v": {
126
+ "id": "glm-4.6v",
127
+ "name": "GLM-4.6V",
128
+ "description": "GLM vision model for visual reasoning, documents, and multimodal agents",
129
+ "family": "glm",
130
+ "attachment": true,
131
+ "reasoning": true,
132
+ "reasoning_options": [
133
+ {
134
+ "type": "toggle"
135
+ }
136
+ ],
137
+ "tool_call": true,
138
+ "temperature": true,
139
+ "knowledge": "2025-04",
140
+ "release_date": "2025-12-08",
141
+ "last_updated": "2025-12-08",
142
+ "modalities": {
143
+ "input": [
144
+ "text",
145
+ "image",
146
+ "video"
147
+ ],
148
+ "output": [
149
+ "text"
150
+ ]
151
+ },
152
+ "open_weights": true,
153
+ "limit": {
154
+ "context": 128000,
155
+ "output": 32768
156
+ },
157
+ "cost": {
158
+ "input": 0.3,
159
+ "output": 0.9
160
+ }
161
+ },
162
+ "glm-5.2": {
163
+ "id": "glm-5.2",
164
+ "name": "GLM-5.2",
165
+ "description": "Open flagship GLM for long-horizon coding agents and million-token context work",
166
+ "family": "glm",
167
+ "attachment": false,
168
+ "reasoning": true,
169
+ "reasoning_options": [
170
+ {
171
+ "type": "effort",
172
+ "values": [
173
+ "high",
174
+ "max"
175
+ ]
176
+ }
177
+ ],
178
+ "tool_call": true,
179
+ "interleaved": {
180
+ "field": "reasoning_content"
181
+ },
182
+ "structured_output": true,
183
+ "temperature": true,
184
+ "release_date": "2026-06-13",
185
+ "last_updated": "2026-06-13",
186
+ "modalities": {
187
+ "input": [
188
+ "text"
189
+ ],
190
+ "output": [
191
+ "text"
192
+ ]
193
+ },
194
+ "open_weights": true,
195
+ "limit": {
196
+ "context": 1000000,
197
+ "output": 131072
198
+ },
199
+ "cost": {
200
+ "input": 1.4,
201
+ "output": 4.4,
202
+ "cache_read": 0.26,
203
+ "cache_write": 0
204
+ }
205
+ },
48
206
  "glm-4.5-flash": {
49
207
  "id": "glm-4.5-flash",
50
208
  "name": "GLM-4.5-Flash",
@@ -82,25 +240,31 @@
82
240
  "cache_write": 0
83
241
  }
84
242
  },
85
- "glm-5v-turbo": {
86
- "id": "glm-5v-turbo",
87
- "name": "GLM-5V-Turbo",
88
- "description": "Fast GLM vision model for screenshots, documents, and multimodal agent tasks",
243
+ "glm-5.3-flash": {
244
+ "id": "glm-5.3-flash",
245
+ "name": "GLM-5.3-Flash",
246
+ "description": "Native multimodal GLM model for efficient coding and long-horizon agent tasks",
89
247
  "family": "glm",
90
248
  "attachment": true,
91
249
  "reasoning": true,
92
250
  "reasoning_options": [
93
251
  {
94
- "type": "toggle"
252
+ "type": "effort",
253
+ "values": [
254
+ "low",
255
+ "high",
256
+ "max"
257
+ ]
95
258
  }
96
259
  ],
97
260
  "tool_call": true,
98
261
  "interleaved": {
99
262
  "field": "reasoning_content"
100
263
  },
264
+ "structured_output": true,
101
265
  "temperature": true,
102
- "release_date": "2026-04-01",
103
- "last_updated": "2026-04-01",
266
+ "release_date": "2026-08-26",
267
+ "last_updated": "2026-08-26",
104
268
  "modalities": {
105
269
  "input": [
106
270
  "text",
@@ -112,22 +276,22 @@
112
276
  "text"
113
277
  ]
114
278
  },
115
- "open_weights": false,
279
+ "open_weights": true,
116
280
  "limit": {
117
- "context": 200000,
281
+ "context": 1000000,
118
282
  "output": 131072
119
283
  },
120
284
  "cost": {
121
- "input": 1.2,
122
- "output": 4,
123
- "cache_read": 0.24,
285
+ "input": 0.075,
286
+ "output": 0.25,
287
+ "cache_read": 0.015,
124
288
  "cache_write": 0
125
289
  }
126
290
  },
127
- "glm-4.7": {
128
- "id": "glm-4.7",
129
- "name": "GLM-4.7",
130
- "description": "Mature GLM model for dependable coding, reasoning, and structured agent tasks",
291
+ "glm-4.5": {
292
+ "id": "glm-4.5",
293
+ "name": "GLM-4.5",
294
+ "description": "Hybrid-reasoning GLM release that made the 4.5 line broadly useful",
131
295
  "family": "glm",
132
296
  "attachment": false,
133
297
  "reasoning": true,
@@ -137,13 +301,10 @@
137
301
  }
138
302
  ],
139
303
  "tool_call": true,
140
- "interleaved": {
141
- "field": "reasoning_content"
142
- },
143
304
  "temperature": true,
144
305
  "knowledge": "2025-04",
145
- "release_date": "2025-12-22",
146
- "last_updated": "2025-12-22",
306
+ "release_date": "2025-07-28",
307
+ "last_updated": "2025-07-28",
147
308
  "modalities": {
148
309
  "input": [
149
310
  "text"
@@ -154,8 +315,8 @@
154
315
  },
155
316
  "open_weights": true,
156
317
  "limit": {
157
- "context": 204800,
158
- "output": 131072
318
+ "context": 131072,
319
+ "output": 98304
159
320
  },
160
321
  "cost": {
161
322
  "input": 0.6,
@@ -277,10 +438,10 @@
277
438
  "cache_write": 0
278
439
  }
279
440
  },
280
- "glm-5-turbo": {
281
- "id": "glm-5-turbo",
282
- "name": "GLM-5-Turbo",
283
- "description": "Faster GLM-5 lane for coding agents that need lower latency",
441
+ "glm-5.1": {
442
+ "id": "glm-5.1",
443
+ "name": "GLM-5.1",
444
+ "description": "Strong GLM coding model for agentic engineering, terminals, and repository generation",
284
445
  "family": "glm",
285
446
  "attachment": false,
286
447
  "reasoning": true,
@@ -295,8 +456,8 @@
295
456
  },
296
457
  "structured_output": true,
297
458
  "temperature": true,
298
- "release_date": "2026-03-16",
299
- "last_updated": "2026-03-16",
459
+ "release_date": "2026-04-07",
460
+ "last_updated": "2026-04-07",
300
461
  "modalities": {
301
462
  "input": [
302
463
  "text"
@@ -305,32 +466,28 @@
305
466
  "text"
306
467
  ]
307
468
  },
308
- "open_weights": false,
469
+ "open_weights": true,
309
470
  "limit": {
310
471
  "context": 200000,
311
472
  "output": 131072
312
473
  },
313
474
  "cost": {
314
- "input": 1.2,
315
- "output": 4,
316
- "cache_read": 0.24,
475
+ "input": 1.4,
476
+ "output": 4.4,
477
+ "cache_read": 0.26,
317
478
  "cache_write": 0
318
479
  }
319
480
  },
320
- "glm-5.2": {
321
- "id": "glm-5.2",
322
- "name": "GLM-5.2",
323
- "description": "Open flagship GLM for long-horizon coding agents and million-token context work",
481
+ "glm-5-turbo": {
482
+ "id": "glm-5-turbo",
483
+ "name": "GLM-5-Turbo",
484
+ "description": "Faster GLM-5 lane for coding agents that need lower latency",
324
485
  "family": "glm",
325
486
  "attachment": false,
326
487
  "reasoning": true,
327
488
  "reasoning_options": [
328
489
  {
329
- "type": "effort",
330
- "values": [
331
- "high",
332
- "max"
333
- ]
490
+ "type": "toggle"
334
491
  }
335
492
  ],
336
493
  "tool_call": true,
@@ -339,8 +496,8 @@
339
496
  },
340
497
  "structured_output": true,
341
498
  "temperature": true,
342
- "release_date": "2026-06-13",
343
- "last_updated": "2026-06-13",
499
+ "release_date": "2026-03-16",
500
+ "last_updated": "2026-03-16",
344
501
  "modalities": {
345
502
  "input": [
346
503
  "text"
@@ -349,72 +506,43 @@
349
506
  "text"
350
507
  ]
351
508
  },
352
- "open_weights": true,
509
+ "open_weights": false,
353
510
  "limit": {
354
- "context": 1000000,
511
+ "context": 200000,
355
512
  "output": 131072
356
513
  },
357
514
  "cost": {
358
- "input": 1.4,
359
- "output": 4.4,
360
- "cache_read": 0.26,
515
+ "input": 1.2,
516
+ "output": 4,
517
+ "cache_read": 0.24,
361
518
  "cache_write": 0
362
519
  }
363
520
  },
364
- "glm-4.6v": {
365
- "id": "glm-4.6v",
366
- "name": "GLM-4.6V",
367
- "description": "GLM vision model for visual reasoning, documents, and multimodal agents",
521
+ "glm-5.3": {
522
+ "id": "glm-5.3",
523
+ "name": "GLM-5.3",
524
+ "description": "Flagship GLM model for long-horizon coding, agents, and complex project delivery",
368
525
  "family": "glm",
369
- "attachment": true,
370
- "reasoning": true,
371
- "reasoning_options": [
372
- {
373
- "type": "toggle"
374
- }
375
- ],
376
- "tool_call": true,
377
- "temperature": true,
378
- "knowledge": "2025-04",
379
- "release_date": "2025-12-08",
380
- "last_updated": "2025-12-08",
381
- "modalities": {
382
- "input": [
383
- "text",
384
- "image",
385
- "video"
386
- ],
387
- "output": [
388
- "text"
389
- ]
390
- },
391
- "open_weights": true,
392
- "limit": {
393
- "context": 128000,
394
- "output": 32768
395
- },
396
- "cost": {
397
- "input": 0.3,
398
- "output": 0.9
399
- }
400
- },
401
- "glm-4.5-air": {
402
- "id": "glm-4.5-air",
403
- "name": "GLM-4.5-Air",
404
- "description": "Lighter GLM-4.5 variant for fast coding assistance and cheaper agents",
405
- "family": "glm-air",
406
526
  "attachment": false,
407
527
  "reasoning": true,
408
528
  "reasoning_options": [
409
529
  {
410
- "type": "toggle"
530
+ "type": "effort",
531
+ "values": [
532
+ "low",
533
+ "high",
534
+ "max"
535
+ ]
411
536
  }
412
537
  ],
413
538
  "tool_call": true,
539
+ "interleaved": {
540
+ "field": "reasoning_content"
541
+ },
542
+ "structured_output": true,
414
543
  "temperature": true,
415
- "knowledge": "2025-04",
416
- "release_date": "2025-07-28",
417
- "last_updated": "2025-07-28",
544
+ "release_date": "2026-08-14",
545
+ "last_updated": "2026-08-14",
418
546
  "modalities": {
419
547
  "input": [
420
548
  "text"
@@ -425,22 +553,22 @@
425
553
  },
426
554
  "open_weights": true,
427
555
  "limit": {
428
- "context": 131072,
429
- "output": 98304
556
+ "context": 1000000,
557
+ "output": 131072
430
558
  },
431
559
  "cost": {
432
- "input": 0.2,
433
- "output": 1.1,
434
- "cache_read": 0.03,
560
+ "input": 1.4,
561
+ "output": 4.4,
562
+ "cache_read": 0.26,
435
563
  "cache_write": 0
436
564
  }
437
565
  },
438
- "glm-5.1": {
439
- "id": "glm-5.1",
440
- "name": "GLM-5.1",
441
- "description": "Strong GLM coding model for agentic engineering, terminals, and repository generation",
566
+ "glm-5v-turbo": {
567
+ "id": "glm-5v-turbo",
568
+ "name": "GLM-5V-Turbo",
569
+ "description": "Fast GLM vision model for screenshots, documents, and multimodal agent tasks",
442
570
  "family": "glm",
443
- "attachment": false,
571
+ "attachment": true,
444
572
  "reasoning": true,
445
573
  "reasoning_options": [
446
574
  {
@@ -451,27 +579,29 @@
451
579
  "interleaved": {
452
580
  "field": "reasoning_content"
453
581
  },
454
- "structured_output": true,
455
582
  "temperature": true,
456
- "release_date": "2026-04-07",
457
- "last_updated": "2026-04-07",
583
+ "release_date": "2026-04-01",
584
+ "last_updated": "2026-04-01",
458
585
  "modalities": {
459
586
  "input": [
460
- "text"
587
+ "text",
588
+ "image",
589
+ "video",
590
+ "pdf"
461
591
  ],
462
592
  "output": [
463
593
  "text"
464
594
  ]
465
595
  },
466
- "open_weights": true,
596
+ "open_weights": false,
467
597
  "limit": {
468
598
  "context": 200000,
469
599
  "output": 131072
470
600
  },
471
601
  "cost": {
472
- "input": 1.4,
473
- "output": 4.4,
474
- "cache_read": 0.26,
602
+ "input": 1.2,
603
+ "output": 4,
604
+ "cache_read": 0.24,
475
605
  "cache_write": 0
476
606
  }
477
607
  },
@@ -511,43 +641,6 @@
511
641
  "cache_read": 0,
512
642
  "cache_write": 0
513
643
  }
514
- },
515
- "glm-4.5": {
516
- "id": "glm-4.5",
517
- "name": "GLM-4.5",
518
- "description": "Hybrid-reasoning GLM release that made the 4.5 line broadly useful",
519
- "family": "glm",
520
- "attachment": false,
521
- "reasoning": true,
522
- "reasoning_options": [
523
- {
524
- "type": "toggle"
525
- }
526
- ],
527
- "tool_call": true,
528
- "temperature": true,
529
- "knowledge": "2025-04",
530
- "release_date": "2025-07-28",
531
- "last_updated": "2025-07-28",
532
- "modalities": {
533
- "input": [
534
- "text"
535
- ],
536
- "output": [
537
- "text"
538
- ]
539
- },
540
- "open_weights": true,
541
- "limit": {
542
- "context": 131072,
543
- "output": 98304
544
- },
545
- "cost": {
546
- "input": 0.6,
547
- "output": 2.2,
548
- "cache_read": 0.11,
549
- "cache_write": 0
550
- }
551
644
  }
552
645
  }
553
646
  }
@@ -45,15 +45,15 @@ compactor = LLM::Compactor::Truncate.new(agent)
45
45
  compactor.call(keep: 200)
46
46
  ```
47
47
 
48
- ##### The `/compact` command
48
+ ##### The `/keep` command
49
49
 
50
- The REPL provides a `/compact` command that accepts a count or
50
+ The console provides a `/keep` command that accepts a count or
51
51
  percentage:
52
52
 
53
53
  ```ruby
54
- # /compact # keep last 128 messages
55
- # /compact 50 # keep last 50 messages
56
- # /compact 75% # keep approximately 75% of messages
54
+ # /keep # keep last 128 messages
55
+ # /keep 50 # keep last 50 messages
56
+ # /keep 75% # keep approximately 75% of messages
57
57
  ```
58
58
 
59
59
  #### Why would I use it?
@@ -74,12 +74,14 @@ with `store: false`, so no conversation state is kept server-side.
74
74
  Pass `mode: :completions` to use the legacy Chat Completions API
75
75
  instead. Every other provider defaults to `mode: :completions`.
76
76
 
77
- A raw context disables rate-limit retries by default (`retry_budget: 0`).
78
- Pass `retry_budget:` to retry a rate-limited request up to that many
79
- times. Each retry sleeps a growing interval (2s, 4s, 6s, ...) and
80
- notifies the stream through
81
- [`LLM::Stream#on_rate_limit`](https://r.uby.dev/api-docs/llm.rb/LLM/Stream.html#on_rate_limit-instance_method)
82
- before trying again. An `LLM::Agent` enables a budget of 3 by
77
+ A raw context disables retries by default (`retry_budget: 0`).
78
+ Pass `retry_budget:` to retry a request that was rate limited
79
+ (`LLM::RateLimitError`) or timed out (`Timeout::Error`, covering
80
+ `Net::OpenTimeout` and `Net::ReadTimeout`), up to that many times.
81
+ Each retry sleeps a growing interval (2s, 4s, 6s, ...) and notifies
82
+ the stream through
83
+ [`LLM::Stream#on_retry`](https://r.uby.dev/api-docs/llm.rb/LLM/Stream.html#on_retry-instance_method)
84
+ before trying again. An `LLM::Agent` enables a budget of 5 by
83
85
  default, so most users never touch this directly.
84
86
 
85
87
  ### Manual loop
@@ -198,9 +198,9 @@ call through:
198
198
  ```ruby
199
199
  class PolicyGuard < LLM::Guard
200
200
  def call(function:)
201
- if function.name == "shell"
201
+ if function.name == "exec"
202
202
  function.return(error: true, type: "policy_error",
203
- message: "shell is disabled")
203
+ message: "exec is disabled")
204
204
  end
205
205
  end
206
206
  end