@@ -136,6 +136,8 @@ def _build_argv(self, task: str) -> List[str]:
136136 cli_args .extend (['--agent' , self .agent_id ])
137137 if self ._cli_session_id :
138138 cli_args .extend (['--session-id' , self ._cli_session_id ])
139+ if self .timeout :
140+ cli_args .extend (['--timeout' , str (self .timeout )])
139141 cli_args .extend (self .extra_args )
140142
141143 if self .nvm_dir :
@@ -187,25 +189,32 @@ def _write_openclaw_config(self) -> None:
187189 }
188190 ]
189191
192+ provider_config = {
193+ 'baseUrl' : base_url ,
194+ 'apiKey' : '$OPENAI_API_KEY' ,
195+ 'api' : os .environ .get ('OPENCLAW_PROVIDER_API' , 'openai-completions' ),
196+ 'models' : [
197+ {
198+ 'id' : self .model ,
199+ 'name' : self .model ,
200+ 'reasoning' : True ,
201+ 'input' : ['text' ],
202+ 'contextWindow' : int (os .environ .get ('OPENCLAW_CONTEXT_WINDOW' , '128000' )),
203+ 'maxTokens' : int (os .environ .get ('OPENCLAW_MAX_TOKENS' , '16384' )),
204+ }
205+ ],
206+ }
207+ # OpenClaw aborts a model request when no response chunks arrive before the idle window.
208+ # https://docs.openclaw.ai/concepts/agent-loop#timeouts
209+ provider_timeout = os .environ .get ('OPENCLAW_PROVIDER_TIMEOUT_SECONDS' , "1200" )
210+ if provider_timeout :
211+ provider_config ['timeoutSeconds' ] = int (provider_timeout )
212+
190213 config = {
191214 'models' : {
192215 'mode' : 'merge' ,
193216 'providers' : {
194- self .provider : {
195- 'baseUrl' : base_url ,
196- 'apiKey' : '$OPENAI_API_KEY' ,
197- 'api' : os .environ .get ('OPENCLAW_PROVIDER_API' , 'openai-completions' ),
198- 'models' : [
199- {
200- 'id' : self .model ,
201- 'name' : self .model ,
202- 'reasoning' : True ,
203- 'input' : ['text' ],
204- 'contextWindow' : int (os .environ .get ('OPENCLAW_CONTEXT_WINDOW' , '128000' )),
205- 'maxTokens' : int (os .environ .get ('OPENCLAW_MAX_TOKENS' , '16384' )),
206- }
207- ],
208- }
217+ self .provider : provider_config ,
209218 },
210219 },
211220 'agents' : agents ,
0 commit comments