Skip to content

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

Go

fix: preserve active task intent in steer frames (#8621)

Multica Eveb866dacd1cc5
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index 205622fd45..1005e14eaa 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -9311,7 +9311,16 @@ func formatCommentSteerInstruction(authorName, content string) string {
if authorName == "" {
authorName = "a user"
}
- return fmt.Sprintf("[STEER] Human %s left a new comment while you were working:\n\n%s", strconv.Quote(authorName), content)
+ return fmt.Sprintf(`[STEER] Human %s left a new comment while you were working.
+
+Treat this comment as additional guidance for the same active task, not as a replacement:
+- Preserve and complete the original objective.
+- Merge this comment into the work and the turn's single final response.
+- Do not send a separate acknowledgement.
+- Replace or cancel the original objective only if the human explicitly asks for replacement or cancellation.
+
+Human comment:
+%s`, strconv.Quote(authorName), content)
}
func (d *Daemon) executeAndDrain(ctx context.Context, backend agent.Backend, prompt string, opts agent.ExecOptions, taskLog *slog.Logger, taskID, codexHome string, msgSeq *atomic.Int32) (agent.Result, int32, error) {
diff --git a/server/internal/daemon/pending_work_hint_test.go b/server/internal/daemon/pending_work_hint_test.go
index 3dc77a64af..8a600d6f19 100644
--- a/server/internal/daemon/pending_work_hint_test.go
+++ b/server/internal/daemon/pending_work_hint_test.go
@@ -129,9 +129,18 @@ func TestHandleHeartbeatActionsNegotiatesTaskSteerServerCapability(t *testing.T)
}
}
-func TestFormatCommentSteerInstructionCarriesHumanSource(t *testing.T) {
+func TestFormatCommentSteerInstructionPreservesActiveTaskContract(t *testing.T) {
got := formatCommentSteerInstruction("Alice\nAdmin", "keep the migration reversible")
- want := "[STEER] Human \"Alice Admin\" left a new comment while you were working:\n\nkeep the migration reversible"
+ want := `[STEER] Human "Alice Admin" left a new comment while you were working.
+
+Treat this comment as additional guidance for the same active task, not as a replacement:
+- Preserve and complete the original objective.
+- Merge this comment into the work and the turn's single final response.
+- Do not send a separate acknowledgement.
+- Replace or cancel the original objective only if the human explicitly asks for replacement or cancellation.
+
+Human comment:
+keep the migration reversible`
if got != want {
t.Fatalf("steer instruction = %q, want %q", got, want)
}
diff --git a/server/pkg/agent/claude_test.go b/server/pkg/agent/claude_test.go
index a7fad53076..74b3d46c6a 100644
--- a/server/pkg/agent/claude_test.go
+++ b/server/pkg/agent/claude_test.go
@@ -596,6 +596,29 @@ func TestBuildClaudeInputEncodesUserMessage(t *testing.T) {
}
}
+func TestBuildClaudeInputPreservesSteerFraming(t *testing.T) {
+ t.Parallel()
+
+ instruction := "[STEER] preserve ORIGINAL and merge STEERED into one final response"
+ data, err := buildClaudeInput(instruction)
+ if err != nil {
+ t.Fatalf("buildClaudeInput: %v", err)
+ }
+ var payload struct {
+ Message struct {
+ Content []struct {
+ Text string `json:"text"`
+ } `json:"content"`
+ } `json:"message"`
+ }
+ if err := json.Unmarshal(bytes.TrimSpace(data), &payload); err != nil {
+ t.Fatalf("unmarshal payload: %v", err)
+ }
+ if len(payload.Message.Content) != 1 || payload.Message.Content[0].Text != instruction {
+ t.Fatalf("Claude steer payload = %+v, want exact framed instruction", payload.Message.Content)
+ }
+}
+
func TestMergeEnvFiltersClaudeCodeVars(t *testing.T) {
t.Parallel()
diff --git a/server/pkg/agent/codex_test.go b/server/pkg/agent/codex_test.go
index 5a9a0233a7..542c06f4a8 100644
--- a/server/pkg/agent/codex_test.go
+++ b/server/pkg/agent/codex_test.go
@@ -46,8 +46,9 @@ func TestSteerCodexTurnUsesExpectedActiveTurn(t *testing.T) {
c, stdin, _ := newTestCodexClient(t)
c.setThreadID("thread-current")
c.setActiveTurnID("turn-current")
+ instruction := "[STEER] preserve ORIGINAL and merge STEERED into one final response"
done := make(chan error, 1)
- go func() { done <- steerCodexTurn(context.Background(), c, "new constraint") }()
+ go func() { done <- steerCodexTurn(context.Background(), c, instruction) }()
deadline := time.Now().Add(time.Second)
for len(stdin.Lines()) == 0 && time.Now().Before(deadline) {
@@ -73,7 +74,7 @@ func TestSteerCodexTurnUsesExpectedActiveTurn(t *testing.T) {
t.Fatalf("input = %#v, want one text item", params["input"])
}
item, ok := input[0].(map[string]any)
- if !ok || item["type"] != "text" || item["text"] != "new constraint" {
+ if !ok || item["type"] != "text" || item["text"] != instruction {
t.Fatalf("input item = %#v", input[0])
}
c.handleLine(`{"jsonrpc":"2.0","id":1,"result":{}}`)
@@ -82,6 +83,26 @@ func TestSteerCodexTurnUsesExpectedActiveTurn(t *testing.T) {
}
}
+func TestSteerCodexTurnPropagatesProviderFailure(t *testing.T) {
+ c, stdin, _ := newTestCodexClient(t)
+ c.setThreadID("thread-current")
+ c.setActiveTurnID("turn-current")
+ done := make(chan error, 1)
+ go func() { done <- steerCodexTurn(context.Background(), c, "framed instruction") }()
+
+ deadline := time.Now().Add(time.Second)
+ for len(stdin.Lines()) == 0 && time.Now().Before(deadline) {
+ time.Sleep(time.Millisecond)
+ }
+ if len(stdin.Lines()) != 1 {
+ t.Fatalf("steer requests = %d, want 1", len(stdin.Lines()))
+ }
+ c.handleLine(`{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"active turn is not steerable"}}`)
+ if err := <-done; err == nil || !strings.Contains(err.Error(), "active turn is not steerable") {
+ t.Fatalf("steer error = %v, want provider failure", err)
+ }
+}
+
type fakeStdin struct {
mu sync.Mutex
data []byte