fix(agent): default relay completions to the progress-hook wrapper

This commit is contained in:
Konstantin Khlopkov
2026-08-30 12:43:26 +03:00
committed by Teknium
parent dcf725e6d2
commit fba6110cde
+6 -1
View File
@@ -2443,7 +2443,12 @@ def _relay_sync_completion(
from agent.auxiliary_wire import prepare_chat_messages
kwargs = prepare_chat_messages(client, kwargs)
callback = create or (lambda request: client.chat.completions.create(**request))
# The progress hook is installed per task, so every attempt for that
# task must go through _create_with_progress — including auxiliary
# retries and provider fallbacks. Defaulting at this seam covers every
# call site that predates the hook or forgets to thread create= through
# (18 of 24 today); call sites that pass their own create= keep it.
callback = create or (lambda request: _create_with_progress(client, request))
route = _relay_auxiliary_metadata(provider=provider, api_mode=api_mode)
# Isolate only the provider callback so the owning thread can unwind its lease/DB
# transaction on hard cancel without touching the shared client.