Skip to content

fix: persist pre_fix_sha, add agent output limit, fix crash bugs#75

Merged
chanakyav merged 1 commit intomainfrom
fix/issues-22-23-crash-bugs
Mar 25, 2026
Merged

fix: persist pre_fix_sha, add agent output limit, fix crash bugs#75
chanakyav merged 1 commit intomainfrom
fix/issues-22-23-crash-bugs

Conversation

@chanakyav
Copy link
Copy Markdown
Owner

Summary

Addresses three issues in one PR: crash-resilient SHA persistence (#23), agent output OOM prevention (#22), and five high-severity crash bugs at system boundaries (#73).

Changes

Issue #23 — Persist pre_fix_sha for crash recovery

  • persistence.py: Schema v6 to v7. Added pre_fix_sha TEXT column, migration entry, _TASK_COLUMNS entry.
  • orchestrator.py: _do_fix() and _do_fix_ci() now persist pre_fix_sha via update_task(). _do_verify_push() reads from self.task.get("pre_fix_sha") with fallback to instance variable.

Before: If orchestrator crashed between FIX and VERIFY_PUSH, pre_fix_sha was lost. On resume, new_sha != None was always True — incorrectly passing verification.

Issue #22 — Agent output size limit (max_output_bytes)

  • config.py: New max_output_bytes config option (default: 50 MB, minimum: 1 MB).
  • agent.py: _stream_and_capture() stops writing to StringIO when limit is exceeded, but keeps streaming to terminal. Appends [OUTPUT TRUNCATED] marker.
  • orchestrator.py: Passes max_output_bytes from config to run_agent().

Before: A runaway agent printing large output could fill RAM with no cap on the StringIO buffer.

Issue #73 — High-severity crash bug fixes

  1. config.py: json.load() on malformed config now raises ValueError with file path and parse details instead of raw JSONDecodeError.
  2. github_api.py: get_issue() wraps json.loads() — raises GitHubAPIError on parse failure.
  3. github_api.py: get_pr_description() — same pattern.
  4. cli.py: cmd_start --issue catches GitHubAPIError, prints error, exits 1.
  5. cli.py: Prompt file open() catches PermissionError/OSError, prints error, exits 1.

Tests Added (12 new)

  • test_pre_fix_sha_persists + migration test updated (test_persistence.py)
  • test_output_truncated_when_limit_exceeded (test_agent.py)
  • test_output_not_truncated_when_under_limit (test_agent.py)
  • test_output_unlimited_when_zero (test_agent.py)
  • test_validation_max_output_bytes (test_config.py)
  • test_max_output_bytes_default (test_config.py)
  • test_malformed_json_config_file (test_config.py)
  • test_issue_fetch_failure_exits (test_cli.py)
  • test_file_permission_error_exits (test_cli.py)
  • test_invalid_json_raises_api_error for get_issue (test_github_api.py)
  • test_invalid_json_raises_api_error for get_pr_description (test_github_api.py)

Verification

  • ruff check src/ tests/ — zero errors
  • pytest tests/ — 283 tests passed, zero failures, no regressions

Closes #22, Closes #23, Closes #73


🤖 autopilot-loop

- Issue #23: Persist pre_fix_sha to DB for crash recovery (schema v7)
- Issue #22: Add max_output_bytes config to cap agent output capture
- Issue #73: Fix 5 high-severity crash bugs at system boundaries
  - config.py: handle malformed JSON config files
  - github_api.py: handle JSON parse errors in get_issue/get_pr_description
  - cli.py: catch GitHubAPIError in cmd_start --issue
  - cli.py: catch PermissionError when reading prompt files

Closes #22, Closes #23, Closes #73
@chanakyav chanakyav merged commit b2d8f1b into main Mar 25, 2026
3 checks passed
@chanakyav chanakyav deleted the fix/issues-22-23-crash-bugs branch March 25, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High-severity crash bugs at system boundaries Persist pre_fix_sha to database for crash recovery Add agent output size limit to prevent OOM

1 participant