Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(cli): explain Docker Codex OAuth EOF

zhiwuyazhe_fjr20ff3ad1931d
diff --git a/README.md b/README.md
index e198bc98e..888038036 100644
--- a/README.md
+++ b/README.md
@@ -742,6 +742,17 @@ docker compose up --build
Open `http://localhost:8899`. Backend + frontend in one container.
+> [!NOTE]
+> **OpenAI Codex OAuth with Docker:** the browser login needs a terminal so you
+> can paste the callback URL. Run it through Compose, which allocates an
+> interactive terminal automatically:
+>
+> ```bash
+> docker compose exec vibe-trading vibe-trading provider login openai-codex
+> ```
+>
+> If you use `docker exec` directly, pass `-it` before the container name.
+
Docker publishes the backend on `127.0.0.1:8899` by default and runs the app as a non-root container user. If you intentionally expose the API beyond your own machine, set a strong `API_AUTH_KEY` and send `Authorization: Bearer <key>` from clients.
> [!NOTE]
diff --git a/agent/cli/_legacy.py b/agent/cli/_legacy.py
index ee1fb2a42..d0a1587b0 100644
--- a/agent/cli/_legacy.py
+++ b/agent/cli/_legacy.py
@@ -2881,6 +2881,21 @@ def cmd_provider_login(provider: str) -> int:
account = getattr(token, "account_id", None) or "ChatGPT"
console.print(f"[green]Authenticated with OpenAI Codex[/green] [dim]{account}[/dim]")
return EXIT_SUCCESS
+ except EOFError:
+ # ``docker exec`` does not allocate stdin/TTY unless explicitly asked
+ # to do so. oauth-cli-kit prompts for the browser callback URL after
+ # printing the authorization link, so an unattended stdin otherwise
+ # fails with the opaque ``EOF when reading a line`` error.
+ console.print(
+ "[red]Authentication error:[/red] OpenAI Codex OAuth needs an "
+ "interactive terminal to paste the callback URL."
+ )
+ console.print(
+ "[yellow]Docker:[/yellow] run `docker compose exec vibe-trading "
+ "vibe-trading provider login openai-codex` or add `-it` to "
+ "`docker exec`."
+ )
+ return EXIT_RUN_FAILED
except Exception as exc:
console.print(f"[red]Authentication error:[/red] {exc}")
return EXIT_RUN_FAILED
diff --git a/agent/tests/test_cli_provider_login.py b/agent/tests/test_cli_provider_login.py
new file mode 100644
index 000000000..5a8704296
--- /dev/null
+++ b/agent/tests/test_cli_provider_login.py
@@ -0,0 +1,21 @@
+from __future__ import annotations
+
+from unittest.mock import patch
+
+from cli import _legacy
+
+
+def test_provider_login_explains_docker_tty_requirement(capsys) -> None:
+ """An EOF from the OAuth prompt should point Docker users to a TTY command."""
+
+ with patch(
+ "src.providers.openai_codex.login_openai_codex",
+ side_effect=EOFError("EOF when reading a line"),
+ ):
+ result = _legacy.cmd_provider_login("openai-codex")
+
+ assert result == _legacy.EXIT_RUN_FAILED
+ output = capsys.readouterr().out
+ assert "interactive terminal" in output
+ assert "docker compose exec vibe-trading" in output
+ assert "-it" in output