Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
refactor(daemon): de-duplicate cross-section rules in the runtime brief (MUL-5442) (#6302)
Bohan Jiang3c6176cbcdf1
diff --git a/server/internal/daemon/execenv/execenv_test.go b/server/internal/daemon/execenv/execenv_test.goindex b209507291..ccec3669ad 100644--- a/server/internal/daemon/execenv/execenv_test.go+++ b/server/internal/daemon/execenv/execenv_test.go@@ -1078,13 +1078,34 @@ func TestInjectRuntimeConfigAvailableCommandsCoreOnly(t *testing.T) {"multica issue status <id> <status>","multica issue comment add <issue-id>","multica issue comment add --help",- "multica squad member set-role <squad-id>",} {if !strings.Contains(s, want) {t.Errorf("AGENTS.md missing core command/help text %q\n---\n%s", want, s)}}+ // Squad maintenance is squad-leader surface and is gated on that (MUL-5442):+ // an agent leading no squad has no squad whose roles it could change.+ if strings.Contains(s, "### Squad maintenance") {+ t.Errorf("non-leader brief must not carry the squad maintenance block\n---\n%s", s)+ }+ leaderDir := t.TempDir()+ if _, err := InjectRuntimeConfig(leaderDir, "codex", TaskContextForEnv{IssueID: "issue-1", IsSquadLeader: true}); err != nil {+ t.Fatalf("InjectRuntimeConfig failed: %v", err)+ }+ leader, err := os.ReadFile(filepath.Join(leaderDir, "AGENTS.md"))+ if err != nil {+ t.Fatalf("failed to read leader AGENTS.md: %v", err)+ }+ for _, want := range []string{+ "### Squad maintenance",+ "multica squad member set-role <squad-id>",+ } {+ if !strings.Contains(string(leader), want) {+ t.Errorf("squad-leader AGENTS.md missing %q\n---\n%s", want, leader)+ }+ }+for _, banned := range []string{"multica issue list [--status","multica issue label list",@@ -4953,9 +4974,12 @@ func TestInjectRuntimeConfigMentionLoopHardening(t *testing.T) {t.Run("workflow-carries-silence-as-exit-and-no-signoff-mention", func(t *testing.T) {t.Parallel()s := readClaudeMD(t, commentTriggerCtx)- // The anti-loop signal for CLAUDE.md lives in the numbered workflow- // steps (4 + 5), not in a dedicated preamble. Lock in the key phrases- // so the signal can't decay back into pure prose again.+ // The anti-loop signal must reach the brief; lock in the key phrases so+ // it can't decay back into pure prose again. The reply-warranted rules+ // live in the Reply mode block, while the no-sign-off-mention rule is+ // mention policy and lives in `## Mentions` (MUL-5442) — these+ // assertions are file-wide on purpose, so the signal is pinned without+ // pinning which section carries it.for _, want := range []string{"Decide whether a reply is warranted","Silence is a valid and preferred way",@@ -5608,7 +5632,7 @@ func TestInjectRuntimeConfigIssueMetadataSectionScope(t *testing.T) {"high-signal scratchpad","**Read on entry.**","**Write on exit.**",- "See the `## Issue Metadata` section above",+ "the bar in `## Issue Metadata`",},}@@ -5637,7 +5661,11 @@ func TestInjectRuntimeConfigIssueMetadataSectionScope(t *testing.T) {filename: "CLAUDE.md",workflowStepPresent: []string{"multica issue metadata list issue-md-1 --output json",- "See the `## Issue Metadata` section above",+ // Both steps point at the section instead of restating its+ // rules (MUL-5442); the entry step names what to look for,+ // the exit step names the write bar.+ "What to look for: `## Issue Metadata`",+ "the bar in `## Issue Metadata`",// Exit step must show both write and delete, not just// "set" — stale-key cleanup is the half that keeps// metadata from rotting.@@ -5654,7 +5682,8 @@ func TestInjectRuntimeConfigIssueMetadataSectionScope(t *testing.T) {filename: "CLAUDE.md",workflowStepPresent: []string{"multica issue metadata list issue-md-2 --output json",- "See the `## Issue Metadata` section above",+ "What to look for: `## Issue Metadata`",+ "the bar in `## Issue Metadata`","multica issue metadata set","multica issue metadata delete","Before exiting",diff --git a/server/internal/daemon/execenv/runtime_config_delivery_test.go b/server/internal/daemon/execenv/runtime_config_delivery_test.goindex 9b810ecc2d..eba2d3cc69 100644--- a/server/internal/daemon/execenv/runtime_config_delivery_test.go+++ b/server/internal/daemon/execenv/runtime_config_delivery_test.go@@ -117,6 +117,13 @@ func TestBriefSurfaceDeliveryPolicy(t *testing.T) {// TestBriefInboundAttachmentIsNotADeliverable locks the inbound half: a// downloaded attachment's local path is a private working copy, and the most// tempting one to echo back because it arrived from the conversation.+//+// The Attachments section owns that framing — it is what `## Output` cannot+// express, because Output does not know an attachment felt shared. The+// no-clickable-local-path rule itself belongs to Output and used to be restated+// here verbatim; MUL-5442 replaced the restatement with a pointer, so this test+// pins the framing plus the pointer and lets the delivery tests above own the+// rule.func TestBriefInboundAttachmentIsNotADeliverable(t *testing.T) {t.Parallel()@@ -125,12 +132,17 @@ func TestBriefInboundAttachmentIsNotADeliverable(t *testing.T) {})for _, want := range []string{"private working copy",- "Never echo it back into a deliverable as a link",+ "not something the reader can open",+ "the link rules in `## Output` apply to it too",} {if !strings.Contains(out, want) {t.Errorf("Attachments section missing %q\n---\n%s", want, out)}}+ // The rule the pointer defers to must actually be present in the brief.+ if !strings.Contains(out, "NEVER write an absolute path or a `file://` URL as a clickable link") {+ t.Errorf("Attachments points at ## Output but the rule is missing\n---\n%s", out)+ }}func TestChannelDisplayName(t *testing.T) {diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.goindex b99ea0267a..687a94e029 100644--- a/server/internal/daemon/execenv/runtime_config_sections.go+++ b/server/internal/daemon/execenv/runtime_config_sections.go@@ -78,28 +78,33 @@ func writeHeader(b *strings.Builder) {//// Bullet order is deliberate: run-owned rules first, then the persistent// service handoff and its negative boundary, then the external-systems / CI-// cluster, with the "standing by" ban last so it closes over all three. The-// former boundary sentence "The rules above apply only to work owned by the-// current run" was dropped in the MUL-5274 review: with the handoff exception-// inserted above it, "the rules above" would have swept in work that is-// precisely no longer run-owned. The external-systems bullet carries the-// boundary on its own ("are not agent-owned background tasks"). Within the CI-// cluster the exception bullet must stay below the ban bullet — the ban-// forward-references "the explicit exception below".+// cluster. The former boundary sentence "The rules above apply only to work+// owned by the current run" was dropped in the MUL-5274 review: with the+// handoff exception inserted above it, "the rules above" would have swept in+// work that is precisely no longer run-owned. The external-systems bullet+// carries the boundary on its own ("are not agent-owned background tasks").+// Within the CI cluster the exception bullet must stay below the ban bullet —+// the ban forward-references "the explicit exception below".+//+// MUL-5442 folds four bullets that restated one rule from different angles+// (end-of-turn ban, untrustworthy tool promises, unobservable results, the+// "standing by" sign-off) into the leading bullet. They were four views of+// "the turn ending is the deadline", and separating them cost bytes without+// adding a distinct behaviour. Every pinned phrase is carried over verbatim.+// The sign-off ban now leads rather than closes the list; it still applies to+// the whole section because the opening bullet scopes it to ending a turn at+// all, not to any one later bullet.func writeBackgroundTaskSafetySlim(b *strings.Builder) {b.WriteString("## Background Task Safety\n\n")b.WriteString("Multica marks the task terminal the moment your top-level turn exits — any process, tool call, or subagent owned by this run that is still active is orphaned, its result lost, and the final comment you meant to post after it never sends. There is no background-completion wakeup here.\n\n")- b.WriteString("- Do NOT end your turn while background tasks or other work that still belongs to the current run is active, including async subagents, background shell commands, and detached tool calls. Never background-and-yield: never end a turn expecting a future notification or wakeup to resume — it will not arrive.\n")+ b.WriteString("- Do NOT end your turn while background tasks or other work that still belongs to the current run is active, including async subagents, background shell commands, and detached tool calls. Never background-and-yield: no future notification or wakeup will arrive to resume you. A tool response that says to wait for a future notification/reminder, or that it is running in the background so you can keep working, does not change that — block before exiting. If you can't observe a result, run the work synchronously instead, and never end a turn with a \"standing by\" / \"I'll report back when X finishes\" message: that becomes your final output and the task ends.\n")b.WriteString("- When a required result from run-owned work must be collected, wait synchronously inside one foreground tool call that blocks to completion (e.g. a blocking test or build command); never split \"start the wait\" and \"collect the result\" across turns.\n")- b.WriteString("- If a tool response says to wait for a future notification/reminder, or that it is running in the background so you can keep working, do not rely on that in Multica-managed runs — block on the appropriate wait / output / collect operation before exiting.\n")- b.WriteString("- If you can't observe a background task's result, run the work synchronously instead.\n")b.WriteString("- A user explicitly asking for a local development or test service to stay available after the turn is a persistent service handoff, not background-and-yield. Use it only when the running service itself is the requested deliverable, and hand off only once the service's lifecycle no longer depends on this run: stdio redirected to durable logs, an ownership and cleanup handle recorded (for example PID/profile). Then verify readiness before replying, and provide the URL, logs, and stop instructions. Leave no pending result or future wakeup. Without a supervisor, describe survival as best-effort, not guaranteed.\n")b.WriteString("- The persistent-service exception does not cover tests, builds, CI polling, monitors, or any other work whose completion the agent still owes; those remain run-owned, and the CI-specific rules below still apply.\n")b.WriteString("- External systems triggered by a completed action — for example GitHub Actions after a successful push — are not agent-owned background tasks. Do not wait for them by default; report them as pending and finish the handoff.\n")b.WriteString("- Concretely, after a push or a PR create, unless the explicit exception below applies: do NOT run `gh pr checks --watch`, `gh run watch`, or any sleep / retry loop that polls check status. Enabling auto-merge (`gh pr merge --auto`) is fine — it returns immediately; waiting for it to land is not. Take at most ONE non-blocking status snapshot (`gh pr checks <pr>` or `multica issue pull-requests <issue-id>`) and deliver the evidence you already have: \"Local tests pass (`go test ./...` / `pnpm test`); CI running: <PR link>\". A PR whose CI is still in flight is a complete hand-off.\n")b.WriteString("- A repo's merge requirements — \"CI must be green before merge\", required reviews, branch protection — are GitHub's merge gate, NOT your delivery acceptance criteria, and do not license a wait.\n")- b.WriteString("- The one exception: when the trigger comment or the issue's acceptance criteria explicitly ask you for the CI result, that result IS the deliverable — wait for it as ONE foreground blocking call (`gh pr checks <pr> --watch`) inside this same turn and report the outcome. Nothing else re-opens this door.\n")- b.WriteString("- Never end a turn with a \"standing by\" / \"I'll report back when X finishes\" message — that becomes your final output and the task ends.\n\n")+ b.WriteString("- The one exception: when the trigger comment or the issue's acceptance criteria explicitly ask you for the CI result, that result IS the deliverable — wait for it as ONE foreground blocking call (`gh pr checks <pr> --watch`) inside this same turn and report the outcome. Nothing else re-opens this door.\n\n")}// writeAgentIdentity emits the Agent Identity heading and (optionally) the@@ -252,23 +257,30 @@ func sanitizeBriefCodeToken(s string) string {// The fold-aware `--full` flag from MUL-3555 is documented inline on the// comment-list bullet so the slim brief preserves the same agent// behaviour as the legacy brief on that path.-func writeAvailableCommands(b *strings.Builder) {+func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {b.WriteString("## Available Commands\n\n")b.WriteString("Prefer `--output json` for structured data. The default brief lists only the core agent loop and common issue create/update tasks; for everything else run `multica --help` or `multica <command> --help`.\n\n")b.WriteString("### Core\n")b.WriteString("- `multica issue get <id> --output json` — full issue.\n")- b.WriteString("- `multica issue comment list <issue-id> [--roots-only] [--summary] [--thread <comment-id> [--tail N] | --recent N] [--before <ts> --before-id <uuid>] [--since <RFC3339>] [--full] --output json` — thread-aware comment reads. `--recent N` caps THREADS, not comments: every returned thread carries its root plus EVERY descendant with no per-thread cap, so on an issue with fewer than N root threads it hands you the entire history apart from the resolved threads it folds. `--roots-only` (top-level comments with `reply_count` + `last_activity_at`) and `--summary` (clip each body to a preview) are how you bound a wide read; `--thread <id> --tail N` is how you bound a deep one. Resolved threads come back folded by default on complete-thread reads (default list, `--recent`, `--thread` without `--tail`); pass `--full` to expand. Page older replies / threads with `--before`/`--before-id` (stderr labels: `Next reply cursor`, `Next thread cursor`); `--help` for full semantics.\n")- b.WriteString("- `multica issue create --title \"...\" [--description-file <path>] [--priority X] [--status X] [--assignee X | --assignee-id <uuid>] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <RFC3339>] [--attachment <path>]` — create an issue. For agent-authored long descriptions prefer `--description-file <path>` (heredoc stdin can swallow trailing flags, #4182). Write that file inside your working directory (e.g. `./description.md`), never `/tmp` or shared paths, and treat a failed write as fatal — the CLI rejects a path outside the workdir so a stale file from another run can't leak in (MUL-4252).\n")+ b.WriteString("- `multica issue comment list <issue-id> [--roots-only] [--summary] [--thread <comment-id> [--tail N] | --recent N] [--before <ts> --before-id <uuid>] [--since <RFC3339>] [--full] --output json` — thread-aware comment reads. `--recent N` caps THREADS, not comments: every returned thread carries its root plus EVERY descendant with no per-thread cap, so on an issue with fewer than N root threads it hands you the entire history apart from the resolved threads it folds. Bound a wide read with `--roots-only` (roots plus `reply_count` / `last_activity_at`) and `--summary` (bodies clipped to a preview); bound a deep one with `--thread <id> --tail N`. Resolved threads come back folded on complete-thread reads (default list, `--recent`, `--thread` without `--tail`); `--full` expands them. Page with `--before`/`--before-id` (stderr labels: `Next reply cursor`, `Next thread cursor`); `--help` for full semantics.\n")+ b.WriteString("- `multica issue create --title \"...\" [--description-file <path>] [--priority X] [--status X] [--assignee X | --assignee-id <uuid>] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <RFC3339>] [--attachment <path>]` — create an issue. For agent-authored long descriptions prefer `--description-file <path>` (heredoc stdin can swallow trailing flags, #4182). Write that file inside your working directory (e.g. `./description.md`), never `/tmp` or shared paths — same workdir rule as `## Comment Formatting`.\n")b.WriteString("- `multica issue update <id> [--title X] [--description-file <path>] [--priority X] [--status X] [--assignee X] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <RFC3339>]` — update fields; pass `--parent \"\"` to clear parent.\n")b.WriteString("- `multica issue status <id> <status>` — flip status (todo / in_progress / in_review / done / blocked / backlog / cancelled).\n")b.WriteString("- `multica issue children <id> [--output json]` — list a parent's sub-issues grouped by stage.\n")- b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file`. `multica issue comment add --help` for full flags.\n")+ b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file`; see `## Comment Formatting` for why. `multica issue comment add --help` for full flags.\n")b.WriteString("- `multica issue metadata list <issue-id> [--output json]` — list KV metadata.\n")b.WriteString("- `multica issue metadata set <issue-id> --key <k> --value <v> [--type string|number|bool]` — pin or overwrite a key.\n")b.WriteString("- `multica issue metadata delete <issue-id> --key <k>` — remove a key.\n")b.WriteString("- `multica repo checkout <url> [--ref <branch-or-sha>]` — repository checkout on a dedicated branch.\n\n")- b.WriteString("### Squad maintenance\n")- b.WriteString("- `multica squad member set-role <squad-id> --member-id <id> --member-type <agent|member> --role <role> [--output json]` — change role in place (use this instead of remove+add).\n\n")+ // Squad maintenance is squad-leader surface: an agent that leads no squad+ // has no squad to change roles in, so this shipped to every run as dead+ // weight (MUL-5442). IsSquadLeader is agent configuration, not per-run+ // state, so gating on it keeps the brief byte-stable across runs of one+ // session (MUL-5377) — the same reason the workflow already branches on it.+ if ctx.IsSquadLeader {+ b.WriteString("### Squad maintenance\n")+ b.WriteString("- `multica squad member set-role <squad-id> --member-id <id> --member-type <agent|member> --role <role> [--output json]` — change role in place (use this instead of remove+add).\n\n")+ }}// writeAvailableCommandsQuickCreate emits a minimal Available Commands@@ -365,11 +377,19 @@ func writeIssueMetadata(b *strings.Builder) {// writeInstructionPrecedence emits the "Agent Identity wins over the issue// workflow below" guardrail. Caller gates on kind == kindIssue.+//+// This section owns the single enumeration of the actions Agent Identity can+// forbid. It and workflow step 4 were added together in #3802 and each carried+// its own list; the lists then disagreed — this one named status changes, the+// step named issue create/update and delegation, and neither contained the+// other. MUL-5442 merges them here so adding an action type is a one-place+// edit. Step 4 keeps only what this section cannot express: the delegation-only+// role's "stop once the delegation is delivered" rule.func writeInstructionPrecedence(b *strings.Builder) {b.WriteString("## Instruction Precedence\n\n")b.WriteString("Agent Identity instructions have priority over the issue workflow below. ")b.WriteString("If a workflow step conflicts with Agent Identity, skip the conflicting action and continue with the remaining compatible steps. ")- b.WriteString("Never treat this runtime workflow as permission to change issue status, investigate, implement, or otherwise act beyond your Agent Identity.\n\n")+ b.WriteString("Never treat this runtime workflow as permission to change issue status, investigate, implement, create issues, update issues, delegate, or otherwise act beyond your Agent Identity.\n\n")}// SessionContinuityNotice warns the agent — and, through it, the user — when a@@ -494,15 +514,15 @@ func writeWorkflowIssue(b *strings.Builder, ctx TaskContextForEnv) {b.WriteString("**Steps 1–6 — both modes**\n\n")fmt.Fprintf(b, "1. Run `multica issue get %s --output json` to understand the issue context\n", ctx.IssueID)- fmt.Fprintf(b, "2. Run `multica issue metadata list %s --output json` to see what prior agents pinned — best-effort, empty `{}` and CLI failures are normal. See the `## Issue Metadata` section above for what to look for.\n", ctx.IssueID)- fmt.Fprintf(b, "3. Catch up on the comment history — this is mandatory, not optional, but read it in two bounded steps instead of one bulk pull. First scan every thread cheaply: `multica issue comment list %s --roots-only --summary --output json`, which tells you what discussion exists without paying for its contents. Then expand only the threads that matter: `multica issue comment list %s --thread <thread-id> --tail 30 --output json`. Earlier comments often carry context the issue body lacks (e.g. which repo to work in, the prior agent's findings, the reason the issue was reassigned to you). Skipping this step is the most common cause of agents acting on stale or incomplete instructions — so always run the scan, even when the trigger looks self-contained. In Reply mode the per-turn user message names the thread to expand first; the scan is how you decide whether any OTHER thread is also relevant. If these two reads genuinely are not enough, the rest of the read surface and its pagination cursors are documented once in `## Available Commands` above.\n", ctx.IssueID, ctx.IssueID)- b.WriteString("4. Complete the task within your Agent Identity boundaries. Do not investigate, implement, create issues, update issues, or delegate if your Agent Identity forbids that action; if your role is delegation-only, perform the allowed delegation work and stop once that outcome is delivered.\n")+ fmt.Fprintf(b, "2. Run `multica issue metadata list %s --output json` to see what prior agents pinned — best-effort, empty `{}` and CLI failures are normal. What to look for: `## Issue Metadata`.\n", ctx.IssueID)+ fmt.Fprintf(b, "3. Catch up on the comment history — this is mandatory, not optional — in two bounded reads, never one bulk pull. Scan every thread cheaply with `multica issue comment list %s --roots-only --summary --output json`, then expand only the threads that matter with `multica issue comment list %s --thread <thread-id> --tail 30 --output json`. Earlier comments often carry context the issue body lacks (e.g. which repo to work in, the prior agent's findings, the reason the issue was reassigned to you). Skipping this step is the most common cause of agents acting on stale or incomplete instructions — so always run the scan, even when the trigger looks self-contained. In Reply mode the per-turn user message names the thread to expand first; the scan is how you decide whether any OTHER thread is also relevant. Flag semantics and pagination: `## Available Commands`.\n", ctx.IssueID, ctx.IssueID)+ b.WriteString("4. Complete the task within your Agent Identity boundaries (`## Instruction Precedence` lists the actions Agent Identity can forbid). If your role is delegation-only, perform the allowed delegation work and stop once that outcome is delivered.\n")if ctx.IsSquadLeader {fmt.Fprintf(b, "5. **Post your final results as a comment** (unless your outcome is `no_action` — in that case, calling `multica squad activity %s no_action --reason \"...\"` alone is sufficient; you MUST exit without posting any comment. DO NOT post a comment announcing no_action or saying you are exiting silently): post it with `multica issue comment add %s` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). Your results are only visible to the user if posted via this CLI call; text in your terminal or run logs is NOT delivered.\n", ctx.IssueID, ctx.IssueID)} else {- fmt.Fprintf(b, "5. **Post your final results as a comment — this step is mandatory**: post it with `multica issue comment add %s` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). Your results are only visible to the user if posted via this CLI call; text in your terminal or run logs is NOT delivered. In Reply mode this step is conditional on the reply rule below.\n", ctx.IssueID)+ fmt.Fprintf(b, "5. **Post your final results as a comment — this step is mandatory**: post it with `multica issue comment add %s` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). `## Output` states why this call is the only delivery channel. In Reply mode this step is conditional on the reply rule below.\n", ctx.IssueID)}- b.WriteString("6. Before exiting: only if this run produced a fact that clears the high bar (important AND likely to be re-read by future runs on this same issue, e.g. a new PR URL or deploy URL), or you noticed a metadata key from entry that is now stale, pin or clear it via `multica issue metadata set`/`delete`. Most runs write nothing here — that is the expected outcome, not a gap. When in doubt, do not write. See the `## Issue Metadata` section above for the full bar.\n\n")+ b.WriteString("6. Before exiting, pin or clear a metadata key via `multica issue metadata set`/`delete` only if it clears the bar in `## Issue Metadata`. Most runs write nothing here — that is the expected outcome, not a gap. When in doubt, do not write.\n\n")b.WriteString("**Ownership mode only — you own the issue status this run**\n\n")fmt.Fprintf(b, "- Before step 4, run `multica issue status %s in_progress` unless your Agent Identity forbids issue status changes; if it does, skip it.\n", ctx.IssueID)@@ -519,8 +539,8 @@ func writeWorkflowIssue(b *strings.Builder, ctx TaskContextForEnv) {if ctx.IsSquadLeader {fmt.Fprintf(b, "- **Squad leader rule:** If your evaluation outcome is `no_action`, call `multica squad activity %s no_action --reason \"...\"` and then EXIT IMMEDIATELY. DO NOT post any comment whose only purpose is to announce that you are taking no action, exiting silently, or acknowledging another agent. A comment like \"No action needed\" or \"Exiting silently\" is noise — the `squad activity` call already records your decision in the timeline.\n", ctx.IssueID)}- b.WriteString("- If a reply IS warranted: do any requested work first, then **decide whether to include any `@mention` link.** The default is NO mention. Only mention when you are escalating to a human owner who is not yet involved, delegating a concrete new sub-task to another agent for the first time, or the user explicitly asked you to loop someone in. Never @mention the agent you are replying to as a thank-you or sign-off.\n")- b.WriteString("- **If you reply, posting it as a comment is mandatory.** Text in your terminal or run logs is NOT delivered to the user. Use the `--parent` value the per-turn user message gives you for this turn; do NOT reuse a `--parent` from an earlier turn in this session. When that message lists more than one thread to answer, post one reply per thread instead of merging them.\n")+ b.WriteString("- If a reply IS warranted: do any requested work first, then **decide whether to include any `@mention` link.** The default is NO mention; `## Mentions` states when one is warranted.\n")+ b.WriteString("- **If you reply, posting it as a comment is mandatory** (`## Output`). Use the `--parent` value the per-turn user message gives you for this turn; do NOT reuse a `--parent` from an earlier turn in this session. When that message lists more than one thread to answer, post one reply per thread instead of merging them.\n")if ctx.IsSquadLeader {// The default rule below and the Squad Operating Protocol's// "Own the parent issue status" responsibility would otherwise@@ -590,7 +610,7 @@ func writeMentions(b *strings.Builder) {b.WriteString("- `[@Name](mention://member/<user-id>)` — **notifies a human**\n")b.WriteString("- `[@Name](mention://agent/<agent-id>)` — **enqueues a new run for that agent**\n\n")b.WriteString("### When NOT to use a mention link\n\n")- b.WriteString("Default: NO mention. Replying to another agent that just spoke to you, or thanking / acknowledging / signing off — **end with no mention at all**. An accidental `@mention` restarts an agent-to-agent loop and costs the user money.\n\n")+ b.WriteString("Default: NO mention. Never @mention the agent you are replying to as a thank-you or sign-off — when replying to an agent that just spoke to you, or thanking / acknowledging / signing off, **end with no mention at all**. An accidental `@mention` restarts an agent-to-agent loop and costs the user money.\n\n")b.WriteString("### When a mention IS appropriate\n\n")b.WriteString("Escalating to a human owner not yet involved; delegating a concrete new sub-task to another agent for the first time; or when the user explicitly asks to loop someone in. Otherwise **don't mention**. Silence ends conversations.\n\n")}@@ -604,7 +624,7 @@ func writeAttachments(b *strings.Builder) {// just downloaded is the most tempting local path to echo back, because it// came from the conversation and *feels* shared. It is not — the download// landed in this run's private workdir.- b.WriteString("An attachment you download lands in your own workdir: that local path is a private working copy, not something the reader can open. Never echo it back into a deliverable as a link — re-deliver the file itself if it needs to travel (see `## Output`).\n\n")+ b.WriteString("An attachment you download lands in your own workdir: that local path is a private working copy, not something the reader can open — the link rules in `## Output` apply to it too.\n\n")}// writeAlwaysUseCLI emits the "must go through the multica CLI" guardrail@@ -719,7 +739,7 @@ func buildMetaSkillContentSlim(provider string, ctx TaskContextForEnv) string {case kindQuickCreate:writeAvailableCommandsQuickCreate(&b)default:- writeAvailableCommands(&b)+ writeAvailableCommands(&b, ctx)}writeIssueBodyFormatting(&b)diff --git a/server/internal/daemon/execenv/runtime_config_test.go b/server/internal/daemon/execenv/runtime_config_test.goindex 9b41f3e674..398d3e3fe0 100644--- a/server/internal/daemon/execenv/runtime_config_test.go+++ b/server/internal/daemon/execenv/runtime_config_test.go@@ -329,10 +329,15 @@ func TestIssueWorkflowHonorsAgentIdentity(t *testing.T) {"## Instruction Precedence","Agent Identity instructions have priority over the issue workflow below.","If a workflow step conflicts with Agent Identity, skip the conflicting action",- "Never treat this runtime workflow as permission to change issue status, investigate, implement",+ // One enumeration, in Instruction Precedence, covering every action+ // type Agent Identity can forbid. This and workflow step 4 each used to+ // carry their own list and the two disagreed (MUL-5442).+ "Never treat this runtime workflow as permission to change issue status, investigate, implement, create issues, update issues, delegate, or otherwise act beyond your Agent Identity.","Before step 4, run `multica issue status " + issueID + " in_progress` unless your Agent Identity forbids issue status changes; if it does, skip it.",- "Complete the task within your Agent Identity boundaries.",- "Do not investigate, implement, create issues, update issues, or delegate if your Agent Identity forbids that action",+ "Complete the task within your Agent Identity boundaries",+ // Step 4 keeps only what the enumeration cannot express: a+ // delegation-only role stops once the delegation is delivered.+ "If your role is delegation-only, perform the allowed delegation work and stop once that outcome is delivered","When done, run `multica issue status " + issueID + " in_review` unless your Agent Identity forbids issue status changes; if it does, skip it.","If blocked, run `multica issue status " + issueID + " blocked` unless your Agent Identity forbids issue status changes.",} {