|
45 | 45 | depth: int = 0, |
46 | 46 | max_depth: int = 1, |
47 | 47 | max_iterations: int = 30, |
| 48 | + max_budget: float | None = None, |
| 49 | + max_timeout: float | None = None, |
| 50 | + max_tokens: int | None = None, |
| 51 | + max_errors: int | None = None, |
48 | 52 | custom_system_prompt: str | None = None, |
49 | 53 | other_backends: list[str] | None = None, |
50 | 54 | other_backend_kwargs: list[dict] | None = None, |
51 | 55 | logger: RLMLogger | None = None, |
52 | 56 | verbose: bool = False, |
| 57 | + persistent: bool = False, |
| 58 | + on_subcall_start: Callable[[int, str, str], None] | None = None, |
| 59 | + on_subcall_complete: Callable[[int, str, float, str | None], None] | None = None, |
| 60 | + on_iteration_start: Callable[[int, int], None] | None = None, |
| 61 | + on_iteration_complete: Callable[[int, int, float], None] | None = None, |
53 | 62 | ) |
54 | 63 | ``` |
55 | 64 |
|
@@ -158,7 +167,7 @@ environment_kwargs = { |
158 | 167 | **Type:** `int` |
159 | 168 | **Default:** `1` |
160 | 169 |
|
161 | | -Maximum recursion depth for nested RLM calls. Currently only depth 1 is fully supported. |
| 170 | +Maximum recursion depth for nested RLM calls. Depth>1 recursive subcalls are supported in the local environment via `llm_query()`. |
162 | 171 |
|
163 | 172 | When `depth >= max_depth`, the RLM falls back to a regular LM completion. |
164 | 173 |
|
@@ -187,6 +196,46 @@ rlm = RLM( |
187 | 196 |
|
188 | 197 | --- |
189 | 198 |
|
| 199 | +#### `max_budget` |
| 200 | +{: .no_toc } |
| 201 | + |
| 202 | +**Type:** `float | None` |
| 203 | +**Default:** `None` |
| 204 | + |
| 205 | +Maximum total USD cost for a completion. If exceeded, RLM raises `BudgetExceededError`. This requires a backend that reports cost. |
| 206 | + |
| 207 | +--- |
| 208 | + |
| 209 | +#### `max_timeout` |
| 210 | +{: .no_toc } |
| 211 | + |
| 212 | +**Type:** `float | None` |
| 213 | +**Default:** `None` |
| 214 | + |
| 215 | +Maximum wall-clock seconds for a completion. If exceeded, RLM raises `TimeoutExceededError`. |
| 216 | + |
| 217 | +--- |
| 218 | + |
| 219 | +#### `max_tokens` |
| 220 | +{: .no_toc } |
| 221 | + |
| 222 | +**Type:** `int | None` |
| 223 | +**Default:** `None` |
| 224 | + |
| 225 | +Maximum total tokens (input + output) for a completion. If exceeded, RLM raises `TokenLimitExceededError`. |
| 226 | + |
| 227 | +--- |
| 228 | + |
| 229 | +#### `max_errors` |
| 230 | +{: .no_toc } |
| 231 | + |
| 232 | +**Type:** `int | None` |
| 233 | +**Default:** `None` |
| 234 | + |
| 235 | +Maximum consecutive REPL errors before aborting. If exceeded, RLM raises `ErrorThresholdExceededError`. |
| 236 | + |
| 237 | +--- |
| 238 | + |
190 | 239 | #### `custom_system_prompt` |
191 | 240 | {: .no_toc } |
192 | 241 |
|
@@ -401,6 +450,12 @@ rlm = RLM(backend="unknown") |
401 | 450 |
|
402 | 451 | If the RLM exhausts `max_iterations` without finding a `FINAL()` answer, it prompts the LM one more time to provide a final answer based on the conversation history. |
403 | 452 |
|
| 453 | +RLM also raises explicit exceptions when limits are exceeded: |
| 454 | +- `BudgetExceededError` |
| 455 | +- `TimeoutExceededError` |
| 456 | +- `TokenLimitExceededError` |
| 457 | +- `ErrorThresholdExceededError` |
| 458 | + |
404 | 459 | --- |
405 | 460 |
|
406 | 461 | ## Thread Safety |
@@ -458,4 +513,3 @@ result = rlm.completion( |
458 | 513 | root_prompt="Summarize the key findings" |
459 | 514 | ) |
460 | 515 | ``` |
461 | | - |
|
0 commit comments