Skip to content

fix(models): concurrency-safe reasoning patch via ContextVar#254

Merged
Lightblues merged 1 commit into
mainfrom
fix/reasoning-concurrency
Mar 17, 2026
Merged

fix(models): concurrency-safe reasoning patch via ContextVar#254
Lightblues merged 1 commit into
mainfrom
fix/reasoning-concurrency

Conversation

@Lightblues

Copy link
Copy Markdown
Collaborator

Summary

  • Replace per-call monkey-patching of Converter.items_to_messages with a one-time global patch + ContextVar
  • Eliminates RecursionError and reasoning field corruption under concurrent asyncio execution
  • Remove unused draft file reasoning.py

Changes

  • utu/models/reasoning_chat_completions.py: Capture original function once at module load, use ContextVar for per-task strategy isolation, remove instance method _make_patched_items_to_messages

Closes #253

Replace per-call monkey-patching of Converter.items_to_messages with a
one-time global patch + ContextVar. Fixes RecursionError and reasoning
field corruption under concurrent asyncio execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Lightblues Lightblues merged commit 437a4db into main Mar 17, 2026
1 of 2 checks passed
@Lightblues Lightblues deleted the fix/reasoning-concurrency branch March 17, 2026 13:24
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.

fix: concurrency-safe reasoning field patch | easons_agent

1 participant