@@ -74,6 +74,9 @@ def __init__(
7474 on_subcall_complete : Callable [[int , str , float , str | None ], None ] | None = None ,
7575 on_iteration_start : Callable [[int , int ], None ] | None = None ,
7676 on_iteration_complete : Callable [[int , int , float ], None ] | None = None ,
77+ sampling_args : dict [str , Any ] | None = None ,
78+ sub_sampling_args : dict [str , Any ] | None = None ,
79+ orchestrator : bool = True ,
7780 ):
7881 """
7982 Args:
@@ -109,6 +112,32 @@ def __init__(
109112 on_iteration_start: Callback fired when an iteration starts. Args: (depth, iteration_num).
110113 on_iteration_complete: Callback fired when an iteration completes. Args: (depth, iteration_num, duration).
111114 """
115+ # Sampling args plumbed into backend_kwargs / other_backend_kwargs
116+ # before the clients are constructed, so they reach the chat-completions
117+ # call (e.g. temperature, top_p, max_tokens, seed). ``sampling_args``
118+ # applies to the root model (depth=0); ``sub_sampling_args`` to
119+ # depth=1 sub-LLM calls. If ``sub_sampling_args`` is set without an
120+ # ``other_backends``, we mirror the root backend so depth=1 routes
121+ # through a separate client with its own sampling args.
122+ if sampling_args is not None :
123+ backend_kwargs = dict (backend_kwargs or {})
124+ existing = dict (backend_kwargs .get ("sampling_args" ) or {})
125+ existing .update (sampling_args )
126+ backend_kwargs ["sampling_args" ] = existing
127+ if sub_sampling_args is not None :
128+ if other_backends is None :
129+ other_backends = [backend ]
130+ other_backend_kwargs = [dict (backend_kwargs or {})]
131+ else :
132+ other_backend_kwargs = [
133+ dict (kw or {}) for kw in (other_backend_kwargs or [{}])
134+ ]
135+ first = dict (other_backend_kwargs [0 ])
136+ existing = dict (first .get ("sampling_args" ) or {})
137+ existing .update (sub_sampling_args )
138+ first ["sampling_args" ] = existing
139+ other_backend_kwargs [0 ] = first
140+
112141 # Store config for spawning per-completion
113142 self .backend = backend
114143 self .backend_kwargs = backend_kwargs
@@ -144,6 +173,7 @@ def __init__(
144173 self .max_tokens = max_tokens
145174 self .max_errors = max_errors
146175 self .system_prompt = custom_system_prompt if custom_system_prompt else RLM_SYSTEM_PROMPT
176+ self .orchestrator = orchestrator
147177 self .logger = logger
148178 self .verbose = VerbosePrinter (enabled = verbose )
149179
@@ -276,6 +306,7 @@ def _setup_prompt(
276306 query_metadata = metadata ,
277307 custom_tools = self .custom_tools ,
278308 root_prompt = root_prompt ,
309+ orchestrator = self .orchestrator ,
279310 )
280311 if self .compaction :
281312 message_history [0 ]["content" ] += (
0 commit comments