Skip to content

Deal with errors better#7

Open
neil-hiverge wants to merge 3 commits into
mainfrom
neil/error_events
Open

Deal with errors better#7
neil-hiverge wants to merge 3 commits into
mainfrom
neil/error_events

Conversation

@neil-hiverge

@neil-hiverge neil-hiverge commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This PR improves the error handling in the daemon server.

See also this PR: https://github.com/hiverge/hiverge/pull/553

@hiverge-robot hiverge-robot added needs-triage Indicates an issue or PR lacks a label and requires one. needs-priority Indicates a PR lacks a label and requires one. do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Jul 9, 2026
@neil-hiverge neil-hiverge marked this pull request as ready for review July 10, 2026 01:14
@neil-hiverge neil-hiverge requested a review from Copilot July 10, 2026 01:14
@neil-hiverge

Copy link
Copy Markdown
Collaborator Author

/kind cleanup

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves how evaluator execution failures are surfaced to API callers by refining run_command error reporting and avoiding accidental double-wrapping of execution errors.

Changes:

  • Add last_output_lines (and a max-tail constant) to include a focused tail of evaluator output in non-zero-exit errors.
  • Update run_command to distinguish signal termination vs non-zero exit, handle “no output” cleanly, and improve the timeout message.
  • Update execute_python_function to re-raise the original FunctionExecutionError instead of wrapping it, and add a new common_tools test suite.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
main.py Stops wrapping FunctionExecutionError again when checkpoint retrieval fails.
common_tools.py Adds output-tail helper and improves run_command error handling/messages.
common_tools_test.py Introduces tests covering success, non-zero exit, signal termination, timeout, and output-tail behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.py
Comment thread common_tools.py
Comment on lines +56 to +57
source = stderr if stderr.strip() else stdout
return "\n".join(source.strip().splitlines()[-max_lines:])
Comment thread common_tools.py
lines = stdout.strip().splitlines()
if not lines:
# Exited cleanly but printed nothing, so there is no result to parse.
raise FunctionExecutionError("Evaluator Format Error: No output was written.")
Comment thread common_tools.py
except subprocess.TimeoutExpired as exc:
process.kill()
raise FunctionExecutionError("Timeout") from exc
raise FunctionExecutionError(f"Evaluation timed-out after {timeout} seconds.") from exc
Comment thread common_tools_test.py
Comment on lines +74 to +77
"""
A command killed by a signal reports the signal with an execution-failed
prefix.
"""
@hiverge-robot hiverge-robot added cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Jul 10, 2026
@neil-hiverge

Copy link
Copy Markdown
Collaborator Author

/hold

@hiverge-robot hiverge-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 10, 2026

@kerry-hiverge kerry-hiverge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! one small comment

Comment thread common_tools.py
the evaluator produced no output at all.
"""
source = stderr if stderr.strip() else stdout
return "\n".join(source.strip().splitlines()[-max_lines:])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it could be useful to show both the stderr and stdout if both are present, e.g., the stdout could give useful context about where the program was up to before it crashed. we could present the last few lines of both if both are nonempty perhaps

@neil-hiverge

Copy link
Copy Markdown
Collaborator Author

Clean test run now:

================================================================= 11 passed in 126.41s (0:02:06) =================================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-priority Indicates a PR lacks a label and requires one. needs-triage Indicates an issue or PR lacks a label and requires one. risk/medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants