MCPcopy Create free account
hub / github.com/Facets-cloud/flow / bgAgentStatus

Function bgAgentStatus

internal/app/harness.go:196–224  ·  view source on GitHub ↗

bgAgentStatus returns the live background-agent entry for a task's bound session, or nil if the task isn't bg-bound, has no session, the harness can't host background agents, or the session isn't currently running. Used by `flow show` to surface a bg session's status/state/pid via a per-render `clau

(t *flowdb.Task)

Source from the content-addressed store, hash-verified

194// Used by `flow show` to surface a bg session's status/state/pid via a
195// per-render `claude agents --json` lookup.
196func bgAgentStatus(t *flowdb.Task) *harness.BackgroundAgent {
197 if t == nil || !t.SessionID.Valid || t.SessionID.String == "" {
198 return nil
199 }
200 // Only consult the registry in bg mode — see liveSessionsForTasks.
201 // Keeps `flow show` free of a `claude agents` subprocess for non-bg
202 // users (and avoids surfacing bg state they never opted into).
203 if !spawner.IsBackground() {
204 return nil
205 }
206 h, err := harnessForTask(t)
207 if err != nil {
208 return nil
209 }
210 bg, ok := h.(harness.BackgroundLauncher)
211 if !ok {
212 return nil
213 }
214 agents, err := bg.BackgroundAgents()
215 if err != nil {
216 return nil
217 }
218 for i := range agents {
219 if strings.EqualFold(agents[i].SessionID, t.SessionID.String) {
220 return &agents[i]
221 }
222 }
223 return nil
224}

Callers 3

TestBGAgentStatusFunction · 0.85
printTaskMetadataFunction · 0.85

Calls 3

IsBackgroundFunction · 0.92
harnessForTaskFunction · 0.85
BackgroundAgentsMethod · 0.65

Tested by 2

TestBGAgentStatusFunction · 0.68