vxcontrol/pentagi · error
flow not found
Error message
flow not found
What it means
GetFlowAgentLog looks up the flow ID in the agent-log controller's in-memory flows map under a mutex; if absent it returns fmt.Errorf("flow not found"). This means no agent-log worker has been registered for that flow — the flow either never started, already finished and was cleaned up, or the ID is wrong.
Source
Thrown at backend/pkg/controller/alogs.go:67
flows := make([]FlowAgentLogWorker, 0, len(alc.flows))
for _, flw := range alc.flows {
flows = append(flows, flw)
}
return flows, nil
}
func (alc *agentLogController) GetFlowAgentLog(
ctx context.Context,
flowID int64,
) (FlowAgentLogWorker, error) {
alc.mx.Lock()
defer alc.mx.Unlock()
flw, ok := alc.flows[flowID]
if !ok {
return nil, fmt.Errorf("flow not found")
}
return flw, nil
}
View on GitHub (pinned to ea665308ba)
Solutions
- Verify the flow_id exists and the flow is currently running
- Re-query the flow list to get a valid ID and retry
- Fetch persisted logs from the database for completed flows instead of the live in-memory worker
- If after a backend restart, accept that live log workers are gone and re-run/re-open the flow
Example fix
// before
const worker = await agentLog.getFlowAgentLog(flowId); // throws if evicted
// after
const flow = await api.getFlow(flowId);
if (flow.status === 'completed') {
const logs = await api.getPersistedFlowLogs(flowId);
} else {
const worker = await agentLog.getFlowAgentLog(flowId);
} Defensive patterns
Strategy: try-catch
Validate before calling
const flow = await api.getFlow(flowId); // 404 here means the ID is wrong before touching the log worker
if (!flow || flow.status !== 'running') throw new Error(`flow ${flowId} is not active`); Type guard
function hasActiveWorker(w: FlowAgentLogWorker | undefined): w is FlowAgentLogWorker {
return w !== undefined;
} Try / catch
try {
const worker = await agentLogCtl.GetFlowAgentLog(ctx, flowId);
return worker.Stream();
} catch (e) {
if (/flow not found/.test(String(e))) {
return loadPersistedAgentLog(flowId); // completed flow or restart
}
throw e;
} Prevention
- Only request live logs for flows in 'running' state
- Fall back to DB-persisted logs for finished flows
- Re-subscribe after backend restarts; in-memory workers do not survive redeploys
- Validate flow IDs against the API list before opening log streams
When it happens
Trigger: Requesting the agent log stream/log for flow_id when no FlowAgentLogWorker exists in alc.flows: unknown flow ID, flow created before this service instance started (restart wiped the map), or flow already terminated and evicted.
Common situations: Client polling logs after flow completion, backend restart losing in-memory worker registrations, copying a flow ID from another environment, or race where the log request lands before the worker is registered.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/25146a5b859b0643.
Report an issue: GitHub.