fix(issue-36): the legacy shell loop and lib.sh's submit helpers pass prompts by file

The two remaining exec points that carried a prompt as one argv string
(capped at 131,072 bytes):

- run_loop.sh (MAM_LOOP_PY=0): delegate_job_safe, which all eleven shell
  delegations go through, turns `--prompt <text>` into `--prompt-file` under
  the control root's .mam/ and removes the file once the wrapper returns. Its
  failure lines go to stderr: callers capture stdout, and under set -e a
  failed submit ends the loop at that line with the wrapper's code, so the
  cause was being swallowed.
- lib.sh delegate_submit_job and its legacy twin (create_session's onboarding
  and --submit-job): the prompt is written under .mam/ and handed on as
  --prompt-file; lib_py.delegation.cli submit accepts --prompt-file and
  forwards it to the registry. --prompt keeps working everywhere.

S6/S6b push a 140,000-byte prompt through the CLI and both helpers; S7 runs
the real run_loop.sh with a 140,000-byte plan and a 150,000-byte diff; S7b
fixes a nonzero exit when the implementation or compliance job cannot be
registered. All six fail on 14d11bf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-09-24 06:08:25 +00:00
1 parent 14d11bf062
commit f26952ccc3
4 files changed
+189 -15

No files matched your search

@@ -187,14 +187,36 @@ _mam_release_guard() {
# Runs the delegate-job wrapper from the frozen skills tree (REPO_ROOT).
# Stage 2 creates a single snapshot at loop initialization outside the skill tree (B-13),
# keeping the running loop immune across turns without per-call copies or tree pollution (B-6).
#
# Issue #36: a `--prompt <text>` argument is handed to the wrapper as
# `--prompt-file <path>` instead - one argv string is capped at 131,072 bytes
# and a review prompt carries the whole diff. The file lives under the control
# root's .mam/ and is removed once the wrapper returns (it blocks until the
# job ends, so nothing reads the file afterwards).
delegate_job_safe() {
local wrapper_script="$REPO_ROOT/.agents/skills/multi-agent-mux-delegate-job/multi-agent-mux-delegate-job"
local rc=0
bash "$wrapper_script" "$@" || rc=$?
local rc=0 prompt_file="" args=()
while [ $# -gt 0 ]; do
if [ "$1" = "--prompt" ] && [ $# -ge 2 ]; then
mkdir -p "$MAM_REAL_ROOT/.mam" \
&& prompt_file="$(mktemp "$MAM_REAL_ROOT/.mam/prompt-shloop-XXXXXX")" \
&& printf '%s' "$2" > "$prompt_file" \
|| { log_error "delegate_job_safe: cannot write the prompt file under $MAM_REAL_ROOT/.mam"; return 1; }
args+=(--prompt-file "$prompt_file")
shift 2
else
args+=("$1")
shift
fi
done
bash "$wrapper_script" ${args[@]+"${args[@]}"} || rc=$?
[ -n "$prompt_file" ] && rm -f "$prompt_file"
if [ "$rc" -ne 0 ]; then
log_error "delegate_job_safe failed (exit $rc): $wrapper_script"
log_error " if this loop edits framework skills in place, check that file's syntax:"
log_error " bash -n \"$wrapper_script\""
# stderr: callers capture stdout with $(...), and under set -e a failed
# submit ends the loop right there - this line is the only cause shown.
log_error "delegate_job_safe failed (exit $rc): $wrapper_script" >&2
log_error " if this loop edits framework skills in place, check that file's syntax:" >&2
log_error " bash -n \"$wrapper_script\"" >&2
fi
return $rc
}