Skip to content

fix(fork,shell_safety): actionable override hint and blank-error crash - #31

Open
12britz wants to merge 1 commit into
mpfaffenberger:mainfrom
12britz:fix/fork-empty-error-and-shell-safety-hint
Open

fix(fork,shell_safety): actionable override hint and blank-error crash#31
12britz wants to merge 1 commit into
mpfaffenberger:mainfrom
12britz:fix/fork-empty-error-and-shell-safety-hint

Conversation

@12britz

@12britz 12britz commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Two small reliability fixes, each with a regression test:

1. fork — blank-error crash hides the failure (fixes #30)

fork/register_callbacks.py:282:

first_line = str(result.error).strip().splitlines()[0]

When a fork's result carries an empty/whitespace error, splitlines() returns [] and [0] raised IndexError. The blanket except swallowed it, so the fork was marked failed with no error message at all.

Now falls back to the raw error string when there is no first line, and lets the _emit_error actually run.

2. shell_safety — override hint is a guaranteed no-op (fixes #25)

The safety callback only ever runs while yolo_mode is already true — it returns None silently otherwise. Yet all three blocking messages told the agent to /set yolo_mode true, wasting a turn. All three now point only at the setting that actually changes behavior.

The exception path was worse: it declared risk HIGH and suggested raising safety_permission_level to high — the level of the very command that could not be assessed — defeating fail-closed. It now explains the assessment failed and points at manual review instead.

Tests

  • tests/test_fork_plugin.pytest_fork_reports_blank_error_without_crashing
  • tests/test_shell_safety_override_hint.py — new suite asserting the hint never suggests yolo_mode true and the fault path never raises permission to the fault level
  • ruff check + ruff format --check clean
  • 38 tests across the touched suites pass

fork: a failed fork whose result error is empty/whitespace crashed the
failure banner with IndexError (str(error).strip().splitlines()[0] on an
empty string). The blanket except then swallowed the failure, so the user
got no error text at all. Fall back to the raw error when there is no
first line, and let the emit actually run.

shell_safety: the blocked-command hint told the agent to '/set yolo_mode
true', but the callback only ever runs while yolo_mode is already on — a
guaranteed no-op that wasted a turn. All three blocking messages now point
only at the setting that actually changes behavior. The exception path is
also fixed: it suggested raising safety_permission_level to the level of
the very command that could not be assessed, defeating fail-closed; it now
explains the assessment failed and points at manual review instead.

Includes regression tests for both fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant