Skip to content

fix(process_registry): keep poll() read-only — do not mark completions consumed - #31756

Closed
someaka wants to merge 1 commit into
NousResearch:mainfrom
someaka:fix/poll-not-mark-consumed-upstream
Closed

fix(process_registry): keep poll() read-only — do not mark completions consumed#31756
someaka wants to merge 1 commit into
NousResearch:mainfrom
someaka:fix/poll-not-mark-consumed-upstream

Conversation

@someaka

@someaka someaka commented May 25, 2026

Copy link
Copy Markdown

Summary

Keeps process_registry.poll() read-only for exited background processes.

poll() should report status, not mark a notify_on_complete result as consumed. Otherwise a normal status check can race with the gateway watcher and permanently suppress the synthetic completion event before it is delivered back to the chat.

Root cause

PR #8228 added _completion_consumed tracking to avoid duplicate completion notifications. That behavior is correct for explicit consumption paths like wait() and read_log(), but not for poll():

  • wait() is a blocking consume — "give me the result, I'm done"
  • read_log() is an explicit read — "I'm reading the output, don't notify me"
  • poll() is a read-only status query — "what's the current state?"

Treating poll() as consumption causes this race:

  1. Agent starts a background process with notify_on_complete=true
  2. Process exits → completion event queued
  3. Next agent turn calls process(action="poll")
  4. poll() marks session as consumed → watcher skips notification → silent loss

Changes Made

  • tools/process_registry.py: Remove self._completion_consumed.add(session_id) from poll(). Update docstrings from "wait/poll/log" to "wait/log".
  • tests/tools/test_process_registry.py: Add test_poll_does_not_mark_completion_consumed — verifies that after poll() on an exited process, drain_notifications() still returns the completion event.

Test plan

65 passed in 4.77s

Related

Closes #10156
Refs PR #10158 (existing open PR by @de1tydev — this is a focused minimal version with only the poll() change and a regression test)

…s consumed

poll() was marking sessions as completed in _completion_consumed, which
silently suppressed notify_on_complete watcher notifications. poll() is
a read-only status query and should not have the side effect of consuming
the notification event.

The correct consumers (wait(), read_log()) already mark consumed.

Includes:
- Remove self._completion_consumed.add(session_id) from poll()
- Update docstrings: 'wait/poll/log' -> 'wait/log'
- Regression test: test_poll_does_not_mark_completion_consumed

Fixes: NousResearch#10156
Ref: NousResearch#10156
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/terminal Terminal execution and process management tool/memory Memory tool and memory providers duplicate This issue or pull request already exists labels May 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #10158 (canonical, open since April) which implements the same poll() read-only fix for #10156. Also duplicate of #31750 (same author's prior submission). Note: this PR bundles unrelated memory_manager.py changes (multi-provider support, threading lock) that are outside the poll() fix scope — consider splitting.

@someaka

someaka commented May 30, 2026

Copy link
Copy Markdown
Author

Closing — duplicate of #10158 per @alt-glitch. The poll() read-only fix is already tracked there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists tool/memory Memory tool and memory providers tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: poll() marking _completion_consumed silently suppresses watcher notification

2 participants