opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: Allow passing a custom timeout to `opencode run`

Open AurelienRibon opened this issue 2 months ago • 10 comments

Some models, like gpt-5-pro, can think for way longer than the default 5 minutes timeout. This PR allows the customization of this parameter, with a new --timeout argument passed to opencode run.

Does it work?

With a small timeout, we get a TimeoutError from fetch, as expected. image

With a sufficient timeout, no error. image

Without any custom timeout, no error. image

EDIT

I just added support for timeout units (like --timeout 60s). If no unit is provided, ms is assumed.

AurelienRibon avatar Oct 28 '25 09:10 AurelienRibon

I changed the proposition to a constant-based approach, which is less intrusive (does not appear in help, does not introduce new params to existing functions).

This PR is still required for gpt-5-pro to work, as the current state of the tool prevents the model from completing its work (most complex questions require ~10mins to complete, some can go to 20mins).

AurelienRibon avatar Oct 29 '25 08:10 AurelienRibon

Do u still think this makes sense even with OPENCODE_CONFIG, OPENCODE_CONFIG_CONTENT, and existing opencode configs that let u specify timeout?

rekram1-node avatar Oct 30 '25 02:10 rekram1-node

@AurelienRibon okay someone else asked for it: https://github.com/sst/opencode/issues/3583

Can we make it a flag for the run command and drop the env var?

rekram1-node avatar Oct 30 '25 17:10 rekram1-node

@rekram1-node hey, sorry I took a day off with the wife and kid. I initially made it a flag, so I will just roll-back the latest changes to restore the flag behavior. Will do that tomorrow, you'll tell me if the result is fine.

Only question I had in my mind when it was a CLI argument: what should it be named? I chose --timeout initially for simplicity, but that could be ambiguous, as it's the timeout for one model request, not the entire opencode run loop. I'll go with --timeout, but if you have a better idea in the meantime, just say.

AurelienRibon avatar Oct 30 '25 18:10 AurelienRibon

timeout is good, and hey no worries dont worry about being super responsive family takes priority and u are doing this for fun hope im not coming off as needing u to do things immediately! :)

rekram1-node avatar Oct 30 '25 18:10 rekram1-node

All done, I updated the PR description with new behavior examples.

AurelienRibon avatar Oct 31 '25 11:10 AurelienRibon

@actions-user, why you create conflicts?

image image

AurelienRibon avatar Nov 03 '25 14:11 AurelienRibon

haha the stats auto update is running on your fork, there may be a way to disable that? Idk

rekram1-node avatar Nov 04 '25 15:11 rekram1-node

haha the stats auto update is running on your fork, there may be a way to disable that? Idk

@rekram1-node Probably because I'm working from dev instead of a custom branch. No problem, let's just merge that PR when possible ^^

AurelienRibon avatar Nov 04 '25 17:11 AurelienRibon

@rekram1-node Can this be merged? We desperately need it for gpt-5-pro to be useable for OpenCode in CLI mode. With the default timeout, the model times out if it gets something challenging to do (and it's purpose is to answer challenging questions). For advanced science, this is mandatory 🥺

AurelienRibon avatar Nov 05 '25 14:11 AurelienRibon