The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(codex): pin source-aware OAuth classification for plugin 401 stderr
teknium13e7a8636e807
diff --git a/tests/agent/transports/test_codex_app_server_session.py b/tests/agent/transports/test_codex_app_server_session.pyindex 65b2d1fe190..84836092be2 100644--- a/tests/agent/transports/test_codex_app_server_session.py+++ b/tests/agent/transports/test_codex_app_server_session.py@@ -383,7 +383,28 @@ class TestRunTurn:assert "sk-stalled-secret-abc123" not in r.errorassert r.should_retire is True+ @pytest.mark.parametrize("op", ["run_turn", "compact_thread"])+ def test_plugin_401_stderr_keeps_primary_rpc_error_visible(self, op):+ """#75167: an ambient ChatGPT plugin prewarm 401 in codex stderr must not rewrite an+ unrelated RPC error into the `codex login` hint (turn and compaction paths alike)."""+ from agent.transports.codex_app_server import CodexAppServerError++ client = FakeClient()+ client.set_stderr_tail(["WARN ChatGPT plugin prewarm failed: HTTP 401 Unauthorized"])++ def boom(method, params):+ if method in ("turn/start", "thread/compact/start"):+ raise CodexAppServerError(code=-32603, message="internal error: workspace initialization failed")+ return {"thread": {"id": "t"}, "activePermissionProfile": {"id": "x"}}+ client._request_handler = boom+ s = make_session(client)+ r = getattr(s, op)(*(["hi"] if op == "run_turn" else []), turn_timeout=2.0)+ assert r.error is not None+ assert "workspace initialization failed" in r.error+ assert "plugin prewarm failed" in r.error # stderr tail still attached for debugging+ assert "codex login" not in r.error+ assert r.should_retire is Falsedef test_steer_appends_input_to_active_turn(self):@@ -924,5 +945,22 @@ class TestClassifyOAuthFailure:)assert _classify_oauth_failure() is Noneassert _classify_oauth_failure("") is None- assert _classify_oauth_failure("", None) is None # type: ignore[arg-type]+ assert _classify_oauth_failure("", stderr=None) is None # type: ignore[arg-type]++ @pytest.mark.parametrize(+ "primary, stderr, expected",+ [+ ("internal error: workspace initialization failed", "ChatGPT plugin prewarm failed: HTTP 401 Unauthorized", False),+ ("", "plugin discovery: oauth handshake returned 401 unauthorized", False),+ ("HTTP 401 Unauthorized", "", True),+ ("internal error", "token refresh failed: invalid_grant", True),+ ],+ ids=["plugin-401-stderr-keeps-rpc-error", "plugin-401-stderr-keeps-timeout", "primary-401", "strong-stderr-signal"],+ )+ def test_generic_auth_words_count_only_in_primary_error(self, primary, stderr, expected):+ """#75167: ambient plugin 401/oauth stderr must not become the re-login hint; the+ primary error's own 401 and strong stderr credential signals still do."""+ from agent.transports.codex_app_server_session import _classify_oauth_failure++ assert (_classify_oauth_failure(primary, stderr=stderr) is not None) is expected