fix(gateway): defer goal status notices until after response delivery

Route goal status notices through the platform adapter send API and register post-delivery callbacks so completed-goal notices appear after the final assistant response. Also cancel queued synthetic goal continuations on /goal pause and /goal clear while preserving normal queued user messages.
This commit is contained in:
JC 2026-05-03 08:57:28 +08:00 committed by Teknium
parent 7d66d30d77
commit 03ddff8897
3 changed files with 300 additions and 36 deletions

View file

@ -3146,7 +3146,9 @@ class BasePlatformAdapter(ABC):
_post_cb = getattr(self, "_post_delivery_callbacks", {}).pop(session_key, None)
if callable(_post_cb):
try:
_post_cb()
_post_result = _post_cb()
if inspect.isawaitable(_post_result):
await _post_result
except Exception:
pass
# Stop typing indicator