Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(agent): steer running Hermes turns in issues and Chat via ACP /steer (MUL-9970) (#11419)
Bohan Jiang40cbc0df8257
diff --git a/README.ja.md b/README.ja.mdindex b4c65400a1..9dac1f91ef 100644--- a/README.ja.md+++ b/README.ja.md@@ -120,7 +120,7 @@ Multica は、こうしたエージェントとチームメイトを 1 つのワ</p>- **[実行ログ](https://multica.ai/docs/ja/tasks) →** すべてのツール呼び出し、コマンド、エラーをタイムスタンプ付きで再生できます。-- **[実行中のエージェントに指示を出す](https://multica.ai/docs/ja/providers#割り込みへの対応) →** 作業中に返信すると、メッセージは次の実行ではなく今の実行に届きます。現在は Claude Code、Codex、Cursor Agent、Grok、Kiro、Pi、Antigravity に対応しています。+- **[実行中のエージェントに指示を出す](https://multica.ai/docs/ja/providers#割り込みへの対応) →** 作業中に返信すると、メッセージは次の実行ではなく今の実行に届きます。現在は Claude Code、Codex、Cursor Agent、Grok、Hermes、Kiro、Pi、Antigravity に対応しています。- **利用状況の分析 →** 各実行にかかったコストを、エージェント別・タスク別に確認できます。- **[レビューゲート](https://multica.ai/docs/ja/issues) →** 作業は main に直接入らず、まずレビューに回ります。何をリリースするかはあなたが決めます。- **[インボックス](https://multica.ai/docs/ja/inbox) →** 細かなステップごとではなく、エージェントが判断を求めてきたときだけ通知が届きます。diff --git a/README.md b/README.mdindex 576174d4cb..a2117d9f52 100644--- a/README.md+++ b/README.md@@ -123,7 +123,7 @@ How it compares: [Linear and Jira](https://multica.ai/docs/compare/linear-jira)</p>- **[Execution log](https://multica.ai/docs/tasks) →** Replay every tool call, command, and error, timestamped.-- **[Steer a running agent](https://multica.ai/docs/providers#steer-a-running-run) →** Reply while it works and the message lands in the current run, not the next one. Claude Code, Codex, Cursor Agent, Grok, Kiro, Pi, and Antigravity today.+- **[Steer a running agent](https://multica.ai/docs/providers#steer-a-running-run) →** Reply while it works and the message lands in the current run, not the next one. Claude Code, Codex, Cursor Agent, Grok, Hermes, Kiro, Pi, and Antigravity today.- **Usage analytics →** See what each run cost, per agent and per issue.- **[Review gates](https://multica.ai/docs/issues) →** Work lands in review, not in main. You decide what ships.- **[Inbox](https://multica.ai/docs/inbox) →** Get pinged when an agent needs a call, not for every step.diff --git a/README.zh.md b/README.zh.mdindex 426d35fbec..f44b83d8a7 100644--- a/README.zh.md+++ b/README.zh.md@@ -116,7 +116,7 @@ diff,全都挂在同一个任务下——没人需要重新捋一遍上下文</p>- **[执行日志](https://multica.ai/docs/zh/tasks) →** 每次工具调用、命令和报错都带时间戳,可以完整回放。-- **[运行中插话](https://multica.ai/docs/zh/providers#插话支持) →** 智能体干活时直接回复,消息会进到当前这次运行,不用等下一次。目前支持 Claude Code、Codex、Cursor Agent、Grok、Kiro、Pi 和 Antigravity。+- **[运行中插话](https://multica.ai/docs/zh/providers#插话支持) →** 智能体干活时直接回复,消息会进到当前这次运行,不用等下一次。目前支持 Claude Code、Codex、Cursor Agent、Grok、Hermes、Kiro、Pi 和 Antigravity。- **用量统计 →** 每次运行花了多少,按智能体、按任务都看得到。- **[人来验收](https://multica.ai/docs/zh/issues) →** 活先进入审核中,不直接进 main。上不上线你说了算。- **[收件箱](https://multica.ai/docs/zh/inbox) →** 只在智能体需要你拍板时提醒你,而不是每一步都来烦你。diff --git a/apps/docs/content/docs/providers.fr.mdx b/apps/docs/content/docs/providers.fr.mdxindex 2b3fc2a545..e806ccdb19 100644--- a/apps/docs/content/docs/providers.fr.mdx+++ b/apps/docs/content/docs/providers.fr.mdx@@ -96,6 +96,7 @@ Vous pouvez [ajouter un message à une exécution encore en cours](/mentioning-a| Codex | 0.100.0 || Cursor Agent | 2026.10.14 || Grok | 1.0.14 |+| Hermes | 0.22.3 || Kiro CLI | 2.33.0 || Pi | 1.4.0 |diff --git a/apps/docs/content/docs/providers.ja.mdx b/apps/docs/content/docs/providers.ja.mdxindex 29580e4e57..a0d040f9c4 100644--- a/apps/docs/content/docs/providers.ja.mdx+++ b/apps/docs/content/docs/providers.ja.mdx@@ -96,6 +96,7 @@ Amp ではデーモンまたはエージェントの環境に `AMP_API_KEY` も| Codex | 0.100.0 || Cursor Agent | 2026.10.14 || Grok | 1.0.14 |+| Hermes | 0.22.3 || Kiro CLI | 2.33.0 || Pi | 1.4.0 |diff --git a/apps/docs/content/docs/providers.ko.mdx b/apps/docs/content/docs/providers.ko.mdxindex cd85a995c7..a3b5d5929f 100644--- a/apps/docs/content/docs/providers.ko.mdx+++ b/apps/docs/content/docs/providers.ko.mdx@@ -96,6 +96,7 @@ Amp는 데몬 또는 에이전트 환경에 `AMP_API_KEY`도 필요하며, 저| Codex | 0.100.0 || Cursor Agent | 2026.10.14 || Grok | 1.0.14 |+| Hermes | 0.22.3 || Kiro CLI | 2.33.0 || Pi | 1.4.0 |diff --git a/apps/docs/content/docs/providers.mdx b/apps/docs/content/docs/providers.mdxindex f847abb2d9..7c65a5a2b8 100644--- a/apps/docs/content/docs/providers.mdx+++ b/apps/docs/content/docs/providers.mdx@@ -98,6 +98,7 @@ You can [add a message to a run that is still working](/mentioning-agents#steer-| Codex | 0.100.0 || Cursor Agent | 2026.10.14 || Grok | 1.0.14 |+| Hermes | 0.22.3 || Kiro CLI | 2.33.0 || Pi | 1.4.0 |diff --git a/apps/docs/content/docs/providers.zh-Hant.mdx b/apps/docs/content/docs/providers.zh-Hant.mdxindex 23083818f3..82cef59122 100644--- a/apps/docs/content/docs/providers.zh-Hant.mdx+++ b/apps/docs/content/docs/providers.zh-Hant.mdx@@ -96,6 +96,7 @@ Amp 還需要在守護行程或 AI 代理環境中設定 `AMP_API_KEY`,僅有| Codex | 0.100.0 || Cursor Agent | 2026.10.14 || Grok | 1.0.14 |+| Hermes | 0.22.3 || Kiro CLI | 2.33.0 || Pi | 1.4.0 |diff --git a/apps/docs/content/docs/providers.zh.mdx b/apps/docs/content/docs/providers.zh.mdxindex 19aa332abb..f1c3587dc2 100644--- a/apps/docs/content/docs/providers.zh.mdx+++ b/apps/docs/content/docs/providers.zh.mdx@@ -96,6 +96,7 @@ Amp 还需要在守护进程或智能体环境中设置 `AMP_API_KEY`,仅有| Codex | 0.100.0 || Cursor Agent | 2026.10.14 || Grok | 1.0.14 |+| Hermes | 0.22.3 || Kiro CLI | 2.33.0 || Pi | 1.4.0 |diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.goindex 32c28be613..e81c389eca 100644--- a/server/internal/daemon/daemon.go+++ b/server/internal/daemon/daemon.go@@ -9093,6 +9093,10 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot isupplementSupported := agent.SupportsTaskSupplement(provider, resolvedVersion) && (task.IssueID != "" || task.ChatSessionID != "")if supplementSupported {switch provider {+ case "hermes":+ // The version floor describes Hermes Agent. Other CLIs speaking+ // the Hermes protocol family, such as jcode, have no `/steer`.+ supplementSupported = !usesCustomProfileCommandcase "cursor":supplementHookCommand, supplementSupported = cursorSupplementHookCommand(env)case "antigravity":diff --git a/server/internal/daemon/task_supplement.go b/server/internal/daemon/task_supplement.goindex b680e6b1f0..371da7efce 100644--- a/server/internal/daemon/task_supplement.go+++ b/server/internal/daemon/task_supplement.go@@ -131,7 +131,7 @@ func taskSupplementFailureReason(ctx context.Context, err error) string {if errors.Is(err, context.DeadlineExceeded) {return protocol.TaskSupplementFailureTimeout}- if ctx.Err() != nil || errors.Is(err, context.Canceled) {+ if ctx.Err() != nil || errors.Is(err, context.Canceled) || errors.Is(err, agent.ErrSupplementTurnEnded) {return protocol.TaskSupplementFailureTurnEnded}if strings.Contains(strings.ToLower(err.Error()), "turn") && strings.Contains(strings.ToLower(err.Error()), "not started") {diff --git a/server/internal/handler/comment_steer_test.go b/server/internal/handler/comment_steer_test.goindex 9e830cebce..ec2b6f2379 100644--- a/server/internal/handler/comment_steer_test.go+++ b/server/internal/handler/comment_steer_test.go@@ -58,7 +58,7 @@ func outcomeFor(outcomes []CommentTriggerOutcome, agentID string) (CommentTrigge}func TestCreateCommentSteersTheThreadAgentsRunningTurn(t *testing.T) {- for _, provider := range []string{"codex", "grok", "cursor", "kiro", "pi", "antigravity"} {+ for _, provider := range []string{"codex", "grok", "cursor", "kiro", "pi", "antigravity", "hermes"} {t.Run(provider, func(t *testing.T) {f := newSupplementFixture(t, provider, "running", true)dbfx.Exec(t, `UPDATE comment SET content = $2 WHERE id = $1`, f.triggerID,diff --git a/server/internal/handler/task_supplement_test.go b/server/internal/handler/task_supplement_test.goindex 8bf187e2d5..6e8d980c28 100644--- a/server/internal/handler/task_supplement_test.go+++ b/server/internal/handler/task_supplement_test.go@@ -185,6 +185,7 @@ func TestTaskSupplementNegotiationFailsClosed(t *testing.T) {{name: "kiro negotiated", provider: "kiro", daemonAdvertises: true, wantCapabilityRow: true},{name: "pi negotiated", provider: "pi", daemonAdvertises: true, wantCapabilityRow: true},{name: "antigravity negotiated", provider: "antigravity", daemonAdvertises: true, wantCapabilityRow: true},+ {name: "hermes negotiated", provider: "hermes", daemonAdvertises: true, wantCapabilityRow: true},{name: "pi old daemon", provider: "pi", daemonAdvertises: false, wantCapabilityRow: false},{name: "claude old daemon", provider: "claude", daemonAdvertises: false, wantCapabilityRow: false},{name: "old daemon", provider: "codex", daemonAdvertises: false, wantCapabilityRow: false},@@ -219,7 +220,7 @@ func TestTaskSupplementCapabilityDoesNotBreakNonIssueStarts(t *testing.T) {if testHandler == nil {t.Skip("database not available")}- for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro", "pi", "antigravity"} {+ for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro", "pi", "antigravity", "hermes"} {t.Run(provider, func(t *testing.T) {runtimeID := dbfx.Runtime(t, "supplement-no-issue", testutil.Cols{"provider": provider})agentID := dbfx.Agent(t, "Supplement no issue", runtimeID)@@ -298,7 +299,7 @@ func TestPiTaskSupplementLifecycle(t *testing.T) {}func TestTaskSupplementCompletionDoesNotReplayBoundComments(t *testing.T) {- for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro", "pi", "antigravity"} {+ for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro", "pi", "antigravity", "hermes"} {for _, status := range []string{"pending", "delivering", "delivered", "failed"} {for _, ordinary := range []string{"none", "unhandled", "queued"} {t.Run(provider+"/"+status+"/"+ordinary, func(t *testing.T) {diff --git a/server/pkg/agent/agent.go b/server/pkg/agent/agent.goindex d5358812a8..9e910343b9 100644--- a/server/pkg/agent/agent.go+++ b/server/pkg/agent/agent.go@@ -8,6 +8,7 @@ package agentimport ("context""encoding/json"+ "errors""fmt""log/slog""strings"@@ -208,6 +209,11 @@ func runContext(ctx context.Context, timeout time.Duration) (context.Context, coreturn context.WithCancel(ctx)}+// ErrSupplementTurnEnded is returned (wrapped) by a Session.Supplement whose+// target turn finished before the provider accepted the message. The daemon+// reports it as turn_ended rather than as a provider rejection.+var ErrSupplementTurnEnded = errors.New("turn ended before the message was accepted")+// Session represents a running agent execution.type Session struct {// CleanupRequired means Result is also the acknowledgement that thediff --git a/server/pkg/agent/codex.go b/server/pkg/agent/codex.goindex 3883f29047..ef77a75fb2 100644--- a/server/pkg/agent/codex.go+++ b/server/pkg/agent/codex.go@@ -2472,6 +2472,10 @@ func (c *codexClient) activeTurnID() string {type pendingRPC struct {ch chan rpcResultmethod string+ // command marks a Hermes `/steer` sent as its own session/prompt beside+ // the primary one. Its response settles only the command, never the+ // turn's stop reason or usage.+ command bool}type rpcResult struct {diff --git a/server/pkg/agent/hermes.go b/server/pkg/agent/hermes.goindex 7d619bfb53..26c05b7f33 100644--- a/server/pkg/agent/hermes.go+++ b/server/pkg/agent/hermes.go@@ -574,6 +574,7 @@ func (b *hermesBackend) Execute(ctx context.Context, prompt string, opts ExecOptpromptDone := make(chan hermesPromptResult, 1)activity := make(chan struct{}, 1)+ supplements := newHermesSupplementSession()c := &hermesClient{cfg: b.cfg,@@ -584,6 +585,8 @@ func (b *hermesBackend) Execute(ctx context.Context, prompt string, opts ExecOptacceptNotification: func(string) bool {return streamingCurrentTurn.Load()},+ acceptUpdate: supplements.acceptUpdate,+ onNotification: supplements.observeNotification,onActivity: func() {select {case activity <- struct{}{}:@@ -609,6 +612,7 @@ func (b *hermesBackend) Execute(ctx context.Context, prompt string, opts ExecOpt},onUsage: opts.OnUsage,}+ supplements.client = c// Start reading stdout in background.readerDone := make(chan struct{})@@ -908,12 +912,19 @@ func (b *hermesBackend) Execute(ctx context.Context, prompt string, opts ExecOpttrySend(msgCh, Message{Type: MessageStatus, Status: "running", SessionID: sessionID})streamingCurrentTurn.Store(true)- _, err = c.request(runCtx, "session/prompt", map[string]any{+ // Steering opens only once the prompt is on the wire and closes as soon+ // as it answers; see hermesSupplementSession.+ _, err = c.requestAndNotifySent(runCtx, "session/prompt", map[string]any{"sessionId": sessionID,"prompt": []map[string]any{{"type": "text", "text": hermesTurnText(prompt, opts.ResumeExpected, resumeLanded, opts.ResumeContinuityNotice)},},+ }, func() {+ if opts.EnableTaskSupplement {+ supplements.open(sessionID)+ }})+ supplements.stop()if err != nil {// If the request itself failed (not just context cancelled),// check if the context was cancelled/timed out.@@ -1088,7 +1099,12 @@ func (b *hermesBackend) Execute(ctx context.Context, prompt string, opts ExecOpt}}()- return &Session{Messages: msgCh, Result: resCh}, nil+ session := &Session{Messages: msgCh, Result: resCh}+ if opts.EnableTaskSupplement {+ session.Supplement = supplements.send+ session.SupplementReady = supplements.ready+ }+ return session, nil}// waitForHermesNotificationQuiescence gives the stdout reader a bounded chance@@ -1195,9 +1211,9 @@ type hermesClient struct {// fresh-human approvals that also happen to carry allow_once options.// Nil preserves the shared ACP policy for existing backends.selectPermission func(json.RawMessage) (optionID string, grant bool, ok bool)- // onNotification observes vendor notifications that are not session/update.- // Existing backends leave it nil; the callback must do its own method and- // lifecycle filtering.+ // onNotification observes every notification before the session/update+ // gates below, so it also sees updates those gates drop. The callback must+ // do its own method and lifecycle filtering.onNotification func(method string, params json.RawMessage)// onActivity observes accepted ACP session updates. Hermes and Grok use it// to retain a short post-response drain window; other ACP backends leave it@@ -1305,10 +1321,21 @@ func (c *hermesClient) request(ctx context.Context, method string, params any) (// that request use it to avoid advertising readiness before the provider has// received the lifecycle-starting frame.func (c *hermesClient) requestAndNotifySent(ctx context.Context, method string, params any, afterWrite func()) (json.RawMessage, error) {+ return c.call(ctx, &pendingRPC{ch: make(chan rpcResult, 1), method: method}, params, afterWrite)+}++// commandAndNotifySent sends a session/prompt that carries a slash command+// beside the primary prompt. Its response is returned as is and never feeds+// onPromptDone, which belongs to the primary turn.+func (c *hermesClient) commandAndNotifySent(ctx context.Context, params any, afterWrite func()) (json.RawMessage, error) {+ return c.call(ctx, &pendingRPC{ch: make(chan rpcResult, 1), method: "session/prompt", command: true}, params, afterWrite)+}++func (c *hermesClient) call(ctx context.Context, pr *pendingRPC, params any, afterWrite func()) (json.RawMessage, error) {+ method := pr.methodc.mu.Lock()id := c.nextIDc.nextID++- pr := &pendingRPC{ch: make(chan rpcResult, 1), method: method}c.pending[id] = prc.mu.Unlock()@@ -1827,7 +1854,7 @@ func (c *hermesClient) handleResponse(raw map[string]json.RawMessage) {pr.ch <- rpcResult{err: &acpRPCError{Method: pr.method, Code: rpcErr.Code, Message: rpcErr.Message, Data: detail}}} else {// If this is a prompt response, extract usage and stop reason.- if pr.method == "session/prompt" {+ if pr.method == "session/prompt" && !pr.command {c.extractPromptResult(raw["result"])}pr.ch <- rpcResult{result: raw["result"]}diff --git a/server/pkg/agent/hermes_supplement.go b/server/pkg/agent/hermes_supplement.gonew file mode 100644index 0000000000..eff9fe54b7--- /dev/null+++ b/server/pkg/agent/hermes_supplement.go@@ -0,0 +1,278 @@+package agent++import (+ "context"+ "encoding/json"+ "errors"+ "fmt"+ "strings"+ "sync"+ "sync/atomic"+ "time"+)++// hermesSteerAckPrefix opens the reply Hermes sends when `/steer` lands on the+// running turn (acp_adapter/gateway_commands.py `_steer`, Hermes >= 0.22.3).+// The reply arrives as an agent_message_chunk before the command's own+// session/prompt response. It is the only proof the guidance joined the live+// turn: without an active turn Hermes runs the text as a new prompt instead.+const hermesSteerAckPrefix = "⏩ Steer queued for the active turn:"++// hermesSupplementSettleGrace bounds how long a `/steer` still in flight may+// take to settle once the primary prompt has answered. A var so tests can+// shorten it.+var hermesSupplementSettleGrace = 5 * time.Second++// hermesSupplementSession delivers guidance to a running Hermes turn through+// its standard `/steer` slash command, sent as a second session/prompt while+// the primary one is in flight.+//+// Observed contract (Hermes Agent 0.22.5, gateway ACP):+// - During the turn, `/steer` answers at once with an agent_message_chunk+// starting with hermesSteerAckPrefix. Hermes adds the guidance after the+// current tool batch or before the next model call; guidance that arrives+// after the last tool call runs as a follow-up inside the same admission,+// and the primary session/prompt answers only after it.+// - Without an active turn, `/steer <text>` is admitted as an ordinary+// prompt and runs as a turn of its own. session/cancel stops it.+//+// Steering opens only after Hermes advertised the command for this session and+// produced output for the primary prompt, so the turn is known to be running.+// If the primary prompt answers while a `/steer` is still unacknowledged, the+// command missed the turn: the session is cancelled so the stray prompt cannot+// run, and the message is reported as not delivered.+type hermesSupplementSession struct {+ client *hermesClient++ // steerAdvertised mirrors the latest available_commands_update.+ steerAdvertised atomic.Bool+ // acked records the acknowledgement of the `/steer` in flight. Set from the+ // stdout reader, which must never block on mu.+ acked atomic.Bool+ // steered is set once any `/steer` was sent, so a late acknowledgement is+ // still kept out of the transcript.+ steered atomic.Bool++ mu sync.Mutex+ sessionID string+ prompted bool // primary session/prompt is on the wire+ started bool // the primary turn produced a session update+ stopped bool // the primary session/prompt answered+ inFlight bool+ written bool // the in-flight `/steer` frame reached Hermes' stdin+ settled chan struct{}+ stopCh chan struct{}+}++func newHermesSupplementSession() *hermesSupplementSession {+ return &hermesSupplementSession{stopCh: make(chan struct{})}+}++// observeNotification tracks whether this session advertises `/steer`.+func (s *hermesSupplementSession) observeNotification(method string, params json.RawMessage) {+ if method != "session/update" {+ return+ }+ var p struct {+ Update struct {+ SessionUpdate string `json:"sessionUpdate"`+ AvailableCommands []struct {+ Name string `json:"name"`+ } `json:"availableCommands"`+ } `json:"update"`+ }+ if err := json.Unmarshal(params, &p); err != nil || p.Update.SessionUpdate != "available_commands_update" {+ return+ }+ advertised := false+ for _, command := range p.Update.AvailableCommands {+ if command.Name == "steer" {+ advertised = true+ break+ }+ }+ s.steerAdvertised.Store(advertised)+}++// acceptUpdate marks the primary turn as started and drops `/steer`+// acknowledgements, which are Hermes' reply to the command rather than part of+// the agent's answer.+func (s *hermesSupplementSession) acceptUpdate(updateType string, update json.RawMessage) bool {+ if updateType == "" {+ return true+ }+ if updateType == "agent_message_chunk" && s.steered.Load() && hermesSteerAck(update) {+ s.acked.Store(true)+ return false+ }+ if !hermesTurnActivity(updateType) {+ return true+ }+ s.mu.Lock()+ if s.prompted {+ s.started = true+ }+ s.mu.Unlock()+ return true+}++// hermesTurnActivity reports whether an update proves the primary turn is+// running. Hermes sends available_commands_update and usage_update+// asynchronously after attach (gateway_server.py `_after_attach`), so they can+// arrive after session/prompt is written but before the turn starts; a `/steer`+// sent then finds no running admission and is admitted as a new prompt.+func hermesTurnActivity(updateType string) bool {+ switch updateType {+ case "agent_message_chunk", "agent_thought_chunk", "tool_call", "tool_call_update":+ return true+ }+ return false+}++func hermesSteerAck(update json.RawMessage) bool {+ var msg struct {+ Content struct {+ Text string `json:"text"`+ } `json:"content"`+ }+ return json.Unmarshal(update, &msg) == nil && strings.HasPrefix(strings.TrimSpace(msg.Content.Text), hermesSteerAckPrefix)+}++// open is called once the primary session/prompt is written.+func (s *hermesSupplementSession) open(sessionID string) {+ s.mu.Lock()+ s.sessionID = sessionID+ s.prompted = true+ s.mu.Unlock()+}++func (s *hermesSupplementSession) ready() bool {+ s.mu.Lock()+ defer s.mu.Unlock()+ return s.readyLocked()+}++func (s *hermesSupplementSession) readyLocked() bool {+ return s.prompted && s.started && !s.stopped && !s.inFlight && s.steerAdvertised.Load()+}++func (s *hermesSupplementSession) send(ctx context.Context, text string) error {+ s.mu.Lock()+ if s.stopped {+ s.mu.Unlock()+ return fmt.Errorf("hermes: %w", ErrSupplementTurnEnded)+ }+ if !s.readyLocked() {+ s.mu.Unlock()+ return errors.New("hermes turn is not ready for steering")+ }+ s.inFlight, s.written = true, false+ s.acked.Store(false)+ s.steered.Store(true)+ settled := make(chan struct{})+ s.settled = settled+ sessionID := s.sessionID+ s.mu.Unlock()+ defer func() {+ s.mu.Lock()+ s.inFlight, s.written = false, false+ s.mu.Unlock()+ close(settled)+ }()++ // While the turn runs, an acknowledged `/steer` answers at once and an+ // unacknowledged one waits behind the turn, so the wait is bounded by the+ // turn itself plus a grace after it ends.+ reqCtx, cancelReq := context.WithCancel(ctx)+ defer cancelReq()+ go func() {+ select {+ case <-s.stopCh:+ case <-reqCtx.Done():+ return+ }+ grace := time.NewTimer(hermesSupplementSettleGrace)+ defer grace.Stop()+ select {+ case <-grace.C:+ cancelReq()+ case <-reqCtx.Done():+ }+ }()++ response, err := s.client.commandAndNotifySent(reqCtx, map[string]any{+ "sessionId": sessionID,+ "prompt": []map[string]any{{"type": "text", "text": "/steer " + text}},+ }, func() {+ s.mu.Lock()+ s.written = true+ cancelStray := s.stopped && !s.acked.Load()+ s.mu.Unlock()+ if cancelStray {+ s.cancel(sessionID)+ }+ })+ // The reader handles the acknowledgement chunk before the response frame.+ if s.acked.Load() {+ return nil+ }+ if ctx.Err() != nil {+ return ctx.Err()+ }+ s.mu.Lock()+ stopped := s.stopped+ s.mu.Unlock()+ if stopped {+ return fmt.Errorf("hermes /steer: %w", ErrSupplementTurnEnded)+ }+ if err != nil {+ return fmt.Errorf("hermes /steer failed: %w", err)+ }+ return fmt.Errorf("hermes /steer was not applied to the running turn: %s", strings.TrimSpace(string(response)))+}++// stop closes steering when the primary session/prompt answers, cancels a+// `/steer` that missed the turn, and waits for it to settle so stdin is not+// closed under it.+func (s *hermesSupplementSession) stop() {+ s.mu.Lock()+ if s.stopped {+ s.mu.Unlock()+ return+ }+ s.stopped = true+ close(s.stopCh)+ cancelStray := s.inFlight && s.written && !s.acked.Load()+ settled := s.settled+ inFlight := s.inFlight+ sessionID := s.sessionID+ s.mu.Unlock()+ if cancelStray {+ s.cancel(sessionID)+ }+ if !inFlight {+ return+ }+ timer := time.NewTimer(hermesSupplementSettleGrace + time.Second)+ defer timer.Stop()+ select {+ case <-settled:+ case <-timer.C:+ }+}++func (s *hermesSupplementSession) cancel(sessionID string) {+ data, err := json.Marshal(map[string]any{+ "jsonrpc": "2.0",+ "method": "session/cancel",+ "params": map[string]any{"sessionId": sessionID},+ })+ if err != nil {+ return+ }+ if err := s.client.writeLine(append(data, '\n')); err != nil {+ s.client.cfg.Logger.Warn("hermes: could not cancel a /steer that missed the turn", "error", err)+ return+ }+ s.client.cfg.Logger.Info("hermes: cancelled a /steer that arrived after the turn ended", "session_id", sessionID)+}diff --git a/server/pkg/agent/hermes_supplement_integration_test.go b/server/pkg/agent/hermes_supplement_integration_test.gonew file mode 100644index 0000000000..160a98b661--- /dev/null+++ b/server/pkg/agent/hermes_supplement_integration_test.go@@ -0,0 +1,86 @@+//go:build agentintegration++package agent++import (+ "context"+ "log/slog"+ "os/exec"+ "strings"+ "testing"+ "time"+)++// TestHermesRealSupplementReachesTheTurn steers a real Hermes Agent run with+// `/steer` while a tool is running and asserts the model acted on the guidance+// in the same turn. It is what catches Hermes changing the `/steer`+// acknowledgement or no longer folding guidance into the running turn.+func TestHermesRealSupplementReachesTheTurn(t *testing.T) {+ requireRealAgentSmoke(t)+ if testing.Short() {+ t.Skip("skipping real-binary smoke test in -short mode")+ }+ path, err := exec.LookPath("hermes")+ if err != nil {+ t.Skip("hermes not on PATH; skipping real-binary smoke test")+ }+ version, err := exec.Command(path, "acp", "--version").Output()+ if err != nil || !SupportsTaskSupplement("hermes", strings.TrimSpace(string(version))) {+ t.Skipf("hermes %q predates ACP /steer", strings.TrimSpace(string(version)))+ }++ backend, err := New("hermes", Config{ExecutablePath: path, Logger: slog.Default(), BuiltinRuntime: true})+ if err != nil {+ t.Fatalf("new hermes backend: %v", err)+ }+ ctx, cancel := context.WithTimeout(context.Background(), 240*time.Second)+ defer cancel()+ session, err := backend.Execute(ctx,+ "Use the terminal tool to run `sleep 15 && echo step-one`. After it finishes, run `echo step-two`. Then reply with a one-line summary.",+ ExecOptions{Cwd: t.TempDir(), Timeout: 230 * time.Second, EnableTaskSupplement: true})+ if err != nil {+ t.Fatalf("execute: %v", err)+ }+ var transcript strings.Builder+ drained := make(chan struct{})+ go func() {+ defer close(drained)+ for msg := range session.Messages {+ transcript.WriteString(msg.Content)+ }+ }()++ for !session.SupplementReady() {+ select {+ case <-ctx.Done():+ t.Fatal("hermes turn never became ready for guidance")+ case <-time.After(50 * time.Millisecond):+ }+ }+ // The daemon's own framing (formatTaskSupplementInstruction).+ guidance := `[ADDITIONAL GUIDANCE] Human "Jiayuan" added guidance while you were working.++Treat this as additional guidance for the same active task, not as a replacement:+- Preserve and complete the original objective.+- Incorporate this guidance 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 message:+Also include the codeword ORCHID-19 in your final reply.`+ if err := session.Supplement(ctx, guidance); err != nil {+ t.Fatalf("supplement was not delivered: %v", err)+ }++ result := <-session.Result+ <-drained+ if result.Status != "completed" {+ t.Fatalf("status = %q, error = %q", result.Status, result.Error)+ }+ if !strings.Contains(result.Output, "ORCHID-19") {+ t.Fatalf("final reply ignored the delivered guidance: %q", result.Output)+ }+ if strings.Contains(transcript.String(), hermesSteerAckPrefix) {+ t.Fatalf("the /steer acknowledgement leaked into the transcript: %q", transcript.String())+ }+}diff --git a/server/pkg/agent/hermes_supplement_test.go b/server/pkg/agent/hermes_supplement_test.gonew file mode 100644index 0000000000..c7f7340c24--- /dev/null+++ b/server/pkg/agent/hermes_supplement_test.go@@ -0,0 +1,268 @@+package agent++import (+ "context"+ "errors"+ "log/slog"+ "os"+ "path/filepath"+ "runtime"+ "strings"+ "testing"+ "time"+)++// fakeHermesSteerACPScript mirrors Hermes Agent 0.22.5's gateway ACP. The+// primary session/prompt reports a tool call and stays open; a concurrent+// `/steer` session/prompt is handled per HERMES_STEER_MODE:+// - "" (live turn): acknowledge with the "Steer queued" chunk, answer the+// command, then finish the primary turn with the steered answer.+// - "noack": answer the command without an acknowledgement.+// - "late": the primary turn ends first; the command waits like a stray+// prompt until session/cancel answers it as cancelled.+//+// HERMES_ADVERTISE_STEER publishes the command after session/new. Without it,+// the primary turn ends on its own after a short delay.+func fakeHermesSteerACPScript() string {+ return `#!/bin/sh+prompt_id=""+steer_id=""+while IFS= read -r line; do+ if [ -n "$HERMES_REQUESTS_FILE" ]; then+ printf '%s\n' "$line" >> "$HERMES_REQUESTS_FILE"+ fi+ id=$(printf '%s' "$line" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')+ case "$line" in+ *'"method":"initialize"'*)+ printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":1,"agentCapabilities":{}}}\n' "$id"+ ;;+ *'"method":"session/new"'*)+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"ses_new"}}\n' "$id"+ if [ -n "$HERMES_ADVERTISE_STEER" ]; then+ printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_new","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"queue"},{"name":"steer"}]}}}\n'+ fi+ ;;+ *'"method":"session/cancel"'*)+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"cancelled"}}\n' "$steer_id"+ ;;+ *'/steer '*)+ steer_id="$id"+ case "$HERMES_STEER_MODE" in+ noack)+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn"}}\n' "$steer_id"+ ;;+ late)+ printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_new","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"done"}}}}\n'+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn"}}\n' "$prompt_id"+ ;;+ *)+ printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_new","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"⏩ Steer queued for the active turn: The word is PINEAPPLE.\\n"}}}}\n'+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn"}}\n' "$steer_id"+ printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_new","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"PINEAPPLE"}}}}\n'+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn","usage":{"inputTokens":7,"outputTokens":3}}}\n' "$prompt_id"+ ;;+ esac+ ;;+ *'"method":"session/prompt"'*)+ prompt_id="$id"+ printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_new","update":{"sessionUpdate":"tool_call","toolCallId":"call_1","title":"terminal: sleep 5","kind":"execute","status":"pending"}}}\n'+ if [ -z "$HERMES_ADVERTISE_STEER" ]; then+ sleep 0.5+ printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_new","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"plain"}}}}\n'+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn"}}\n' "$prompt_id"+ fi+ ;;+ esac+done+`+}++func startHermesSteerSession(t *testing.T, env map[string]string, negotiated bool) (*Session, context.Context) {+ t.Helper()+ if runtime.GOOS == "windows" {+ t.Skip("shell-script fixture is POSIX-only")+ }+ fakePath := filepath.Join(t.TempDir(), "hermes")+ writeTestExecutable(t, fakePath, []byte(fakeHermesSteerACPScript()))+ backend, err := New("hermes", Config{ExecutablePath: fakePath, Env: env, Logger: slog.Default()})+ if err != nil {+ t.Fatal(err)+ }+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)+ t.Cleanup(cancel)+ session, err := backend.Execute(ctx, "do the task", ExecOptions{Timeout: 20 * time.Second, EnableTaskSupplement: negotiated})+ if err != nil {+ t.Fatal(err)+ }+ return session, ctx+}++func waitHermesSupplementReady(t *testing.T, session *Session) {+ t.Helper()+ // Generous: the fake shell is slow to start when the package runs in parallel.+ deadline := time.Now().Add(15 * time.Second)+ for !session.SupplementReady() && time.Now().Before(deadline) {+ time.Sleep(5 * time.Millisecond)+ }+ if !session.SupplementReady() {+ t.Fatal("supplement never became ready during the active prompt")+ }+}++func drainHermesMessages(session *Session) <-chan []Message {+ out := make(chan []Message, 1)+ go func() {+ var messages []Message+ for msg := range session.Messages {+ messages = append(messages, msg)+ }+ out <- messages+ }()+ return out+}++func TestHermesSupplementSteersActiveTurn(t *testing.T) {+ t.Parallel()+ requestsPath := filepath.Join(t.TempDir(), "requests.jsonl")+ session, ctx := startHermesSteerSession(t, map[string]string{+ "HERMES_ADVERTISE_STEER": "1",+ "HERMES_REQUESTS_FILE": requestsPath,+ }, true)+ if session.Supplement == nil || session.SupplementReady == nil {+ t.Fatal("negotiated Hermes session did not expose supplement callbacks")+ }+ waitHermesSupplementReady(t, session)+ messages := drainHermesMessages(session)++ if err := session.Supplement(ctx, "The word is PINEAPPLE.\nKeep going."); err != nil {+ t.Fatalf("steer: %v", err)+ }+ result := <-session.Result+ transcript := <-messages+ if result.Status != "completed" || result.Output != "PINEAPPLE" {+ t.Fatalf("result status=%q output=%q error=%q, want the steered answer in the same turn", result.Status, result.Output, result.Error)+ }+ // The command's own response must not stand in for the primary turn's.+ if usage := result.Usage["unknown"]; usage.InputTokens != 7 || usage.OutputTokens != 3 {+ t.Fatalf("usage=%+v, want the primary prompt's", result.Usage)+ }+ for _, msg := range transcript {+ if strings.Contains(msg.Content, "Steer queued") {+ t.Fatalf("acknowledgement leaked into the transcript: %+v", msg)+ }+ }+ if session.SupplementReady() {+ t.Fatal("supplement stayed ready after session/prompt completed")+ }+ if err := session.Supplement(ctx, "too late"); !errors.Is(err, ErrSupplementTurnEnded) {+ t.Fatalf("supplement after the turn ended: err=%v, want ErrSupplementTurnEnded", err)+ }+ requests, err := os.ReadFile(requestsPath)+ if err != nil {+ t.Fatal(err)+ }+ if want := `"text":"/steer The word is PINEAPPLE.\nKeep going."`; !strings.Contains(string(requests), want) {+ t.Errorf("ACP requests missing %s:\n%s", want, requests)+ }+}++func TestHermesSupplementRequiresAcknowledgement(t *testing.T) {+ t.Parallel()+ session, ctx := startHermesSteerSession(t, map[string]string{+ "HERMES_ADVERTISE_STEER": "1",+ "HERMES_STEER_MODE": "noack",+ }, true)+ waitHermesSupplementReady(t, session)+ err := session.Supplement(ctx, "hello")+ if err == nil {+ t.Fatal("unacknowledged steer must not be reported as delivered")+ }+ if errors.Is(err, ErrSupplementTurnEnded) {+ t.Fatalf("err=%v: the turn is still running, so this is a rejection", err)+ }+ // The turn is still live; t.Cleanup cancels ctx and reaps the fake.+}++func TestHermesSupplementCancelsSteerThatMissedTheTurn(t *testing.T) {+ t.Parallel()+ requestsPath := filepath.Join(t.TempDir(), "requests.jsonl")+ session, ctx := startHermesSteerSession(t, map[string]string{+ "HERMES_ADVERTISE_STEER": "1",+ "HERMES_STEER_MODE": "late",+ "HERMES_REQUESTS_FILE": requestsPath,+ }, true)+ waitHermesSupplementReady(t, session)+ messages := drainHermesMessages(session)++ if err := session.Supplement(ctx, "hello"); !errors.Is(err, ErrSupplementTurnEnded) {+ t.Fatalf("err=%v, want ErrSupplementTurnEnded for a steer that missed the turn", err)+ }+ result := <-session.Result+ <-messages+ if result.Status != "completed" || result.Output != "done" {+ t.Fatalf("result=%+v, want the primary turn's own completion", result)+ }+ requests, err := os.ReadFile(requestsPath)+ if err != nil {+ t.Fatal(err)+ }+ if !strings.Contains(string(requests), `"method":"session/cancel"`) {+ t.Errorf("a steer that missed the turn must be cancelled so Hermes cannot run it as a new prompt:\n%s", requests)+ }+}++func TestHermesSupplementWaitsForAdvertisedCommand(t *testing.T) {+ t.Parallel()+ session, _ := startHermesSteerSession(t, nil, true)+ messages := drainHermesMessages(session)+ done := make(chan Result, 1)+ go func() { done <- <-session.Result }()+ for {+ select {+ case result := <-done:+ <-messages+ if result.Status != "completed" || result.Output != "plain" {+ t.Fatalf("result=%+v, want a normal completed turn", result)+ }+ return+ default:+ if session.SupplementReady() {+ t.Fatal("supplement became ready for a session that never advertised /steer")+ }+ time.Sleep(5 * time.Millisecond)+ }+ }+}++func TestHermesSupplementNotExposedWithoutNegotiation(t *testing.T) {+ t.Parallel()+ session, _ := startHermesSteerSession(t, nil, false)+ if session.Supplement != nil || session.SupplementReady != nil {+ t.Fatal("un-negotiated Hermes session must not expose supplement callbacks")+ }+ messages := drainHermesMessages(session)+ result := <-session.Result+ <-messages+ if result.Status != "completed" || result.Output != "plain" {+ t.Fatalf("result=%+v, want a normal completed turn", result)+ }+}++// Hermes publishes available_commands_update and usage_update after attach,+// independently of the turn, so only agent output or a tool call opens steering.+func TestHermesSupplementStartsOnlyOnTurnActivity(t *testing.T) {+ t.Parallel()+ s := newHermesSupplementSession()+ s.steerAdvertised.Store(true)+ s.open("ses_new")+ for _, kind := range []string{"usage_update", "available_commands_update", "turn_end", ""} {+ s.acceptUpdate(kind, []byte(`{}`))+ if s.ready() {+ t.Fatalf("%q opened steering before the turn produced output", kind)+ }+ }+ s.acceptUpdate("agent_thought_chunk", []byte(`{"content":{"type":"text","text":"thinking"}}`))+ if !s.ready() {+ t.Fatal("agent output for the primary prompt must open steering")+ }+}diff --git a/server/pkg/agent/version.go b/server/pkg/agent/version.goindex 66c0d8b810..23fbdb28fc 100644--- a/server/pkg/agent/version.go+++ b/server/pkg/agent/version.go@@ -162,6 +162,12 @@ func SupportsTaskSupplement(provider, version string) bool {// 2026.10.14 is the oldest build verified to forward postToolUse// additional_context into the model turn in --print mode.minimum = "2026.10.14"+ case "hermes":+ // 0.22.3 is the oldest Hermes Agent whose gateway ACP answers `/steer`+ // with an acknowledgement and keeps late guidance inside the running+ // admission. The backend also requires the session to advertise the+ // command; jcode shares this provider and is gated out by the daemon.+ minimum = "0.22.3"default:return false}diff --git a/server/pkg/agent/version_test.go b/server/pkg/agent/version_test.goindex dbee1efc55..5761c77599 100644--- a/server/pkg/agent/version_test.go+++ b/server/pkg/agent/version_test.go@@ -17,6 +17,7 @@ func TestTaskSupplementVersionGate(t *testing.T) {{"cursor", "2026.10.16-e3cb207", true}, {"cursor", "2026.10.14", true}, {"cursor", "2026.04.17-787b533", false},{"antigravity", "1.4.8", true}, {"antigravity", "agy 1.5.13", true}, {"antigravity", "1.4.7", false}, {"antigravity", "", false},{"kiro", "kiro-cli 2.33.0", true}, {"kiro", "2.34.1", true}, {"kiro", "kiro-cli 2.32.9", false},+ {"hermes", "0.22.3", true}, {"hermes", "0.22.5", true}, {"hermes", "0.22.2", false}, {"hermes", "", false},{"codex", "", false}, {"claude", "dev", false}, {"kimi", "9.0.0", false},} {if got := SupportsTaskSupplement(tc.provider, tc.version); got != tc.want {diff --git a/server/pkg/db/generated/supplement.sql.go b/server/pkg/db/generated/supplement.sql.goindex f370024301..1fa6df68ee 100644--- a/server/pkg/db/generated/supplement.sql.go+++ b/server/pkg/db/generated/supplement.sql.go@@ -108,7 +108,7 @@ WITH locked_task AS MATERIALIZED (OR (t.is_leader_task AND t.squad_id = $5::uuid))AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity', 'hermes')AND ($6::text <> 'agent' OR ((SELECT count(*) FROM task_supplement sJOIN comment c ON c.id = s.comment_id@@ -299,7 +299,7 @@ WITH locked_task AS MATERIALIZED (AND r.workspace_id = $3AND t.status = 'running'AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity', 'hermes')FOR UPDATE OF t), touched_issue AS (UPDATE issue i SET@@ -860,7 +860,7 @@ WITH candidate AS MATERIALIZED (SELECT id, workspace_id, issue_id, 'task-supplement-v1'FROM candidateWHERE $3::boolean- AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity')+ AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity', 'hermes')AND (issue_id IS NOT NULL OR chat_session_id IS NOT NULL)ON CONFLICT DO NOTHINGRETURNING task_iddiff --git a/server/pkg/db/queries/supplement.sql b/server/pkg/db/queries/supplement.sqlindex 7fb1aa7508..f5cb6d38f2 100644--- a/server/pkg/db/queries/supplement.sql+++ b/server/pkg/db/queries/supplement.sql@@ -14,7 +14,7 @@ WITH candidate AS MATERIALIZED (SELECT id, workspace_id, issue_id, 'task-supplement-v1'FROM candidateWHERE @enable_task_supplement::boolean- AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity')+ AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity', 'hermes')AND (issue_id IS NOT NULL OR chat_session_id IS NOT NULL)ON CONFLICT DO NOTHINGRETURNING task_id@@ -50,7 +50,7 @@ WITH locked_task AS MATERIALIZED (AND r.workspace_id = @workspace_idAND t.status = 'running'AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity', 'hermes')FOR UPDATE OF t), touched_issue AS (UPDATE issue i SET@@ -129,7 +129,7 @@ WITH locked_task AS MATERIALIZED (OR (t.is_leader_task AND t.squad_id = sqlc.narg('required_leader_squad_id')::uuid))AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi', 'antigravity', 'hermes')AND (@author_type::text <> 'agent' OR ((SELECT count(*) FROM task_supplement sJOIN comment c ON c.id = s.comment_id