Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-18936-startup-already-running-benign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Startup no longer reports "failed to start agent" (and a self-report issue) when an agent is already running or launching by the time its startup launch runs ([#18936](https://github.com/hivecommons/hive/issues/18936)).
14 changes: 14 additions & 0 deletions src/cmd/hive/boot_launch_deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ func TestBootLaunchWithLogsServeAndStartFailures(t *testing.T) {
}
}

func TestBootLaunchWithAlreadyRunningAgentIsNotStartFailure(t *testing.T) {
b := newLaunchBoot(t, map[string]config.AgentConfig{"telemetry": {Enabled: true}})
var sb strings.Builder
b.logger = slog.New(slog.NewTextHandler(&sb, nil))
h := &launchHarness{
startErr: map[string]error{"telemetry": errors.New("agent telemetry already running")},
}
b.bootLaunchWith(h.deps())

if out := sb.String(); strings.Contains(out, "failed to start agent") {
t.Fatalf("already-running agent must not log a start failure:\n%s", out)
}
}

func TestBootLaunchWithStartsDiscordBotWhenConfigured(t *testing.T) {
for _, tc := range []struct {
name string
Expand Down
8 changes: 7 additions & 1 deletion src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4655,7 +4655,13 @@ func (b *boot) bootLaunchWith(deps bootLaunchDeps) {
}
b.logger.Info("audit: starting agent", "name", name, "trigger", "startup")
if err := deps.startAgent(b.ctx, b.agentMgr, name); err != nil {
b.logger.Warn("failed to start agent", "name", name, "error", err)
if stoppedAgentStartErrorIsBenign(err) {
// Already running (adopted/raced) or launching: the desired
// end state holds, so this is not a start failure (#18936).
b.logger.Info("agent already started; skipping startup launch", "name", name, "reason", err.Error())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory: stoppedAgentStartErrorIsBenign also matches 'shared session pool is busy' (eval_cycle_seams.go:665-667). That case means the agent did not start, yet this logs 'agent already started'. Consider restricting to the already-running/launch-in-progress messages, or rewording.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: the benign check also matches isSharedPoolBusyErr (eval_cycle_seams.go:667). In that case the agent is NOT started, yet this logs "agent already started; skipping startup launch". The downgrade to Info is arguably right, but the message misstates the cause. Consider "agent not started (already running or launch deferred)"; reason already carries the specifics.

} else {
b.logger.Warn("failed to start agent", "name", name, "error", err)
}
} else {
// Surface whether a persisted operator pause was honored on this
// restart, so the audit log shows pause state survived (or didn't).
Expand Down
Loading