feat(issue-34): a job records its parent; submit --parent-job (MAM_JOB_ID by default) and the brief tells the agent to pass it on
- registry: parent_job field, register --parent-job fails closed on an unknown parent, children_of/descendants_of, list --parent - wrapper: --parent-job; $MAM_JOB_ID default (ignored with a warning when this registry lacks it); brief line and one sentence at the end of the injected instructions - create_session: the onboarding instructions carry the same sentence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a4a0c2091
commit
ec663a93c8
3 files changed
+78
-6
No files matched your search
@@ -98,11 +98,12 @@ _pub_cmd() {
|
||||
}
|
||||
|
||||
# _instructions <pub> [iteration]: the prompt injected into the agent (direct
|
||||
# and loop jobs share it; test18 pins parts of this wording).
|
||||
# and loop jobs share it; test18 pins parts of this wording, so Issue #34's
|
||||
# sub-delegation sentence goes at the end).
|
||||
_instructions() {
|
||||
local pub="$1" iter="${2:-}" brief="$REGISTRY_DIR/$JOB_ID/brief.md"
|
||||
printf 'Your job_id is "%s". Detailed task requirements, instructions, and target output paths%s are documented in the task brief file at: %s. Please READ and follow %s to complete your work. Commands: start='"'"'%s --event started --heartbeat %s'"'"' (run it FIRST, within %s s; it also starts an automatic heartbeat timer), success='"'"'%s --event completed --detail <summary>'"'"', error='"'"'%s --event error --detail <reason>'"'"'.' \
|
||||
"$JOB_ID" "${iter:+ for iteration $iter}" "$brief" "$brief" "$pub" "$HEARTBEAT_SEC" "$ACK_TIMEOUT" "$pub" "$pub"
|
||||
printf 'Your job_id is "%s". Detailed task requirements, instructions, and target output paths%s are documented in the task brief file at: %s. Please READ and follow %s to complete your work. Commands: start='"'"'%s --event started --heartbeat %s'"'"' (run it FIRST, within %s s; it also starts an automatic heartbeat timer), success='"'"'%s --event completed --detail <summary>'"'"', error='"'"'%s --event error --detail <reason>'"'"'. If you delegate any part of this work with multi-agent-mux-delegate-job submit, add --parent-job %s so the orchestrator waits for it.' \
|
||||
"$JOB_ID" "${iter:+ for iteration $iter}" "$brief" "$brief" "$pub" "$HEARTBEAT_SEC" "$ACK_TIMEOUT" "$pub" "$pub" "$JOB_ID"
|
||||
}
|
||||
|
||||
usage() {
|
||||
@@ -115,7 +116,11 @@ multi-agent-mux-delegate-job <command> [options]
|
||||
[--registry-dir <dir>] [--dry-run] [--role <role_name>]
|
||||
[--type <direct|loop|discuss>] [--reviewer <reviewer_agent>]
|
||||
[--reviewer-session <reviewer_session>] [--max-iterations <count>]
|
||||
[--counterpart-role <role_name>] [--strict-role-check]
|
||||
[--counterpart-role <role_name>] [--strict-role-check] [--parent-job <id>]
|
||||
# --parent-job names the job this one is delegated from, so a loop
|
||||
# waiting on that job waits for this one too (Issue #34). It must
|
||||
# exist in the registry. Default: $MAM_JOB_ID (set by the remote
|
||||
# runner), ignored with a warning when the registry lacks it.
|
||||
# --prompt-file passes the prompt by file: one argv string is capped
|
||||
# at 131,072 bytes on Linux (Issue #36). The file is read, not kept.
|
||||
# --agent-session herdr:<name> injects into a local herdr pane;
|
||||
@@ -144,6 +149,7 @@ COUNTERPART_ROLE="$DEFAULT_COUNTERPART_ROLE"
|
||||
STRICT_ROLE_CHECK=0
|
||||
ROLE_ALIASES_JSON='{"worker": ["worker", "creator"], "planner": ["planner"], "reviewer": ["reviewer"]}'
|
||||
COUNTERPART_ROLE_EXPLICIT=0
|
||||
PARENT_JOB=""
|
||||
|
||||
parse_opts() {
|
||||
while [[ $# -gt 0 ]]; do
|
||||
@@ -169,6 +175,7 @@ parse_opts() {
|
||||
--max-iterations) MAX_ITERATIONS="$2"; shift 2;;
|
||||
--counterpart-role) COUNTERPART_ROLE="$2"; COUNTERPART_ROLE_EXPLICIT=1; shift 2;;
|
||||
--strict-role-check) STRICT_ROLE_CHECK=1; shift;;
|
||||
--parent-job) PARENT_JOB="$2"; shift 2;;
|
||||
*) echo "unknown option: $1" >&2; usage; exit 1;;
|
||||
esac
|
||||
done
|
||||
@@ -204,6 +211,20 @@ cmd_submit() {
|
||||
_abs_registry_dir
|
||||
LOGS_DIR_ABS="$(_logs_dir_abs 2>/dev/null || true)"
|
||||
|
||||
# Issue #34: an explicit --parent-job fails closed in the registry; the
|
||||
# $MAM_JOB_ID default may name a job of another host's registry (a remote
|
||||
# mirror), so it is only used when this registry has it.
|
||||
local reg_parent=()
|
||||
if [[ -n "$PARENT_JOB" ]]; then
|
||||
reg_parent=(--parent-job "$PARENT_JOB")
|
||||
elif [[ -n "${MAM_JOB_ID:-}" ]]; then
|
||||
if [[ -f "$REGISTRY_DIR/$MAM_JOB_ID.json" ]]; then
|
||||
PARENT_JOB="$MAM_JOB_ID"; reg_parent=(--parent-job "$PARENT_JOB")
|
||||
else
|
||||
echo "WARNING: MAM_JOB_ID=$MAM_JOB_ID is not in $REGISTRY_DIR; registering without a parent job" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# 1) register job (prints the new job id)
|
||||
JOB_ID="$("$PY" "$SCRIPT_DIR/scripts/registry.py" --registry-dir "$REGISTRY_DIR" register \
|
||||
"${reg_prompt[@]}" --agent "$AGENT" --agent-session "$AGENT_SESSION" --role "$DELEGATE_ROLE" \
|
||||
@@ -211,7 +232,7 @@ cmd_submit() {
|
||||
--heartbeat-sec "$HEARTBEAT_SEC" --heartbeat-misses "$HEARTBEAT_MISSES" --ack-timeout "$ACK_TIMEOUT" \
|
||||
--transport "$(_is_remote "$AGENT_SESSION" && echo remote || echo herdr)" \
|
||||
--job-type "$TYPE" --reviewer "$REVIEWER" --reviewer-session "$REVIEWER_SESSION" \
|
||||
--max-iterations "$MAX_ITERATIONS")"
|
||||
--max-iterations "$MAX_ITERATIONS" ${reg_parent[@]+"${reg_parent[@]}"})"
|
||||
echo "registered job: $JOB_ID"
|
||||
|
||||
# 1-1) Provision job directory and write direct brief.md (MAM Job Restructuring)
|
||||
@@ -227,6 +248,7 @@ cmd_submit() {
|
||||
- **Timeout**: $TIMEOUT s (Idle: $IDLE_TIMEOUT s)
|
||||
- **Liveness contract**: heartbeat every $HEARTBEAT_SEC s (automatic once you publish \`started --heartbeat $HEARTBEAT_SEC\`), unresponsive after $HEARTBEAT_MISSES missed heartbeats, \`started\` expected within $ACK_TIMEOUT s
|
||||
- **Output Report Path**: $REGISTRY_DIR/$JOB_ID/$AGENT-reports/report-final.md
|
||||
- **Parent for sub-delegations**: pass \`--parent-job $JOB_ID\` to \`multi-agent-mux-delegate-job submit\`
|
||||
|
||||
## 🔎 Task Description
|
||||
$PROMPT
|
||||
@@ -402,6 +424,7 @@ EOF
|
||||
- **Iteration**: $iteration
|
||||
- **Liveness contract**: heartbeat every $HEARTBEAT_SEC s (automatic once you publish \`started --heartbeat $HEARTBEAT_SEC\`), unresponsive after $HEARTBEAT_MISSES missed heartbeats, \`started\` expected within $ACK_TIMEOUT s
|
||||
- **Output Report Path**: $REGISTRY_DIR/$JOB_ID/${clean_session}-reports/report-final.md
|
||||
- **Parent for sub-delegations**: pass \`--parent-job $JOB_ID\` to \`multi-agent-mux-delegate-job submit\`
|
||||
|
||||
## 🔎 Task Description
|
||||
$current_prompt
|
||||
|
||||
Reference in new issue
Block a user