fix: fix task nonstopping error if model key is expired#1017
fix: fix task nonstopping error if model key is expired#1017
Conversation
|
some questions:
|
|
@LuoPengcheng12138 Updated with model validation at first. |
hi, @bytecraftii Merge is good to go now. One more thing: we need to remove the Python pre-commit hook, as Wendong pointed out that we’re making a large number of updates to the project right now, and adding changes like linting rules will make PR reviews much more difficult. |
For now the pre-commit will not be automatically run, need to be trigger manually. Also I do think try to make the code cleaner will help to make the code review life easier in the long run. |
| # Make a simple test call in executor to avoid blocking | ||
| loop = asyncio.get_event_loop() |
There was a problem hiding this comment.
Can we change to get_running_loop()? Since get_event_loop() is about deprecation
| mock_agent.step = Mock( | ||
| side_effect=Exception("Error code: 429 - Rate limit exceeded") |
There was a problem hiding this comment.
Should we treat rate limit as invalid signal? I think rate limit is temporal
| await loop.run_in_executor(None, lambda: agent.step("test")) | ||
|
|
There was a problem hiding this comment.
Should we also add a timeout in external? like:
try:
await asyncio.wait_for(
loop.run_in_executor(None, lambda: agent.step("test")),
timeout=30.0
)
except asyncio.TimeoutError:
return False, "timed out"
Wendong-Fan
left a comment
There was a problem hiding this comment.
thanks @bytecii ! I think this validation may be doing duplicate work. We already validate the model configuration via /model/validate on the settings page before users start tasks, so adding this would introduce extra latency to every task.
the root cause is in question_confirm when an API error occurs, the exception handler does return True instead of propagating the error. This silently swallows the failure and allows the task to continue running.
A much simpler fix would be to change that return True to raise. This lets the error bubble up to the main loop and be sent back to the frontend via SSE, no additional validation step required, WDYT?
|
added enhance PR #1170 based on review, feel free to check |
|
@Wendong-Fan Ok sounds good |
Description
Validate the model before the task starts and shows the errors if the basic validation fails.
Examples:
Fixes #1010
Fixes #1034
What is the purpose of this pull request?