feat: Allow passing a custom timeout to `opencode run`
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.
With a sufficient timeout, no error.
Without any custom timeout, no error.
EDIT
I just added support for timeout units (like --timeout 60s). If no unit is provided, ms is assumed.
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).
Do u still think this makes sense even with OPENCODE_CONFIG, OPENCODE_CONFIG_CONTENT, and existing opencode configs that let u specify timeout?
@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 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.
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! :)
All done, I updated the PR description with new behavior examples.
@actions-user, why you create conflicts?
haha the stats auto update is running on your fork, there may be a way to disable that? Idk
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 ^^
@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 🥺