The verification helpers (_is_parent_issue, _are_all_sub_issues_closed,
_get_sub_issue_list) and label/comment helpers (_label_id, _add_label,
_remove_label, _post_comment) were defined after the code that calls
them. Under set -euo pipefail, this causes a runtime crash.
Move all helper function definitions to right after the Claude session
completes, before the triage post-processing and verification blocks
that use them.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add an EXIT trap in entrypoint-reproduce.sh that:
- Switches back to the primary branch
- Deletes the triage-debug-${ISSUE_NUMBER} branch
This ensures the throwaway branch used for debug instrumentation
(console.log, verbose logging) is cleaned up if the agent crashes
or times out, preventing repository pollution.
The trap is combined with existing cleanup (heartbeat kill, stack
lock release) into a single EXIT handler.