Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(agent): keep Reasonix off the ask tool in unattended tasks (#6745)
Bohan Jiang8eaa0d229f0f
diff --git a/server/pkg/agent/reasonix.go b/server/pkg/agent/reasonix.goindex f75fa5a6c9..48c1b40fa5 100644--- a/server/pkg/agent/reasonix.go+++ b/server/pkg/agent/reasonix.go@@ -43,6 +43,34 @@ func reasonixACPLaunchArgs() []string {}}+// reasonixUnattendedNotice tells Reasonix that this turn has no interactive+// user, so it must not reach for the `ask` tool.+//+// Reasonix registers `ask` unconditionally and its ACP server wires an asker+// for every session, so the runtime's own "no interactive user" fallback —+// which answers the question with "decide for yourself" — is unreachable over+// ACP. A question that does arrive can only be refused, and Reasonix reads an+// unanswered question as a dismissal and cancels the whole turn.+//+// This rides the per-turn user message rather than the AGENTS.md runtime brief+// because two agents can call `ask` in one turn: the executor, which reads+// AGENTS.md, and the planner, which runs on its own system prompt and never+// sees the workdir brief. The user message is the only surface both read.+const reasonixUnattendedNotice = "Unattended Multica task: there is no interactive user in this session. " ++ "Do NOT call the `ask` tool — nobody can answer it, and an unanswered question cancels the whole turn. " ++ "When a decision is genuinely open, take the most conservative reversible option, keep going, " ++ "and state the assumption you made in your final issue comment."++// withReasonixUnattendedNotice appends the unattended notice to the per-turn+// prompt. It lands last so it sits after any quoted issue or comment body the+// daemon injected, and an empty prompt still carries the constraint.+func withReasonixUnattendedNotice(prompt string) string {+ if strings.TrimSpace(prompt) == "" {+ return reasonixUnattendedNotice+ }+ return prompt + "\n\n" + reasonixUnattendedNotice+}+// reasonixReaderDrainGrace bounds how long the turn waits for trailing ACP// notifications after the session/prompt response. A var, not a const, so// tests can shorten it. Mirrors qoderReaderDrainGrace / traecliReaderDrainGrace.@@ -374,12 +402,13 @@ func (b *reasonixBackend) Execute(ctx context.Context, prompt string, opts ExecO// 4. Send the prompt and wait for PromptResponse. Reasonix loads// AGENTS.md from cwd, so the daemon deliberately does not duplicate the- // runtime brief in this user message.+ // runtime brief in this user message — only the unattended notice, which+ // AGENTS.md cannot deliver to both agents in the turn.streamingCurrentTurn.Store(true)_, err = c.request(runCtx, "session/prompt", map[string]any{"sessionId": sessionID,"prompt": []map[string]any{- {"type": "text", "text": prompt},+ {"type": "text", "text": withReasonixUnattendedNotice(prompt)},},})if err != nil {diff --git a/server/pkg/agent/reasonix_execute_unix_test.go b/server/pkg/agent/reasonix_execute_unix_test.goindex 9cc3a96d8e..afc3cf4a81 100644--- a/server/pkg/agent/reasonix_execute_unix_test.go+++ b/server/pkg/agent/reasonix_execute_unix_test.go@@ -150,6 +150,41 @@ done}}+func TestReasonixPromptCarriesUnattendedNotice(t *testing.T) {+ t.Parallel()+ recordPath := filepath.Join(t.TempDir(), "frames.jsonl")+ fakePath := filepath.Join(t.TempDir(), "reasonix")+ writeTestExecutable(t, fakePath, []byte(fakeACPRecordingScript(recordPath, "notice-session", "{}")))+ backend, err := New("reasonix", Config{ExecutablePath: fakePath, Logger: slog.Default()})+ if err != nil {+ t.Fatalf("New(reasonix): %v", err)+ }+ session, err := backend.Execute(context.Background(), "Reply to the comment.", ExecOptions{Timeout: 5 * time.Second})+ if err != nil {+ t.Fatalf("Execute: %v", err)+ }+ go func() {+ for range session.Messages {+ }+ }()+ if result := <-session.Result; result.Status != "completed" {+ t.Fatalf("result = %+v", result)+ }++ frame := findRecordedFrame(t, recordPath, "session/prompt")+ blocks := frame["params"].(map[string]any)["prompt"].([]any)+ if len(blocks) != 1 {+ t.Fatalf("prompt blocks = %+v, want one text block", blocks)+ }+ text := blocks[0].(map[string]any)["text"].(string)+ if !strings.HasPrefix(text, "Reply to the comment.") {+ t.Fatalf("prompt dropped the task text: %q", text)+ }+ if !strings.Contains(text, reasonixUnattendedNotice) {+ t.Fatalf("prompt = %q, want the unattended notice appended", text)+ }+}+func TestReasonixResumeFiltersUnsupportedSSEMCP(t *testing.T) {t.Parallel()recordPath := filepath.Join(t.TempDir(), "frames.jsonl")diff --git a/server/pkg/agent/reasonix_test.go b/server/pkg/agent/reasonix_test.goindex a6e73a0b4c..52ce068624 100644--- a/server/pkg/agent/reasonix_test.go+++ b/server/pkg/agent/reasonix_test.go@@ -72,6 +72,38 @@ func TestReasonixPermissionPolicy(t *testing.T) {}}+func TestReasonixUnattendedNoticeRidesEveryPrompt(t *testing.T) {+ t.Parallel()+ tests := []struct {+ name string+ prompt string+ want string+ }{+ {name: "appended after the task prompt", prompt: "Reply to the comment.", want: "Reply to the comment.\n\n" + reasonixUnattendedNotice},+ {name: "empty prompt still carries the constraint", prompt: " ", want: reasonixUnattendedNotice},+ }+ for _, tt := range tests {+ tt := tt+ t.Run(tt.name, func(t *testing.T) {+ t.Parallel()+ if got := withReasonixUnattendedNotice(tt.prompt); got != tt.want {+ t.Fatalf("prompt = %q, want %q", got, tt.want)+ }+ })+ }++ // The notice exists to keep BOTH Reasonix agents off the ask tool — the+ // executor and the planner, which never sees AGENTS.md. Naming the tool and+ // the fallback behaviour is the whole payload; a reword that drops either+ // leaves the planner with no instruction at all.+ if !strings.Contains(reasonixUnattendedNotice, "`ask`") {+ t.Fatalf("notice must name the ask tool: %q", reasonixUnattendedNotice)+ }+ if !strings.Contains(reasonixUnattendedNotice, "no interactive user") {+ t.Fatalf("notice must state that no user can answer: %q", reasonixUnattendedNotice)+ }+}+func TestReasonixPermissionMetadataWarningDetection(t *testing.T) {t.Parallel()tests := []struct {