Skip to content

fix: keep Anthropic BYOK notes from failing conversation processing - #21131

Merged
Git-on-my-level merged 3 commits into
mainfrom
fix/errfix-1010-gcp-process-conversation-py-620-fastapi
Oct 13, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
fix/errfix-1010-gcp-process-conversation-py-620-fastapi

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

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

View guided diff Turn on auto-fix

The notes worker-loop clone only accepted ChatOpenAI, so a provider-switched Anthropic key raised TypeError and the conversation returned HTTP 500.

Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T14:59:16.667005Z fae345a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Root cause of the red unit shards (diagnosed from run 38048116131 logs):

This PR adds a module-level from langchain_anthropic import ChatAnthropic to backend/utils/llm/shaped_notes_transport.py. The unit suite path-loads that module (e.g. tests/unit/test_action_item_date_validation.py::_load_module_from_file) in processes where test-isolation helpers have stubbed langchain_core in sys.modules, so langchain_anthropic's import fails: ModuleNotFoundError: No module named 'langchain_core.callbacks' (also 'langchain_core' is not a package). That breaks collection of unrelated test files and surfaces in test_lock_bypass_fixes.py failures with the same signature — shard 4 red while shards 1-3 stay green.

A fix (lazy/TYPE_CHECKING-gated anthropic import) is being pushed to this branch.

Git-on-my-level and others added 2 commits October 13, 2026 20:38
A module-level langchain_anthropic import fails when unit tests have replaced langchain_core in sys.modules.

Co-authored-by: Cursor <[email protected]>
…sport

Catch the Anthropic import failure so path-loaded unit tests still collect, while pyright keeps the real ChatAnthropic narrowing.

Co-authored-by: Cursor <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

errfix finisher: this PR has been open >3 days without merging — escalating to a human.

@Git-on-my-level
Git-on-my-level merged commit 38a7c22 into main Oct 13, 2026
56 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/errfix-1010-gcp-process-conversation-py-620-fastapi branch October 13, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant