Skip to content

Cursor model discovery re-probes and re-warns on every call when cursor-agent is missing #512

Description

@Temikus

TL;DR: getCursorModels() spawns cursor-agent models on every call with no cache of the negative result, so when cursor-agent is not installed each agent-picker render re-probes the missing binary and emits another warning.

Seen on v0.3.3, running in a container that ships Claude, Codex, Opencode, and Amp, but not cursor-agent. The path looks unchanged on main as of 9abf40b.

Detail

server-agents/cursor/src/agents/cursor/cursor-models.ts

export async function getCursorModels(
  config: CursorConfig,
  logger: AgentLogger,
): Promise<CursorModelOption[]> {
  try {
    const parsed = parseCursorModelsOutput(await runCursorModels(config));
    if (parsed.length > 0) return parsed;
  } catch (error) {
    logger.warn('Cursor model discovery failed', {
      error: error instanceof Error ? error.message : String(error),
    });
  }
  return [];
}

There is no availability gate and no memo of the failure, so the spawn is retried indefinitely. Observed output, all from a single UI connection:

[ws:chat] ws: chat client connected
[agents:cursor:cursor-models] cursor: model discovery failed: Executable not found in $PATH: "cursor-agent"
... 13 more identical lines

Over a long-lived server this is the bulk of the log volume.

Suggested fix

Either cache the negative result for the process lifetime, or gate discovery behind a Bun.which(config.binary()) check, along the lines of the guard added for opencode in #42.

Possibly related to #44.

Happy to send a PR if useful. Thanks for garcon.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions