fix: dedupe background process notifications#15277
Open
realraelrr wants to merge 1 commit into
Open
Conversation
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #15276
Summary
This PR prevents duplicate agent-facing background-process notifications when
notify_on_completeandwatch_patternsboth apply to the same process.The fix makes successful gateway delivery of a completion notification update the same consumed state already used by
wait,poll, andread_log. Watch notifications now check that state before interrupting the agent, so a process that has already delivered its completion event cannot later send a duplicate watch notification for the same completed session.Problem
Background processes already track whether completion has been consumed, but that state was only updated through tool read paths such as
wait,poll, andread_log.When the gateway itself injected a synthetic
notify_on_completemessage into the agent thread, the registry still considered the completion unconsumed. If the same process also produced output matchingwatch_patterns, the watch path could inject another synthetic notification for that already-completed process.Changes
ProcessRegistry.mark_completion_consumed(session_id)for explicit gateway-side completion delivery.notify_on_completeinjection._inject_watch_notificationfor process sessions whose completion has already been consumed.Files Changed
tools/process_registry.pygateway/run.pytests/tools/test_notify_on_complete.pytests/gateway/test_internal_event_bypass_pairing.pyBehavior Notes
wait,poll, orread_logcompletion semantics.Test Plan