Skip to content

Commit 6d50466

Browse files
committed
supervise: silent in interactive mode (no banner polluting the agent terminal)
Interactive supervise (docker run -it) now prints nothing on startup — the 'daemon listening', 'supervise: backend=...', and 'running agent' banner lines were polluting the agent's terminal/REPL. They move to where they're useful: the daemon command and headless supervise. The api.Serve listening/uid line is now the caller's responsibility (daemon + headless print it; interactive stays quiet).
1 parent 550a0af commit 6d50466

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

internal/api/server.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package api
1414
import (
1515
"context"
1616
"encoding/json"
17-
"fmt"
1817
"net"
1918
"os"
2019
"sync"
@@ -48,11 +47,10 @@ func Serve(ctx context.Context, r *repo.Repo, c *repo.Capturer, sockPath string)
4847
ln.Close()
4948
return err
5049
}
51-
// Log the uid in big letters so the cross-uid trap (daemon=root,
52-
// agent=non-root, socket=0600) shows up at the first scroll of the log
53-
// instead of after 20 minutes of debugging "permission denied". Pairs
54-
// with the diagnostic in daemonclient.diagnoseConnect.
55-
fmt.Fprintf(os.Stderr, "agentenv daemon listening on %s (uid=%d, mode=0600)\n", sockPath, os.Getuid())
50+
// The listening/uid banner is left to the caller: `daemon` and headless
51+
// `supervise` print it (useful operational logging + the cross-uid trap
52+
// hint), while interactive `supervise` stays silent so it doesn't pollute
53+
// the agent's terminal.
5654
go func() {
5755
<-ctx.Done()
5856
ln.Close()

internal/cli/session.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,20 @@ func cmdSupervise(r *repo.Repo, args []string) error {
6161
go api.Serve(ctx, r, cap, sock)
6262
defer os.Remove(sock)
6363

64-
fmt.Printf("agentenv supervise: backend=%s control-socket=%s self-rollback=%v\n", r.Backend().Name, sock, selfRollback)
65-
fmt.Printf("running agent inside the env: %s\n", strings.Join(agentArgs, " "))
66-
6764
// Two modes, chosen by whether stdin is a terminal:
6865
// - interactive (TTY): run the agent on a PTY in the foreground so a REPL
69-
// like Claude Code works.
70-
// - headless (no TTY): background the agent, tail its log — for
71-
// autonomous/long-running agents.
66+
// like Claude Code works. Stay SILENT — no banner, no snapshot notices —
67+
// so the agent's terminal isn't polluted. (Inspect from another terminal
68+
// with `agentenv log` / `agentenv ctl log`.)
69+
// - headless (no TTY): print a startup banner + tail the agent's log — for
70+
// autonomous/long-running agents where this is useful operational output.
7271
// In self-rollback mode a checkout doesn't kill the agent, so the run loops'
7372
// "killed by rollback → relaunch" branch simply never fires.
7473
if term.IsTerminal(int(os.Stdin.Fd())) {
7574
return superviseInteractive(ctx, r, agentArgs, selfRollback)
7675
}
76+
fmt.Printf("agentenv supervise: backend=%s control-socket=%s self-rollback=%v (uid=%d)\n", r.Backend().Name, sock, selfRollback, os.Getuid())
77+
fmt.Printf("running agent inside the env: %s\n", strings.Join(agentArgs, " "))
7778
cap.SetOnSnapshot(printSnapshot)
7879
return superviseHeadless(ctx, r, agentArgs, selfRollback)
7980
}
@@ -190,7 +191,9 @@ func cmdDaemon(r *repo.Repo, args []string) error {
190191
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
191192
defer cancel()
192193

193-
fmt.Printf("agentenv daemon: backend=%s listening on %s\n", r.Backend().Name, sock)
194+
// uid in the banner surfaces the cross-uid trap (daemon=root, agent=non-root,
195+
// socket=0600) right away — pairs with daemonclient.diagnoseConnect.
196+
fmt.Printf("agentenv daemon: backend=%s listening on %s (uid=%d, mode=0600)\n", r.Backend().Name, sock, os.Getuid())
194197
defer os.Remove(sock)
195198
return api.Serve(ctx, r, cap, sock)
196199
}

0 commit comments

Comments
 (0)