From 844cef444b02eb073fe7e8df3c9c47a10bb2415d Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 22 Jun 2026 20:16:56 -0400 Subject: [PATCH] test(openai): clarify async API key sync failure trace (#38379) Clarifies why the async callable API-key integration test intentionally creates a failed `ChatOpenAI` run in scheduled LangSmith traces. The sync invocation is expected to fail because async API-key callables are only valid for async model methods. --- .../openai/tests/integration_tests/chat_models/test_base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/partners/openai/tests/integration_tests/chat_models/test_base.py b/libs/partners/openai/tests/integration_tests/chat_models/test_base.py index 6ad56f11184..e81d692e57f 100644 --- a/libs/partners/openai/tests/integration_tests/chat_models/test_base.py +++ b/libs/partners/openai/tests/integration_tests/chat_models/test_base.py @@ -111,8 +111,10 @@ async def test_callable_api_key_async(monkeypatch: pytest.MonkeyPatch) -> None: assert isinstance(async_response, AIMessage) assert calls["async"] == 1 - with pytest.raises(ValueError): - # We do not create a sync callable from an async one + with pytest.raises(ValueError, match="Sync client is not available"): + # This intentionally records a failed ChatOpenAI run in scheduled LangSmith + # traces: async API-key callables are valid for async methods, but sync + # invocation must fail. _ = model.invoke("hello")