fix: keep Anthropic BYOK notes from failing conversation processing
Summary
Error group: {"source": "gcp", "service": "backend", "group": "process_conversation.py:620 | fastapi.exceptions.HTTPException: 500: Error processing conversation, please try again later", "count": 109, "id": "gcp:backend-process-conversation-py-620-fastapi-exceptions-httpexception-500-error-processing-conversation-please-"}
Root cause: _get_structured wraps the notes failure as that generic HTTP 500. The chained error is TypeError: Shaped notes requires the configured OpenAI-compatible notes lane in isolated_notes_model. Provider-switched BYOK notes use ChatAnthropic, and the worker-loop transport clone only accepted ChatOpenAI, so those conversations never reached the model.
Fix: clone the Anthropic async client onto a per-invocation HTTP transport the same way the OpenAI lane already does, and leave the cached client untouched.
Verification
python3.11 -m py_compile backend/utils/llm/shaped_notes_transport.py backend/tests/unit/test_shaped_agent.py
python3.11 -m pytest tests/unit/test_shaped_agent.py::test_anthropic_only_byok_notes_preserve_transport_and_omit_cache_hints tests/unit/test_shaped_agent.py::test_notes_transport_is_owned_per_worker_loop -q --tb=short
2 passed, 8 warnings in 18.30s
Failure-Class: none