Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-6104: fix(daemon): tell the brief's reader not to merge stderr into parsed output (#6870)
Xichang(Seacen) Zhaocc2aea387800
diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.goindex 0397540118..10bc78100d 100644--- a/server/internal/daemon/execenv/runtime_config_sections.go+++ b/server/internal/daemon/execenv/runtime_config_sections.go@@ -242,7 +242,7 @@ func sanitizeBriefCodeToken(s string) string {}// writeAvailableCommands emits the slim Available Commands section-// (~2.4k chars vs legacy ~4.4k). Every test-asserted substring is+// (~3.0k chars vs legacy ~4.4k). Every test-asserted substring is// preserved: each `multica issue …` command name, all three `comment add`// input modes, `--description-file <path>`, `--parent ""`, the// `Next reply cursor` / `Next thread cursor` stderr labels, the three@@ -256,6 +256,7 @@ func sanitizeBriefCodeToken(s string) string {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("`--output json` writes JSON to stdout; confirmations and warnings go to stderr. Do not merge them (`2>&1`) into anything that parses the output — that makes a write that SUCCEEDED look like it failed and invites a duplicate retry.\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] [--since <RFC3339>] --output json` — thread-aware comment reads. Bound a wide read with `--roots-only --summary` (roots plus `reply_count` / `last_activity_at`, clipped bodies); bound a deep one with `--thread <id> --tail N`; add `--compact` to any JSON read to drop echoed/null/bookkeeping fields. Careful with `--recent N`: it caps THREADS, not comments, and can return the whole history on a small issue. Resolved-thread folding, paging cursors, and full flag semantics: `--help`.\n")@@ -292,6 +293,7 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {func writeAvailableCommandsQuickCreate(b *strings.Builder) {b.WriteString("## Available Commands\n\n")b.WriteString("**Use `--output json` for structured data.** For anything beyond `issue create`, run `multica --help` or `multica <command> --help`.\n\n")+ b.WriteString("`--output json` writes JSON to stdout; confirmations and warnings go to stderr. Do not merge them (`2>&1`) into anything that parses the output — that makes a write that SUCCEEDED look like it failed and invites a duplicate retry.\n\n")b.WriteString("### Core\n")b.WriteString("- `multica issue create --title \"...\" [--description \"...\" | --description-file <path> | --description-stdin] [--priority X] [--status X] [--assignee X | --assignee-id <uuid>] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <YYYY-MM-DD>] [--attachment <path>]` — Create a new issue; `--attachment` may be repeated. For agent-authored long descriptions, prefer `--description-file <path>` over `--description-stdin` (flags after a HEREDOC terminator can be silently swallowed, #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\n")}diff --git a/server/internal/daemon/execenv/runtime_config_test.go b/server/internal/daemon/execenv/runtime_config_test.goindex 6cec9c7edc..b825e3762c 100644--- a/server/internal/daemon/execenv/runtime_config_test.go+++ b/server/internal/daemon/execenv/runtime_config_test.go@@ -1976,3 +1976,63 @@ func TestBriefSkillsListIsNamesOnly(t *testing.T) {})}}++// Every brief that teaches `--output json` also says not to merge stderr into+// it, because the two facts are only useful together. The CLI is right:+// confirmations go to stderr, JSON goes to stdout, and `--output json | jq` has+// always worked. It stays right only while the caller keeps the streams apart,+// and `2>&1` is ordinary shell habit. The cost of merging them is not a cosmetic+// parse error: a confirmation line inside the JSON makes the parse fail, so a+// write that SUCCEEDED reads as one that failed, and the retry posts the comment+// or sends the file a second time.+//+// The assertions are on the rule's wording, not on loose substrings, because+// `2>&1` and "look like it failed" both survive a brief that says to merge the+// streams. Each builder must carry the prohibition verbatim, exactly once, with+// the consequence attached.+//+// Both brief builders are checked, not one. The quick-create brief is a+// separate function with its own copy of the `--output json` line, so guidance+// added to the full brief alone would be missing from exactly the runs that are+// given the least context to work it out for themselves.+func TestEveryBriefThatTeachesJSONOutputAlsoWarnsAgainstMergingStderr(t *testing.T) {+ t.Parallel()+ const (+ wantFlag = "--output json"+ // The premise the rule rests on. "Do not merge them" says nothing about+ // WHICH stream carries what, so a brief that swapped the two would pass+ // every other assertion here while telling an agent the opposite of the+ // truth — the same defect one clause to the left.+ wantPremise = "writes JSON to stdout; confirmations and warnings go to stderr"+ // The prohibition itself, not just the operator it names: "Always merge+ // them (`2>&1`)" contains `2>&1` and would pass a bare-operator check.+ wantRule = "Do not merge them (`2>&1`)"+ // The consequence, in the direction that makes the rule worth obeying;+ // the inverse claim ("failed write looks like it succeeded") is a+ // different bug and must not satisfy this.+ wantWhy = "a write that SUCCEEDED look like it failed"+ )+ briefs := map[string]string{+ "full": buildMetaSkillContent("claude", TaskContextForEnv{IssueID: "11111111-2222-3333-4444-555555555555"}),+ "quick-create": buildMetaSkillContent("claude", TaskContextForEnv{QuickCreatePrompt: "make an issue"}),+ }+ for name, brief := range briefs {+ if !strings.Contains(brief, wantFlag) {+ t.Fatalf("%s brief does not mention %s at all; this test's premise is gone", name, wantFlag)+ }+ if !strings.Contains(brief, wantPremise) {+ t.Errorf("%s brief teaches %s without saying %q — the rule below it is only correct while the streams carry what this says they carry", name, wantFlag, wantPremise)+ }+ switch got := strings.Count(brief, wantRule); got {+ case 1:+ case 0:+ t.Errorf("%s brief teaches %s without saying %q — the habit it has to displace is the one thing an agent will not infer", name, wantFlag, wantRule)+ continue // the reason check below would report a rule that is not there+ default:+ t.Errorf("%s brief repeats %q %d times; one rule, one place, or the next edit fixes only one of them", name, wantRule, got)+ }+ if !strings.Contains(brief, wantWhy) {+ t.Errorf("%s brief states %q without %q; a rule with no reason is the first one dropped under pressure", name, wantRule, wantWhy)+ }+ }+}