Feat: Keep coding agents working when the Cortex proxy stops

Abierto
#1,738 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@huang195 ya está trabajando en esto.

Desde el 9/11/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

Problem

When the Cortex proxy is not running, every agent that agentop configure wired to it stops working. Claude Code and OpenCode send all traffic to HTTPS_PROXY=http://127.0.0.1:47600. If nothing listens there, each request fails.

The agent shows a plain network error. The error does not name Cortex and does not tell the user how to fix it.

What Cortex does now

  • macOS: launchd starts a supervisor (cortex --supervise). The supervisor restarts the proxy, with a backoff (cmd/cortex/supervise.go).
  • Linux: the systemd unit uses Restart=on-failure.
  • agentop service uninstall: it only warns that "Claude Code and OpenCode stop working whenever the proxy is not running".

Gaps

  1. A killed supervisor stays dead. cmd/cortex/supervise.go:32 says: "What this does NOT cover: the supervisor itself being killed. Nothing restarts it". launchd does not restart it in a gui/<uid> domain, so agents fail until the next login or a manual start.
  2. Crash recovery is not tested from start to end on macOS. cmd/agentop/cmd_service_platform.go:55-58 says that restart-after-crash was "NOT verified end to end".
  3. A bad config at boot stops all agents. A config error is fatal at startup. The supervisor then restarts the proxy into the same error, again and again. A hot reload keeps the last good config, but a boot does not. So one bad edit followed by a restart, or a reboot, cuts off every agent until the user repairs the file.
  4. The failure is hard to understand. The user sees "connection refused" in the agent, not "Cortex is not running".

Proposal

  1. Claude Code SessionStart hook that starts Cortex.
    • agentop configure claude-code enable installs a SessionStart hook.
    • The hook probes 127.0.0.1:47600. If nothing answers, it runs agentop service start and prints one line that says so.
    • The hook must never remove HTTPS_PROXY. See Non-goals.
    • This also covers gap 1: the next session start brings back a dead supervisor.
    • Open question: does the hook run before the first API request of the session? Test this before the design is final.
  2. Boot with the last good config.
    • When startup validation fails, Cortex starts with the last config that it loaded with success.
    • It reports the error in /reload/status and in agentop doctor, in the same way as a failed reload.
    • If no last good config exists, Cortex keeps the current behavior and exits.
  3. A clear message.
    • When the proxy does not answer, agentop and agentop exec print: Cortex is not running on 127.0.0.1:47600. Run: agentop service start.
    • agentop doctor already checks that the proxy serves. Make its fix line give the same command.
  4. A manual crash test on macOS, from a real GUI login:
    • kill -9 the proxy. Check that the supervisor restarts it, and that a running agent session continues after the restart.
    • kill -9 the supervisor. Record what happens, then check that item 1 brings Cortex back.
    • Write the results in docs/laptop-service.md.

Non-goals

  • No automatic fail-open. Cortex must not remove HTTPS_PROXY, and it must not send traffic directly to the provider when the proxy is down. A fail-open does these things without a message:
    • It turns off guardrails (IBAC, OPA) and the egress allow list.
    • It stops session recording.
    • It fires during each normal restart, which takes only seconds.
  • A user who wants to stop using Cortex keeps the manual path: agentop configure claude-code disable.

Acceptance

  • A killed supervisor comes back at the next Claude Code session start.
  • A config with a startup error does not stop agents when a last good config exists. agentop doctor reports the error.
  • A dead proxy gives a message that names Cortex and the command that fixes it.
  • docs/laptop-service.md records the kill -9 results for the proxy and for the supervisor.

Assisted-By: Claude (Anthropic AI) [email protected]

Lenguaje dominante
Go
Estrellas
26
Forks
46
Merge medio
13 h 49 min
PR fusionados (30 d)
244

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rossoctl/cortex

Todos los issues de rossoctl/cortex

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.