Skip to content

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

Go

MUL-8448: fix Quick Create default assignment via picker context (#9793)

Multica Eve37c8fb5a172a
diff --git a/server/cmd/multica/cmd_issue.go b/server/cmd/multica/cmd_issue.go
index 04d156f5b3..ea9a043664 100644
--- a/server/cmd/multica/cmd_issue.go
+++ b/server/cmd/multica/cmd_issue.go
@@ -668,6 +668,7 @@ func init() {
issueCreateCmd.Flags().String("priority", "", "Issue priority")
issueCreateCmd.Flags().String("assignee", "", "Assignee name (member, agent, or squad; fuzzy match)")
issueCreateCmd.Flags().String("assignee-id", "", "Assignee UUID — member, agent, or squad (mutually exclusive with --assignee)")
+ issueCreateCmd.Flags().Bool("assignee-picker", false, "Assign to the agent or squad selected in Quick Create (requires quick-create task context; mutually exclusive with --assignee and --assignee-id)")
issueCreateCmd.Flags().String("parent", "", "Parent issue ID")
issueCreateCmd.Flags().Int("stage", 0, "Stage ordinal (>=1) grouping this sub-issue into an ordered barrier group under its parent; omit for unstaged. The parent assignee is woken only when every sub-issue in a stage finishes.")
issueCreateCmd.Flags().String("project", "", "Project ID")
@@ -1479,6 +1480,30 @@ func quickCreateAttachmentIDsFromEnv() ([]string, error) {
return appendUniqueStrings(nil, ids...), nil
}
+func pickIssueCreateAssignee(ctx context.Context, client *cli.APIClient, cmd *cobra.Command) (string, string, bool, error) {
+ if cmd.Flags().Changed("assignee-picker") && (cmd.Flags().Changed("assignee") || cmd.Flags().Changed("assignee-id")) {
+ return "", "", false, errors.New("--assignee-picker, --assignee, and --assignee-id are mutually exclusive")
+ }
+ picker, _ := cmd.Flags().GetBool("assignee-picker")
+ if !picker {
+ return pickAssigneeFromFlags(ctx, client, cmd, "assignee", "assignee-id", issueAssigneeKinds)
+ }
+ if strings.TrimSpace(os.Getenv("MULTICA_QUICK_CREATE_TASK_ID")) == "" {
+ return "", "", false, errors.New("--assignee-picker requires a quick-create task context")
+ }
+ aType := os.Getenv("MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE")
+ if aType != "agent" && aType != "squad" {
+ return "", "", false, errors.New("invalid picker assignee type: MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE must be agent or squad")
+ }
+ aID := strings.TrimSpace(os.Getenv("MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID"))
+ if !uuidRegexp.MatchString(aID) {
+ return "", "", false, errors.New("MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID must contain a canonical UUID")
+ }
+ // The server validates workspace membership, archive state and invocation
+ // permissions for this typed pair, just as it does for explicit assignees.
+ return aType, aID, true, nil
+}
+
func runIssueCreate(cmd *cobra.Command, _ []string) error {
title, _ := cmd.Flags().GetString("title")
if title == "" {
@@ -1579,7 +1604,7 @@ func runIssueCreate(cmd *cobra.Command, _ []string) error {
if v, _ := cmd.Flags().GetBool("allow-duplicate"); v {
body["allow_duplicate"] = true
}
- aType, aID, hasAssignee, resolveErr := pickAssigneeFromFlags(ctx, client, cmd, "assignee", "assignee-id", issueAssigneeKinds)
+ aType, aID, hasAssignee, resolveErr := pickIssueCreateAssignee(ctx, client, cmd)
if resolveErr != nil {
return fmt.Errorf("resolve assignee: %w", resolveErr)
}
diff --git a/server/cmd/multica/cmd_issue_picker_test.go b/server/cmd/multica/cmd_issue_picker_test.go
new file mode 100644
index 0000000000..596e1a1247
--- /dev/null
+++ b/server/cmd/multica/cmd_issue_picker_test.go
@@ -0,0 +1,126 @@
+package main
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+func TestIssueCreateRegistersAssigneePickerFlag(t *testing.T) {
+ flag := issueCreateCmd.Flags().Lookup("assignee-picker")
+ if flag == nil || flag.Value.Type() != "bool" {
+ t.Fatal("issue create must expose the boolean --assignee-picker flag")
+ }
+}
+
+func TestRunIssueCreatePickerAssignee(t *testing.T) {
+ t.Chdir(t.TempDir())
+ const (
+ taskID = "cccc1111-2222-3333-4444-555566667777"
+ agentID = "282bdf4e-b502-4ca9-8fae-0c842f973e63"
+ squadID = "aaaa1111-2222-3333-4444-555555555555"
+ explicitID = "bbbb1111-2222-3333-4444-666666666666"
+ )
+ for _, tc := range []struct {
+ name, taskID, pickerType, pickerID string
+ args []string
+ wantType, wantID, wantErr string
+ serverStatus int
+ }{
+ {name: "agent picker", taskID: taskID, pickerType: "agent", pickerID: agentID, args: []string{"--assignee-picker"}, wantType: "agent", wantID: agentID},
+ {name: "squad picker", taskID: taskID, pickerType: "squad", pickerID: squadID, args: []string{"--assignee-picker"}, wantType: "squad", wantID: squadID},
+ {name: "unrecognized assignee omits ownership", taskID: taskID, pickerType: "agent", pickerID: agentID},
+ {name: "ordinary create ignores picker environment", pickerType: "agent", pickerID: agentID},
+ {name: "false picker does not assign", taskID: taskID, pickerType: "agent", pickerID: agentID, args: []string{"--assignee-picker=false"}},
+ {name: "explicit assignee keeps precedence", taskID: taskID, pickerType: "squad", pickerID: squadID, args: []string{"--assignee-id", explicitID}, wantType: "agent", wantID: explicitID},
+ {name: "explicit empty ID still fails", taskID: taskID, pickerType: "agent", pickerID: agentID, args: []string{"--assignee-id="}, wantErr: "canonical UUID"},
+ {name: "explicit invalid ID still fails", taskID: taskID, pickerType: "agent", pickerID: agentID, args: []string{"--assignee-id", "282df4e-b502-4ca9-8fae-0c842f973e63"}, wantErr: "canonical UUID"},
+ {name: "picker conflicts with name", args: []string{"--assignee-picker", "--assignee", "someone"}, wantErr: "mutually exclusive"},
+ {name: "picker conflicts with ID", args: []string{"--assignee-picker", "--assignee-id", explicitID}, wantErr: "mutually exclusive"},
+ {name: "picker conflicts with empty ID", args: []string{"--assignee-picker", "--assignee-id="}, wantErr: "mutually exclusive"},
+ {name: "false picker still conflicts with explicit flag", args: []string{"--assignee-picker=false", "--assignee-id", explicitID}, wantErr: "mutually exclusive"},
+ {name: "picker requires quick create context", pickerType: "agent", pickerID: agentID, args: []string{"--assignee-picker"}, wantErr: "quick-create"},
+ {name: "missing type", taskID: taskID, pickerID: agentID, args: []string{"--assignee-picker"}, wantErr: "assignee type"},
+ {name: "missing ID", taskID: taskID, pickerType: "agent", args: []string{"--assignee-picker"}, wantErr: "canonical UUID"},
+ {name: "member cannot be a picker", taskID: taskID, pickerType: "member", pickerID: agentID, args: []string{"--assignee-picker"}, wantErr: "assignee type"},
+ {name: "malformed picker ID", taskID: taskID, pickerType: "agent", pickerID: "282df4e-b502-4ca9-8fae-0c842f973e63", args: []string{"--assignee-picker"}, wantErr: "canonical UUID"},
+ {name: "server permission rejection is preserved", taskID: taskID, pickerType: "agent", pickerID: agentID, args: []string{"--assignee-picker"}, wantType: "agent", wantID: agentID, serverStatus: http.StatusForbidden, wantErr: "permission denied"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ var body map[string]any
+ posts := 0
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ switch r.URL.Path {
+ case "/api/issues":
+ if r.Method != http.MethodPost {
+ t.Errorf("issue request method = %s, want POST", r.Method)
+ }
+ posts++
+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
+ t.Errorf("decode create body: %v", err)
+ }
+ if tc.serverStatus != 0 {
+ w.WriteHeader(tc.serverStatus)
+ json.NewEncoder(w).Encode(map[string]any{"error": "permission denied"})
+ return
+ }
+ w.WriteHeader(http.StatusCreated)
+ json.NewEncoder(w).Encode(map[string]any{"id": "created-issue", "title": "Picker regression"})
+ case "/api/agents":
+ json.NewEncoder(w).Encode([]map[string]any{{"id": explicitID, "name": "explicit-agent"}})
+ case "/api/workspaces/ws-1/members", "/api/squads":
+ json.NewEncoder(w).Encode([]map[string]any{})
+ default:
+ t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path)
+ http.NotFound(w, r)
+ }
+ }))
+ defer srv.Close()
+ t.Setenv("MULTICA_SERVER_URL", srv.URL)
+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+ t.Setenv("MULTICA_QUICK_CREATE_TASK_ID", tc.taskID)
+ t.Setenv("MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE", tc.pickerType)
+ t.Setenv("MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID", tc.pickerID)
+ cmd := newIssueCreateTestCmd()
+ if err := cmd.ParseFlags(append([]string{"--title", "Picker regression", "--description", "Unrecognized assignee: unknown"}, tc.args...)); err != nil {
+ t.Fatal(err)
+ }
+ err := runIssueCreate(cmd, nil)
+ if tc.wantErr != "" {
+ if err == nil || !strings.Contains(err.Error(), tc.wantErr) {
+ t.Fatalf("error = %v, want %q", err, tc.wantErr)
+ }
+ if tc.serverStatus == 0 {
+ if posts != 0 {
+ t.Fatalf("invalid assignee caused %d create POST(s), want zero", posts)
+ }
+ return
+ }
+ } else if err != nil {
+ t.Fatal(err)
+ }
+ if posts != 1 {
+ t.Fatalf("create POST count = %d, want one", posts)
+ }
+ if tc.wantType == "" {
+ if _, ok := body["assignee_type"]; ok {
+ t.Errorf("unexpected assignee_type: %v", body["assignee_type"])
+ }
+ if _, ok := body["assignee_id"]; ok {
+ t.Errorf("unexpected assignee_id: %v", body["assignee_id"])
+ }
+ } else if body["assignee_type"] != tc.wantType || body["assignee_id"] != tc.wantID {
+ t.Errorf("assignee = (%v, %v), want (%s, %s)", body["assignee_type"], body["assignee_id"], tc.wantType, tc.wantID)
+ }
+ if tc.taskID != "" && (body["origin_type"] != "quick_create" || body["origin_id"] != tc.taskID) {
+ t.Errorf("quick-create origin was lost: %v", body)
+ }
+ if body["description"] != "Unrecognized assignee: unknown" {
+ t.Errorf("description changed: %v", body["description"])
+ }
+ })
+ }
+}
diff --git a/server/cmd/multica/cmd_issue_test.go b/server/cmd/multica/cmd_issue_test.go
index cc6691bd84..3ece03009d 100644
--- a/server/cmd/multica/cmd_issue_test.go
+++ b/server/cmd/multica/cmd_issue_test.go
@@ -919,6 +919,7 @@ func newIssueCreateTestCmd() *cobra.Command {
cmd.Flags().String("priority", "", "")
cmd.Flags().String("assignee", "", "")
cmd.Flags().String("assignee-id", "", "")
+ cmd.Flags().Bool("assignee-picker", false, "")
cmd.Flags().String("parent", "", "")
cmd.Flags().String("project", "", "")
cmd.Flags().String("due-date", "", "")
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index c4bd5e793f..d017934c74 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -192,6 +192,14 @@ func taskMulticaEnvironment(task Task, provider, agentName, token, configRoot, w
"TMP": tempDir,
"TEMP": tempDir,
}
+ if task.QuickCreatePrompt != "" {
+ assigneeType, assigneeID := "agent", task.AgentID
+ if task.SquadID != "" {
+ assigneeType, assigneeID = "squad", task.SquadID
+ }
+ env["MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE"] = assigneeType
+ env["MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID"] = assigneeID
+ }
if runtime.GOOS != "windows" {
return env
}
diff --git a/server/internal/daemon/daemon_test.go b/server/internal/daemon/daemon_test.go
index f6f760f799..9751f0a20b 100644
--- a/server/internal/daemon/daemon_test.go
+++ b/server/internal/daemon/daemon_test.go
@@ -602,7 +602,7 @@ func TestHermesTaskEnvPassthroughCoversTaskEnvironment(t *testing.T) {
}
seen[name] = true
}
- env := taskMulticaEnvironment(Task{ID: "task-test", AgentID: "agent-test", WorkspaceID: "workspace-test"},
+ env := taskMulticaEnvironment(Task{ID: "task-test", AgentID: "agent-test", WorkspaceID: "workspace-test", QuickCreatePrompt: "create work"},
"hermes", "agent-name", "mat_fixture", "/task/config", "/task/workspaces", "https://task.example", 19514, 3, "/task/tmp")
for name := range env {
if strings.HasPrefix(name, "MULTICA_") && !seen[name] {
diff --git a/server/internal/daemon/execenv/codex_shell_env_test.go b/server/internal/daemon/execenv/codex_shell_env_test.go
index 9f95082e13..2dca3d118d 100644
--- a/server/internal/daemon/execenv/codex_shell_env_test.go
+++ b/server/internal/daemon/execenv/codex_shell_env_test.go
@@ -50,10 +50,12 @@ func TestCodexShellEnvAllowlistUsesExactTaskAndSafeInheritedNames(t *testing.T)
"MULTICA_SERVER_URL=https://wrong.example",
}
explicit := map[string]string{
- "MULTICA_TOKEN": "mat_task",
- "MULTICA_SERVER_URL": "https://task.example",
- "CUSTOM_FLAG": "enabled",
- "ANTHROPIC_API_KEY": "agent-secret",
+ "MULTICA_TOKEN": "mat_task",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE": "agent",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID": "282bdf4e-b502-4ca9-8fae-0c842f973e63",
+ "MULTICA_SERVER_URL": "https://task.example",
+ "CUSTOM_FLAG": "enabled",
+ "ANTHROPIC_API_KEY": "agent-secret",
}
authorizedExplicit := []string{"ANTHROPIC_API_KEY"}
@@ -66,6 +68,8 @@ func TestCodexShellEnvAllowlistUsesExactTaskAndSafeInheritedNames(t *testing.T)
"HTTPS_PROXY",
"LANG",
"LOCALAPPDATA",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE",
"MULTICA_SERVER_URL",
"MULTICA_TOKEN",
"PATH",
diff --git a/server/internal/daemon/execenv/hermes_home.go b/server/internal/daemon/execenv/hermes_home.go
index 6ca8abdb8a..bb872d77b9 100644
--- a/server/internal/daemon/execenv/hermes_home.go
+++ b/server/internal/daemon/execenv/hermes_home.go
@@ -677,6 +677,8 @@ func HermesTaskEnvPassthroughNames() []string {
"MULTICA_AUTOPILOT_ID",
"MULTICA_QUICK_CREATE_TASK_ID",
"MULTICA_QUICK_CREATE_ATTACHMENT_IDS",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID",
}
}
diff --git a/server/internal/daemon/execenv/hermes_home_test.go b/server/internal/daemon/execenv/hermes_home_test.go
index 4f48b3a73c..6975b72556 100644
--- a/server/internal/daemon/execenv/hermes_home_test.go
+++ b/server/internal/daemon/execenv/hermes_home_test.go
@@ -839,6 +839,7 @@ func TestHermesTerminalEnvPassthrough(t *testing.T) {
"MULTICA_AGENT_NAME", "MULTICA_AGENT_ID", "MULTICA_TASK_ID", "MULTICA_TASK_SLOT",
"MULTICA_AUTOPILOT_RUN_ID", "MULTICA_AUTOPILOT_ID",
"MULTICA_QUICK_CREATE_TASK_ID", "MULTICA_QUICK_CREATE_ATTACHMENT_IDS",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE", "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID",
}
for _, tc := range []struct {
name, config string
@@ -870,12 +871,14 @@ func TestHermesTerminalEnvPassthrough(t *testing.T) {
Provider: "hermes",
HermesSourceHome: shared,
HermesEnv: map[string]string{
- "MULTICA_TOKEN": "mat_fixture_not_for_config",
- "MULTICA_AUTOPILOT_RUN_ID": "autopilot_run_fixture",
- "MULTICA_AUTOPILOT_ID": "autopilot_fixture",
- "MULTICA_QUICK_CREATE_TASK_ID": "quick_create_fixture",
- "MULTICA_QUICK_CREATE_ATTACHMENT_IDS": `["attachment_fixture"]`,
- "UNRELATED_SECRET": "unrelated_fixture",
+ "MULTICA_TOKEN": "mat_fixture_not_for_config",
+ "MULTICA_AUTOPILOT_RUN_ID": "autopilot_run_fixture",
+ "MULTICA_AUTOPILOT_ID": "autopilot_fixture",
+ "MULTICA_QUICK_CREATE_TASK_ID": "quick_create_fixture",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE": "squad",
+ "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID": "aaaa1111-2222-3333-4444-555555555555",
+ "MULTICA_QUICK_CREATE_ATTACHMENT_IDS": `["attachment_fixture"]`,
+ "UNRELATED_SECRET": "unrelated_fixture",
},
Task: task,
}, testLogger())
diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.go
index e5186fe582..39aa84d0e7 100644
--- a/server/internal/daemon/execenv/runtime_config_sections.go
+++ b/server/internal/daemon/execenv/runtime_config_sections.go
@@ -343,7 +343,7 @@ func writeAvailableCommandsQuickCreate(b *strings.Builder) {
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. Inline `--description \"...\"` is only for a short single-line body with no code, quotes, backticks or `$()`. Anything multi-line, or carrying code snippets / file paths / quotes / backticks / `$()` — which quick-create descriptions usually are — MUST go to a file, because the shell rewrites or truncates rich text passed inline (MUL-2904). 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 — never run `--description-file` against a file whose write did not succeed. The CLI rejects a path outside the workdir so a stale file from another run can't leak in (MUL-4252).\n\n")
+ b.WriteString("- `multica issue create --title \"...\" [--description \"...\" | --description-file <path> | --description-stdin] [--priority X] [--status X] [--assignee X | --assignee-id <uuid> | --assignee-picker] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <YYYY-MM-DD>] [--attachment <path>]` — Create a new issue; `--attachment` may be repeated. Inline `--description \"...\"` is only for a short single-line body with no code, quotes, backticks or `$()`. Anything multi-line, or carrying code snippets / file paths / quotes / backticks / `$()` — which quick-create descriptions usually are — MUST go to a file, because the shell rewrites or truncates rich text passed inline (MUL-2904). 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 — never run `--description-file` against a file whose write did not succeed. The CLI rejects a path outside the workdir so a stale file from another run can't leak in (MUL-4252).\n\n")
}
// writeIssueBodyFormatting emits the default Markdown hierarchy for issue
diff --git a/server/internal/daemon/prompt.go b/server/internal/daemon/prompt.go
index 883d4ea2ee..f71390f3f8 100644
--- a/server/internal/daemon/prompt.go
+++ b/server/internal/daemon/prompt.go
@@ -379,31 +379,11 @@ func buildQuickCreatePrompt(task Task) string {
// assignee
b.WriteString("- **assignee**:\n")
- b.WriteString(" - When the user names someone (\"assign to X\" / \"@X\"), call `multica workspace member list --output json`, `multica agent list --output json`, and `multica squad list --output json` and find the matching entity by display name. Squads are first-class assignees too — a squad name (e.g. \"Super Human\") routes work to the squad leader, who then delegates. On a clean unambiguous match, prefer `--assignee-id <uuid>` using the `user_id` (member) or `id` (agent or squad) from that JSON — UUID matching is exact and robust to name collisions in workspaces with overlapping names. `--assignee <name>` (fuzzy) is acceptable as a fallback when names are unambiguous. On no match or ambiguous match, do NOT pass either flag — instead append a final line to the description: `Unrecognized assignee: X`.\n")
+ b.WriteString(" - When the user names someone (\"assign to X\" / \"@X\"), call `multica workspace member list --output json`, `multica agent list --output json`, and `multica squad list --output json` and find the matching entity by display name. Squads are first-class assignees too — a squad name (e.g. \"Super Human\") routes work to the squad leader, who then delegates. On a clean unambiguous match, prefer `--assignee-id <uuid>` using the `user_id` (member) or `id` (agent or squad) from that JSON — UUID matching is exact and robust to name collisions in workspaces with overlapping names. `--assignee <name>` (fuzzy) is acceptable as a fallback when names are unambiguous. On no match or ambiguous match, do NOT pass `--assignee`, `--assignee-id`, or `--assignee-picker` — instead append a final line to the description: `Unrecognized assignee: X`.\n")
b.WriteString(" - Treat bare @-routing as an assignee directive even when the user did not write the English word \"assign\". This includes Chinese imperatives like `让 @独立团 review 这个 PR`, `给 @X 处理`, or `交给 @X`; strip the leading `@`/`@` before matching display names. Do not keep that routing wrapper or `@Name` in the description unless it is a true CC-style notification rather than ownership. If the matched entity is a squad, pass the squad's `id` as `--assignee-id`, not the leader agent's id.\n")
- agentID := ""
- agentName := ""
- if task.Agent != nil {
- agentID = task.Agent.ID
- agentName = task.Agent.Name
- }
- switch {
- case task.SquadID != "":
- // The user opened quick-create with a SQUAD selected. The task
- // runs on the squad's leader agent, but the squad is the expected
- // owner — assigning to the leader would mask the squad's
- // delegation flow. Always point the default at the squad UUID.
- if task.SquadName != "" {
- fmt.Fprintf(&b, " - When the user did NOT name an assignee, default to the picker SQUAD %q: pass `--assignee-id %q` (the squad's UUID). The user opened quick-create with the squad selected; you (the leader agent) are running on the squad's behalf, so the squad — not you — is the expected owner. Never leave the issue unassigned, and do not assign it to your own agent UUID.\n\n", task.SquadName, task.SquadID)
- } else {
- fmt.Fprintf(&b, " - When the user did NOT name an assignee, default to the picker SQUAD: pass `--assignee-id %q` (the squad's UUID). The user opened quick-create with the squad selected; you (the leader agent) are running on the squad's behalf, so the squad — not you — is the expected owner. Never leave the issue unassigned, and do not assign it to your own agent UUID.\n\n", task.SquadID)
- }
- case agentID != "":
- fmt.Fprintf(&b, " - When the user did NOT name an assignee, default to YOURSELF: pass `--assignee-id %q` (your agent UUID). The picker agent is the expected owner because the user opened quick-create with you selected — never leave the issue unassigned. Use the UUID flag, not `--assignee <name>`, so the assignment is unambiguous even when other agents share part of your name.\n\n", agentID)
- case agentName != "":
- fmt.Fprintf(&b, " - When the user did NOT name an assignee, default to YOURSELF: pass `--assignee %q`. The picker agent is the expected owner because the user opened quick-create with you selected — never leave the issue unassigned.\n\n", agentName)
- default:
- b.WriteString(" - When the user did NOT name an assignee, default to YOURSELF (the picker agent): pass `--assignee-id <your agent UUID>` (preferred) or `--assignee <your agent name>`. Never leave the issue unassigned.\n\n")
+ b.WriteString(" - When the user did NOT name an assignee, pass `--assignee-picker`. The CLI assigns the issue to the agent or squad selected in the quick-create modal using task context. Do not pass `--assignee` or `--assignee-id` for this default, and do not copy any picker UUID into the command. Never leave the issue unassigned in this case.\n\n")
+ if task.SquadID != "" {
+ b.WriteString(" - You are the leader agent running on behalf of the selected squad. For default assignment, use `--assignee-picker` to preserve squad ownership; do not substitute your own agent identity.\n\n")
}
if task.QuickCreateDueDate != "" {
diff --git a/server/internal/daemon/prompt_test.go b/server/internal/daemon/prompt_test.go
index 9e13f0a8e7..ece499fd15 100644
--- a/server/internal/daemon/prompt_test.go
+++ b/server/internal/daemon/prompt_test.go
@@ -140,52 +140,6 @@ func TestBuildQuickCreatePromptAssigneeIncludesSquads(t *testing.T) {
}
}
-// TestBuildQuickCreatePromptSquadDefaultsToSquad locks in the MUL-2203
-// fix: when the picker was a squad, the task runs on the squad's leader
-// agent, but the default assignee for issues created by this run must
-// point at the SQUAD's UUID — not the leader agent's UUID. The previous
-// "default to YOURSELF" instruction made squad-created issues land under
-// the leader, hiding them from the squad's delegation flow.
-func TestBuildQuickCreatePromptSquadDefaultsToSquad(t *testing.T) {
- const (
- squadID = "aaaa1111-2222-3333-4444-555555555555"
- squadName = "独立团"
- leaderID = "bbbb1111-2222-3333-4444-666666666666"
- )
- out := buildQuickCreatePrompt(Task{
- QuickCreatePrompt: "fix the login button color",
- Agent: &AgentData{ID: leaderID, Name: "leader-agent"},
- SquadID: squadID,
- SquadName: squadName,
- })
-
- // The default-assignee instruction must point at the squad UUID.
- if !strings.Contains(out, "--assignee-id \""+squadID+"\"") {
- t.Errorf("buildQuickCreatePrompt with SquadID must default to the squad's UUID, got:\n%s", out)
- }
- // And it must NOT tell the agent to default to itself (the leader).
- if strings.Contains(out, "--assignee-id \""+leaderID+"\"") {
- t.Errorf("buildQuickCreatePrompt with SquadID must NOT default to the leader agent's UUID, got:\n%s", out)
- }
- // The squad name should appear in the instruction so the agent has
- // human-readable context for the routing decision.
- if !strings.Contains(out, squadName) {
- t.Errorf("buildQuickCreatePrompt with SquadID should mention the squad name %q, got:\n%s", squadName, out)
- }
- // And the prompt must explicitly call out the squad-vs-leader rule
- // so the agent does not silently regress to "default to YOURSELF".
- mustContain := []string{
- "picker SQUAD",
- "running on the squad's behalf",
- "do not assign it to your own agent UUID",
- }
- for _, s := range mustContain {
- if !strings.Contains(out, s) {
- t.Errorf("buildQuickCreatePrompt with SquadID missing %q\n--- output ---\n%s", s, out)
- }
- }
-}
-
// TestBuildQuickCreatePromptProjectPinning verifies that when the user
// pins a project in the quick-create modal, the prompt instructs the agent
// to pass `--project <uuid>` exactly. Without this, the agent would re-read
diff --git a/server/internal/daemon/quick_create_picker_test.go b/server/internal/daemon/quick_create_picker_test.go
new file mode 100644
index 0000000000..1fe7be18a4
--- /dev/null
+++ b/server/internal/daemon/quick_create_picker_test.go
@@ -0,0 +1,79 @@
+package daemon
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestQuickCreatePickerPrompt(t *testing.T) {
+ t.Parallel()
+ const (
+ agentID = "282bdf4e-b502-4ca9-8fae-0c842f973e63"
+ squadID = "aaaa1111-2222-3333-4444-555555555555"
+ )
+ for _, squad := range []string{"", squadID} {
+ t.Run("squad="+squad, func(t *testing.T) {
+ prompt := buildQuickCreatePrompt(Task{
+ QuickCreatePrompt: "fix the login button color",
+ AgentID: agentID,
+ Agent: &AgentData{ID: agentID, Name: "picker-agent"},
+ SquadID: squad,
+ })
+ for _, want := range []string{
+ "When the user did NOT name an assignee",
+ "pass `--assignee-picker`",
+ "On no match or ambiguous match",
+ "do NOT pass `--assignee`, `--assignee-id`, or `--assignee-picker`",
+ "Unrecognized assignee: X",
+ } {
+ if !strings.Contains(prompt, want) {
+ t.Errorf("prompt missing %q", want)
+ }
+ }
+ for _, id := range []string{agentID, squadID} {
+ if strings.Contains(prompt, id) {
+ t.Errorf("picker identity %s must not be copied through the model", id)
+ }
+ }
+ })
+ }
+}
+
+func TestQuickCreatePickerEnvironment(t *testing.T) {
+ t.Parallel()
+ const (
+ agentID = "282bdf4e-b502-4ca9-8fae-0c842f973e63"
+ squadID = "aaaa1111-2222-3333-4444-555555555555"
+ typeKey = "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_TYPE"
+ idKey = "MULTICA_QUICK_CREATE_DEFAULT_ASSIGNEE_ID"
+ )
+ for _, tc := range []struct {
+ name, prompt, squad, wantType, wantID string
+ }{
+ {name: "ordinary task does not export picker"},
+ {name: "squad task outside quick create does not export picker", squad: squadID},
+ {name: "agent", prompt: "create work", wantType: "agent", wantID: agentID},
+ {name: "squad takes precedence over leader", prompt: "create work", squad: squadID, wantType: "squad", wantID: squadID},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ env := taskMulticaEnvironment(Task{
+ AgentID: agentID, QuickCreatePrompt: tc.prompt, SquadID: tc.squad,
+ }, "codex", "picker-agent", "mat_fixture", "/task/config", "/task/workspaces", "https://task.example", 19514, 0, "/task/tmp")
+ if tc.prompt == "" {
+ for _, key := range []string{typeKey, idKey} {
+ if _, ok := env[key]; ok {
+ t.Errorf("non-quick-create task exported %s", key)
+ }
+ }
+ return
+ }
+ if env[typeKey] != tc.wantType || env[idKey] != tc.wantID {
+ t.Fatalf("picker = (%q, %q), want (%q, %q)", env[typeKey], env[idKey], tc.wantType, tc.wantID)
+ }
+ layerCustomEnvAndHermesHome(env, map[string]string{typeKey: "member", idKey: "wrong-owner"}, "", nil)
+ if env[typeKey] != tc.wantType || env[idKey] != tc.wantID {
+ t.Fatal("custom environment replaced daemon-owned picker identity")
+ }
+ })
+ }
+}