MCPcopy Index your code
hub / github.com/coder/coder / latestWorkspaceAgentNeedsRestart

Method latestWorkspaceAgentNeedsRestart

coderd/x/chatd/chatd.go:997–1021  ·  view source on GitHub ↗
(
	ctx context.Context,
	workspaceID uuid.UUID,
)

Source from the content-addressed store, hash-verified

995}
996
997func (c *turnWorkspaceContext) latestWorkspaceAgentNeedsRestart(
998 ctx context.Context,
999 workspaceID uuid.UUID,
1000) (bool, error) {
1001 agentID, err := c.latestWorkspaceAgentID(ctx, workspaceID)
1002 if err != nil {
1003 if xerrors.Is(err, errChatHasNoWorkspaceAgent) {
1004 return false, err
1005 }
1006 c.server.logger.Warn(ctx, "failed to resolve latest agent for timeout classification", slog.Error(err))
1007 return false, nil
1008 }
1009
1010 agent, err := c.server.db.GetWorkspaceAgentByID(ctx, agentID)
1011 if err != nil {
1012 c.server.logger.Warn(ctx, "failed to load latest agent for timeout classification",
1013 slog.F("agent_id", agentID),
1014 slog.Error(err),
1015 )
1016 return false, nil
1017 }
1018
1019 disconnectedFor, disconnected := agentDisconnectedFor(c.server.clock.Now(), agent, c.server.agentInactiveDisconnectTimeout)
1020 return disconnected && disconnectedFor >= agentDisconnectedRecoveryThreshold, nil
1021}
1022
1023func (c *turnWorkspaceContext) externalAgentError(
1024 ctx context.Context,

Callers 1

getWorkspaceConnMethod · 0.95

Calls 5

agentDisconnectedForFunction · 0.85
GetWorkspaceAgentByIDMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected