refactor(agent): delegate recovery channel eligibility to admission
This commit is contained in:
1 parent
29d0023fca
commit
3e40684112
4 files changed
+43
-23
No files matched your search
@@ -1451,13 +1451,10 @@ class AgentLoop:
|
||||
msg,
|
||||
session_key_override=effective_key,
|
||||
)
|
||||
# A newer WebUI message must supersede an explicit recovery
|
||||
# before it is injected into that recovery's pending queue.
|
||||
# Without this admission point, a recovered turn could finish
|
||||
# first and only then observe the user's newer request.
|
||||
# Mid-turn injection bypasses _dispatch_one, so admit before joining
|
||||
# an active queue. Admission may cancel its worker and release the queue.
|
||||
if (
|
||||
effective_key in self._pending_queues
|
||||
and msg.channel == "websocket"
|
||||
and self._recovery_admission is not None
|
||||
and not await self._recovery_admission.admit(routed_msg)
|
||||
):
|
||||
|
||||
@@ -50,7 +50,12 @@ def request_origin_from_metadata(metadata: Mapping[str, Any]) -> RequestOrigin |
|
||||
|
||||
|
||||
class RecoveryAdmission(Protocol):
|
||||
"""Narrow AgentLoop boundary for explicit recovery validation."""
|
||||
"""Own recovery eligibility before queue injection and worker dispatch.
|
||||
|
||||
Messages carry their effective session key and may come from any channel.
|
||||
Implementations must tolerate repeated admission. Admission may cancel an
|
||||
active worker, so callers must re-read queue ownership afterwards.
|
||||
"""
|
||||
|
||||
async def admit(self, message: InboundMessage) -> bool: ...
|
||||
|
||||
|
||||
Reference in new issue
Block a user