Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(cli): add --compact to issue comment list, adopt it in every agent read command (MUL-5442) (#6546)

Bohan Jiang545d890daedf
diff --git a/server/cmd/multica/cmd_issue.go b/server/cmd/multica/cmd_issue.go
index dc37095d7c..8be012b256 100644
--- a/server/cmd/multica/cmd_issue.go
+++ b/server/cmd/multica/cmd_issue.go
@@ -524,6 +524,7 @@ func init() {
issueCommentListCmd.Flags().Int("tail", 0, "Only valid with --thread. Cap reply count to the N most recent replies; the thread root is always included (even with --tail 0). Use --before/--before-id to scroll to older replies.")
issueCommentListCmd.Flags().Int("recent", 0, "Return the N most recently active threads. N caps THREADS, not comments: every thread carries its root plus EVERY descendant with no per-thread cap, so on an issue with fewer than N root threads this returns the entire history (minus folded resolved threads). Prefer two bounded reads: scan with --roots-only --summary, then open selected threads with --thread <id> --tail N. Use --before/--before-id from the previous response to scroll to older threads.")
issueCommentListCmd.Flags().Bool("roots-only", false, "Only return top-level comments (parent_id is null). Each root also carries reply_count + last_activity_at so you can triage which thread to open.")
+ issueCommentListCmd.Flags().Bool("compact", false, "JSON output only: drop response fields that carry no information for a reader — the issue_id echoed from the request path, source_task_id, updated_at when identical to created_at, null-valued fields, and empty arrays. Content and identity fields pass through untouched. Recommended for agent reads; composes with any mode.")
issueCommentListCmd.Flags().Bool("summary", false, "Clip each comment's content to a short preview (sets content_truncated) so you can scan a list without pulling full bodies. Composes with any mode.")
issueCommentListCmd.Flags().Bool("full", false, "Escape hatch: return every comment in resolved threads verbatim. By default the complete-thread reads (default list, --recent, --thread without --tail) are folded — a resolved thread collapses to its root + conclusion, with the dropped count reported on the root — so you do not pay tokens for settled discussion. Pass --full when you need the folded discussion. No effect on --since/--tail/--roots-only reads, which are never folded.")
issueCommentListCmd.Flags().String("before", "", "Cursor (RFC3339Nano timestamp). With --recent: thread cursor (last_activity_at). With --thread + --tail: reply cursor (reply created_at). Read from the X-Multica-Next-Before response header, printed on stderr as \"Next thread cursor\" / \"Next reply cursor\"; must be paired with --before-id.")
@@ -1895,6 +1896,9 @@ func runIssueCommentList(cmd *cobra.Command, args []string) error {
output, _ := cmd.Flags().GetString("output")
if output == "json" {
+ if compact, _ := cmd.Flags().GetBool("compact"); compact {
+ compactComments(comments)
+ }
return cli.PrintJSON(os.Stdout, comments)
}
@@ -2793,3 +2797,33 @@ func truncateID(id string) string {
}
return id
}
+
+// compactComments strips response fields that carry no information for a
+// reader: the issue_id echoed from the request path, per-run bookkeeping
+// (source_task_id), updated_at when identical to created_at, null-valued
+// keys, and empty arrays. Everything else — content, identity, thread
+// summary fields — passes through untouched. Opt-in via --compact and
+// applied to JSON output only: the two bounded reads the agent workflow
+// prescribes are dominated by exactly this metadata (56% of a
+// --roots-only --summary scan, 21% of a --thread --tail read, measured on
+// a production issue), and it compounds through the prompt-cache prefix
+// (#5999 follow-up, MUL-5442).
+func compactComments(comments []map[string]any) {
+ for _, c := range comments {
+ delete(c, "issue_id")
+ delete(c, "source_task_id")
+ if ua, ok := c["updated_at"]; ok && ua == c["created_at"] {
+ delete(c, "updated_at")
+ }
+ for k, v := range c {
+ switch vv := v.(type) {
+ case nil:
+ delete(c, k)
+ case []any:
+ if len(vv) == 0 {
+ delete(c, k)
+ }
+ }
+ }
+ }
+}
diff --git a/server/cmd/multica/cmd_issue_test.go b/server/cmd/multica/cmd_issue_test.go
index 64da594b93..cf8de61b58 100644
--- a/server/cmd/multica/cmd_issue_test.go
+++ b/server/cmd/multica/cmd_issue_test.go
@@ -2136,6 +2136,7 @@ func newIssueCommentListTestCmd() *cobra.Command {
cmd.Flags().Bool("roots-only", false, "")
cmd.Flags().Bool("summary", false, "")
cmd.Flags().Bool("full", false, "")
+ cmd.Flags().Bool("compact", false, "")
cmd.Flags().String("thread", "", "")
cmd.Flags().Int("recent", 0, "")
cmd.Flags().Int("tail", 0, "")
@@ -3449,9 +3450,159 @@ func TestIssueCommentListHelpCarriesReadContract(t *testing.T) {
// Pagination cursor labels, exactly as the CLI prints them on stderr.
"Next thread cursor",
"Next reply cursor",
+ // The --compact contract (#5999 follow-up): what goes and what is
+ // untouchable.
+ "drop response fields that carry no information",
+ "Content and identity fields pass through untouched",
} {
if !strings.Contains(help, want) {
t.Errorf("comment list rendered help missing %q, got:\n%s", want, help)
}
}
}
+
+// TestCompactCommentsDropsReaderNoise pins the --compact contract (#5999
+// follow-up, MUL-5442): reader-noise fields go — the echoed issue_id,
+// source_task_id, updated_at when identical to created_at, null values,
+// empty arrays — while information-carrying fields and content pass
+// through untouched, and a REAL edit timestamp or non-empty array is
+// never dropped.
+func TestCompactCommentsDropsReaderNoise(t *testing.T) {
+ t.Parallel()
+
+ comments := []map[string]any{{
+ "id": "c-1",
+ "issue_id": "i-1",
+ "parent_id": nil,
+ "author_type": "agent",
+ "author_id": "a-1",
+ "content": "hello",
+ "type": "comment",
+ "created_at": "2026-08-07T02:00:00Z",
+ "updated_at": "2026-08-07T02:00:00Z",
+ "source_task_id": "t-1",
+ "resolved_at": nil,
+ "resolved_by_id": nil,
+ "attachments": []any{},
+ "reactions": []any{},
+ "reply_count": float64(0),
+ "content_truncated": false,
+ "last_activity_at": "2026-08-07T03:00:00Z",
+ }, {
+ "id": "c-2",
+ "issue_id": "i-1",
+ "content": "edited later",
+ "created_at": "2026-08-07T02:00:00Z",
+ "updated_at": "2026-08-07T04:00:00Z",
+ "attachments": []any{map[string]any{"id": "att-1"}},
+ }}
+ compactComments(comments)
+
+ for _, k := range []string{"issue_id", "source_task_id", "updated_at", "parent_id", "resolved_at", "resolved_by_id", "attachments", "reactions"} {
+ if _, ok := comments[0][k]; ok {
+ t.Errorf("compact kept reader-noise field %q", k)
+ }
+ }
+ // reply_count: 0 and content_truncated: false are semantic zero values,
+ // not nulls — null pruning must never generalize to zero pruning
+ // (#6546 review).
+ for _, k := range []string{"id", "author_type", "author_id", "content", "type", "created_at", "reply_count", "content_truncated", "last_activity_at"} {
+ if _, ok := comments[0][k]; !ok {
+ t.Errorf("compact dropped information field %q", k)
+ }
+ }
+ if _, ok := comments[1]["updated_at"]; !ok {
+ t.Error("compact dropped a real edit timestamp (updated_at != created_at)")
+ }
+ if _, ok := comments[1]["attachments"]; !ok {
+ t.Error("compact dropped a non-empty attachments array")
+ }
+}
+
+// TestRunIssueCommentListCompactWiring proves the flag is wired end to end
+// (#6546 review nit): the same server response loses reader-noise fields
+// under --compact while zero-value scalars like reply_count: 0 and
+// content_truncated: false are KEPT (null pruning must never generalize to
+// zero pruning), and without the flag the default output still carries
+// every field — the default contract is untouched.
+func TestRunIssueCommentListCompactWiring(t *testing.T) {
+ const issueID = "22222222-2222-4222-8222-222222222222"
+ payload := []map[string]any{{
+ "id": "c-1",
+ "issue_id": issueID,
+ "parent_id": nil,
+ "author_type": "member",
+ "author_id": "u-1",
+ "type": "comment",
+ "content": "hello",
+ "created_at": "2026-08-07T02:00:00Z",
+ "updated_at": "2026-08-07T02:00:00Z",
+ "source_task_id": "t-1",
+ "attachments": []any{},
+ "reply_count": 0,
+ "content_truncated": false,
+ "folded_count": 0,
+ }}
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ switch {
+ case r.Method == http.MethodGet && r.URL.Path == "/api/issues/"+issueID:
+ _ = json.NewEncoder(w).Encode(map[string]any{"id": issueID, "identifier": "TST-2"})
+ case r.Method == http.MethodGet && r.URL.Path == "/api/issues/"+issueID+"/comments":
+ _ = json.NewEncoder(w).Encode(payload)
+ default:
+ t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path)
+ w.WriteHeader(http.StatusNotFound)
+ }
+ }))
+ defer srv.Close()
+ setCLITestServerEnv(t, srv.URL)
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+
+ run := func(compact bool) []map[string]any {
+ t.Helper()
+ cmd := newIssueCommentListTestCmd()
+ if compact {
+ _ = cmd.Flags().Set("compact", "true")
+ }
+ orig := os.Stdout
+ r, w, err := os.Pipe()
+ if err != nil {
+ t.Fatalf("pipe: %v", err)
+ }
+ os.Stdout = w
+ runErr := runIssueCommentList(cmd, []string{issueID})
+ w.Close()
+ os.Stdout = orig
+ if runErr != nil {
+ t.Fatalf("runIssueCommentList: %v", runErr)
+ }
+ out, _ := io.ReadAll(r)
+ var got []map[string]any
+ if err := json.Unmarshal(out, &got); err != nil {
+ t.Fatalf("output not JSON: %v\n---\n%s", err, out)
+ }
+ return got
+ }
+
+ plain := run(false)
+ if len(plain) != 1 {
+ t.Fatalf("expected 1 comment, got %d", len(plain))
+ }
+ for _, k := range []string{"issue_id", "source_task_id", "updated_at", "parent_id", "attachments"} {
+ if _, ok := plain[0][k]; !ok {
+ t.Errorf("default output must be untouched but lost %q", k)
+ }
+ }
+
+ compacted := run(true)
+ for _, k := range []string{"issue_id", "source_task_id", "updated_at", "parent_id", "attachments"} {
+ if _, ok := compacted[0][k]; ok {
+ t.Errorf("--compact kept reader-noise field %q", k)
+ }
+ }
+ for _, k := range []string{"id", "content", "created_at", "reply_count", "content_truncated", "folded_count"} {
+ if _, ok := compacted[0][k]; !ok {
+ t.Errorf("--compact dropped %q — zero-value scalars must survive", k)
+ }
+ }
+}
diff --git a/server/internal/daemon/execenv/execenv_test.go b/server/internal/daemon/execenv/execenv_test.go
index 14b065aff3..bdf7940b25 100644
--- a/server/internal/daemon/execenv/execenv_test.go
+++ b/server/internal/daemon/execenv/execenv_test.go
@@ -5431,7 +5431,7 @@ func TestInjectRuntimeConfigBriefKeepsStaticCatchUpRead(t *testing.T) {
// MUL-5442 cross-channel dedup: the full command with the real issue id
// moved to the per-turn message (every issue variant carries it); the
// brief keeps the doctrine and the flag mnemonics.
- if !strings.Contains(s, "scan every thread cheaply (`--roots-only --summary`)") {
+ if !strings.Contains(s, "scan every thread cheaply (`--roots-only --summary --compact`)") {
t.Errorf("brief must keep the bounded catch-up doctrine\n---\n%s", s)
}
if strings.Contains(s, issueID) {
@@ -5495,7 +5495,7 @@ func TestInjectRuntimeConfigBriefOmitsResumedThreadAnchor(t *testing.T) {
"No other new comments on this issue since your last run",
"If your reply depends on thread context",
"do not rely only on resumed session memory",
- "multica issue comment list " + issueID + " --thread thread-root-1 --tail 30 --output json",
+ "multica issue comment list " + issueID + " --thread thread-root-1 --tail 30 --compact --output json",
} {
if !strings.Contains(hint, want) {
t.Errorf("resumed hint missing %q\n---\n%s", want, hint)
@@ -5528,7 +5528,7 @@ func TestInjectRuntimeConfigAssignmentTriggerScansRootsFirst(t *testing.T) {
// Mandatory comment catch-up must stay, but the required first read is
// bounded to recent active threads instead of the full flat timeline.
for _, want := range []string{
- "scan every thread cheaply (`--roots-only --summary`)",
+ "scan every thread cheaply (`--roots-only --summary --compact`)",
"this is mandatory, not optional",
"Skipping this step is the most common cause",
} {
@@ -5595,9 +5595,9 @@ func TestInjectRuntimeConfigCatchUpScansRootsFirst(t *testing.T) {
// The cheap scan is the first thing step 3 asks for; the full
// command with real ids arrives in the per-turn message (MUL-5442
// cross-channel dedup), so the brief pins the flag mnemonics.
- "scan every thread cheaply (`--roots-only --summary`)",
+ "scan every thread cheaply (`--roots-only --summary --compact`)",
// ...followed by an explicit, bounded drill-down.
- "expand only the threads that matter (`--thread <id> --tail 30`)",
+ "expand only the threads that matter (`--thread <id> --tail 30 --compact`)",
// The headline saturation warning stays in the flag reference; the
// deep semantics (per-thread cap, root-thread saturation) moved to the
// CLI's own --help (MUL-5442) and are pinned there
diff --git a/server/internal/daemon/execenv/reply_instructions.go b/server/internal/daemon/execenv/reply_instructions.go
index 9e653ceb12..3d42246c91 100644
--- a/server/internal/daemon/execenv/reply_instructions.go
+++ b/server/internal/daemon/execenv/reply_instructions.go
@@ -36,7 +36,7 @@ func BuildNewCommentsHint(issueID, triggerCommentID, triggerThreadID, newComment
return fmt.Sprintf(
"%d new comment(s) on this issue since your last run — don't read them all blindly. "+
"Start with the thread your triggering comment is in: "+
- "`multica issue comment list %s --thread %s --since %s --output json` "+
+ "`multica issue comment list %s --thread %s --since %s --compact --output json` "+
"(swap `--since` for `--tail 30` if you need the full thread, not just the delta). "+
"Only if you need context from the other threads, rerun it without `--thread` for the issue-wide catch-up.\n\n",
newCommentCount, issueID, threadID, newCommentsSince,
@@ -47,7 +47,7 @@ func BuildNewCommentsHint(issueID, triggerCommentID, triggerThreadID, newComment
// issue-wide catch-up.
return fmt.Sprintf(
"%d new comment(s) on this issue since your last run. Catch up: "+
- "`multica issue comment list %s --since %s --output json`.\n\n",
+ "`multica issue comment list %s --since %s --compact --output json`.\n\n",
newCommentCount, issueID, newCommentsSince,
)
}
@@ -73,7 +73,7 @@ func BuildResumedCommentsHint(issueID, triggerCommentID, triggerThreadID string)
"No other new comments on this issue since your last run. "+
"If your reply depends on thread context, do not rely only on resumed session memory — "+
"first pull the triggering conversation with: "+
- "`multica issue comment list %s --thread %s --tail 30 --output json`.\n\n",
+ "`multica issue comment list %s --thread %s --tail 30 --compact --output json`.\n\n",
issueID, threadID,
)
}
@@ -103,7 +103,7 @@ func BuildColdCommentsHint(issueID, triggerCommentID, triggerThreadID string) st
// routing value (MUL-5721 OPT-1).
return fmt.Sprintf(
"Read the triggering conversation first: "+
- "`multica issue comment list %s --thread %s --tail 30 --output json` "+
+ "`multica issue comment list %s --thread %s --tail 30 --compact --output json` "+
"(that thread's root + its 30 newest replies). "+
"Need cross-thread background? Rerun with `--roots-only --summary` replacing `--thread ... --tail 30` "+
"to scan the other threads cheaply, and expand only what looks relevant.\n\n",
diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.go
index 981debf039..bae9a08151 100644
--- a/server/internal/daemon/execenv/runtime_config_sections.go
+++ b/server/internal/daemon/execenv/runtime_config_sections.go
@@ -258,7 +258,7 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {
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] [--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`. 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")
+ 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")
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 <YYYY-MM-DD>] [--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 <YYYY-MM-DD>]` — 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")
@@ -549,7 +549,7 @@ func writeWorkflowIssue(b *strings.Builder, ctx TaskContextForEnv) {
b.WriteString("**Steps 1–6 — both modes** (the per-turn user message carries this issue's real id and ready-to-run context-read commands; assemble other calls from `## Available Commands`)\n\n")
b.WriteString("1. Read the issue (`multica issue get`) to understand the context.\n")
b.WriteString("2. Read the metadata bag (`multica issue metadata list`) — best-effort, empty `{}` and CLI failures are normal. What to look for: `## Issue Metadata`.\n")
- b.WriteString("3. Catch up on the comment history — this is mandatory, not optional — in two bounded reads, never one bulk pull: scan every thread cheaply (`--roots-only --summary`), then expand only the threads that matter (`--thread <id> --tail 30`). Earlier comments often carry context the issue body lacks. 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.\n")
+ b.WriteString("3. Catch up on the comment history — this is mandatory, not optional — in two bounded reads, never one bulk pull: scan every thread cheaply (`--roots-only --summary --compact`), then expand only the threads that matter (`--thread <id> --tail 30 --compact`). Earlier comments often carry context the issue body lacks. 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.\n")
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 {
b.WriteString("5. **Post your final results as a comment** (unless your outcome is `no_action` — in that case, calling `multica squad activity <issue-id> 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` 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")
diff --git a/server/internal/daemon/execenv/runtime_config_test.go b/server/internal/daemon/execenv/runtime_config_test.go
index b4dab05658..28f3534214 100644
--- a/server/internal/daemon/execenv/runtime_config_test.go
+++ b/server/internal/daemon/execenv/runtime_config_test.go
@@ -240,7 +240,7 @@ func TestPerRunCommentContextStaysOutOfBrief(t *testing.T) {
for _, want := range []string{
"4 new comment(s) on this issue since your last run",
"blindly",
- "--thread thread-abc --since " + since + " --output json",
+ "--thread thread-abc --since " + since + " --compact --output json",
"--tail 30",
} {
if !strings.Contains(hint, want) {
@@ -258,7 +258,7 @@ func TestColdCommentsHintPointsAtTriggeringThread(t *testing.T) {
if strings.Contains(hint, "new comment(s) since your last run") {
t.Errorf("no since-delta hint should render on cold start, got:\n%s", hint)
}
- if !strings.Contains(hint, "multica issue comment list "+issueID+" --thread thread-root-1 --tail 30 --output json") {
+ if !strings.Contains(hint, "multica issue comment list "+issueID+" --thread thread-root-1 --tail 30 --compact --output json") {
t.Errorf("cold start must point at the triggering thread read, got:\n%s", hint)
}
if strings.Contains(buildMetaSkillContent("claude", TaskContextForEnv{IssueID: issueID, TriggerCommentID: "trigger-1", TriggerThreadID: "thread-root-1"}), "thread-root-1") {
@@ -277,7 +277,7 @@ func TestResumedCommentsHintSkipsDefaultThreadRead(t *testing.T) {
"No other new comments on this issue since your last run",
"If your reply depends on thread context",
"do not rely only on resumed session memory",
- "multica issue comment list " + issueID + " --thread thread-root-1 --tail 30 --output json",
+ "multica issue comment list " + issueID + " --thread thread-root-1 --tail 30 --compact --output json",
} {
if !strings.Contains(hint, want) {
t.Errorf("resumed/no-delta hint missing %q\n--- output ---\n%s", want, hint)
diff --git a/server/internal/daemon/prompt.go b/server/internal/daemon/prompt.go
index fc0efdb609..a6d5d5ba1d 100644
--- a/server/internal/daemon/prompt.go
+++ b/server/internal/daemon/prompt.go
@@ -124,7 +124,7 @@ func buildPromptBody(task Task, provider string) string {
fmt.Fprintf(&b, "> %s\n\n", task.HandoffNote)
}
fmt.Fprintf(&b, "Start by running `multica issue get %s --output json` to understand your task, then complete it.\n", task.IssueID)
- fmt.Fprintf(&b, "For comment history, follow the rule in your runtime workflow file (assignment-triggered tasks treat the read as mandatory). Scan the threads first with `multica issue comment list %s --roots-only --summary --output json`, then expand only what matters with `--thread <thread-id> --tail 30`. For `--since` incremental polling, pagination, and folding, see `multica issue comment list --help`.\n", task.IssueID)
+ fmt.Fprintf(&b, "For comment history, follow the rule in your runtime workflow file (assignment-triggered tasks treat the read as mandatory). Scan the threads first with `multica issue comment list %s --roots-only --summary --compact --output json`, then expand only what matters with `--thread <thread-id> --tail 30`. For `--since` incremental polling, pagination, and folding, see `multica issue comment list --help`.\n", task.IssueID)
return b.String()
}
@@ -293,7 +293,7 @@ func buildCommentPrompt(task Task, provider string) string {
b.WriteString(":\n")
fmt.Fprintf(&b, " > %s\n", strings.ReplaceAll(strings.TrimSpace(cc.Content), "\n", "\n > "))
}
- fmt.Fprintf(&b, "\nIf you need the surrounding discussion for any of them, fetch its thread with `multica issue comment list %s --thread <thread-id> --tail 30 --output json` using the thread id shown above.\n\n", task.IssueID)
+ fmt.Fprintf(&b, "\nIf you need the surrounding discussion for any of them, fetch its thread with `multica issue comment list %s --thread <thread-id> --tail 30 --compact --output json` using the thread id shown above.\n\n", task.IssueID)
} else if len(task.CoalescedCommentIDs) > 0 {
// MUL-5442: this fallback used to send the agent at `--recent 30`.
// That flag caps THREADS, not comments, and every returned thread
@@ -324,10 +324,10 @@ func buildCommentPrompt(task Task, provider string) string {
fmt.Fprintf(&b, "This run also covers %d earlier comment(s) posted before it started — you must read and address every one of them, not just the one above: %s. They may be in DIFFERENT threads, so do not assume they share the triggering thread.\n\n",
len(task.CoalescedCommentIDs), strings.Join(task.CoalescedCommentIDs, ", "))
if task.NewCommentsSince != "" {
- fmt.Fprintf(&b, "Start with `multica issue comment list %s --since %s --output json`. Treat that as a candidate window, not a guarantee — it also carries unrelated comments, and a retried run can carry ids older than the window. Check every id above against the result.\n\n",
+ fmt.Fprintf(&b, "Start with `multica issue comment list %s --since %s --compact --output json`. Treat that as a candidate window, not a guarantee — it also carries unrelated comments, and a retried run can carry ids older than the window. Check every id above against the result.\n\n",
task.IssueID, task.NewCommentsSince)
}
- fmt.Fprintf(&b, "Fetch each id you still need directly: `multica issue comment list %s --thread <comment-id> --tail 30 --output json`. `--thread` accepts a reply id, not just a thread root, so you do not need to know which thread the comment lives in. If it is older than those 30 replies, page back with the `Next reply cursor` values (`--before` / `--before-id`) until it appears. Do not finish this turn until every id above is accounted for.\n\n",
+ fmt.Fprintf(&b, "Fetch each id you still need directly: `multica issue comment list %s --thread <comment-id> --tail 30 --compact --output json`. `--thread` accepts a reply id, not just a thread root, so you do not need to know which thread the comment lives in. If it is older than those 30 replies, page back with the `Next reply cursor` values (`--before` / `--before-id`) until it appears. Do not finish this turn until every id above is accounted for.\n\n",
task.IssueID)
}
if taskIsSquadLeader(task) {
@@ -348,7 +348,7 @@ func buildCommentPrompt(task Task, provider string) string {
} else if cold := execenv.BuildColdCommentsHint(task.IssueID, task.TriggerCommentID, task.TriggerThreadID); cold != "" {
b.WriteString(cold)
} else {
- fmt.Fprintf(&b, "Read the discussion: scan with `multica issue comment list %s --roots-only --summary --output json`, then expand what matters with `--thread <thread-id> --tail 30`.\n\n", task.IssueID)
+ fmt.Fprintf(&b, "Read the discussion: scan with `multica issue comment list %s --roots-only --summary --compact --output json`, then expand what matters with `--thread <thread-id> --tail 30`.\n\n", task.IssueID)
}
// Reply routing. When this run coalesced comments spanning MORE THAN ONE
// root thread, answer each thread in its own thread instead of dumping one
diff --git a/server/internal/daemon/prompt_test.go b/server/internal/daemon/prompt_test.go
index 33bbe21fce..ba5bc86620 100644
--- a/server/internal/daemon/prompt_test.go
+++ b/server/internal/daemon/prompt_test.go
@@ -847,7 +847,7 @@ func TestBuildChatPromptSlashSkills(t *testing.T) {
func TestBuildPromptDefaultScansRootsFirst(t *testing.T) {
out := BuildPrompt(Task{IssueID: "issue-default-1"}, "claude")
for _, s := range []string{
- "multica issue comment list issue-default-1 --roots-only --summary --output json",
+ "multica issue comment list issue-default-1 --roots-only --summary --compact --output json",
"--since",
} {
if !strings.Contains(out, s) {
@@ -934,7 +934,7 @@ func TestBuildPromptNewCommentsHint(t *testing.T) {
t.Errorf("hint must discourage blindly reading every new comment, got:\n%s", out)
}
// Parent thread first: the --thread <trigger> read is the prioritized action.
- if !strings.Contains(out, "multica issue comment list "+issueID+" --thread thread-root-1 --since "+since+" --output json") {
+ if !strings.Contains(out, "multica issue comment list "+issueID+" --thread thread-root-1 --since "+since+" --compact --output json") {
t.Errorf("hint must point at the triggering (parent) thread --since read first, got:\n%s", out)
}
if !strings.Contains(out, "--tail 30") {
@@ -974,7 +974,7 @@ func TestBuildPromptColdStartThreadRead(t *testing.T) {
if strings.Contains(out, "new comment(s) since your last run") {
t.Errorf("no since-delta hint should render on cold start, got:\n%s", out)
}
- if !strings.Contains(out, "multica issue comment list "+issueID+" --thread thread-root-1 --tail 30 --output json") {
+ if !strings.Contains(out, "multica issue comment list "+issueID+" --thread thread-root-1 --tail 30 --compact --output json") {
t.Errorf("cold start must point at the triggering thread read, got:\n%s", out)
}
// MUL-5372: cross-thread background is a cheap roots scan. The hint names
@@ -1017,7 +1017,7 @@ func TestBuildPromptResumedNoDeltaDoesNotForceThreadRead(t *testing.T) {
"No other new comments on this issue since your last run",
"If your reply depends on thread context",
"do not rely only on resumed session memory",
- "multica issue comment list " + issueID + " --thread thread-root-1 --tail 30 --output json",
+ "multica issue comment list " + issueID + " --thread thread-root-1 --tail 30 --compact --output json",
} {
if !strings.Contains(out, want) {
t.Errorf("resumed/no-delta prompt missing %q\n--- output ---\n%s", want, out)
@@ -1109,7 +1109,7 @@ func TestBuildCommentPromptCoalescedIDsOnlyFallback(t *testing.T) {
task.NewCommentsSince = "2026-08-03T06:00:00Z"
out := BuildPrompt(task, "claude")
- want := "multica issue comment list issue-fallback-1 --since 2026-08-03T06:00:00Z --output json"
+ want := "multica issue comment list issue-fallback-1 --since 2026-08-03T06:00:00Z --compact --output json"
if !strings.Contains(out, want) {
t.Errorf("id-only fallback should prefetch the window with %q, got:\n%s", want, out)
}
@@ -1162,7 +1162,7 @@ func assertBoundedIDOnlyFallback(t *testing.T, out string) {
// id is reachable without knowing its thread; paging keeps it reachable even
// when it is older than the tail window.
for _, want := range []string{
- "multica issue comment list issue-fallback-1 --thread <comment-id> --tail 30 --output json",
+ "multica issue comment list issue-fallback-1 --thread <comment-id> --tail 30 --compact --output json",
"accepts a reply id",
"Next reply cursor",
"--before-id",