fix(python/omp-rpc): marked RPC client as closed during stop to unblock prompt waits

- Stop now marks the client as closed via `_mark_closed` with `RpcProcessExitError`, so `_wait_for_agent_end` wakes immediately instead of waiting for a timeout.
- Added a regression test using a hanging server subprocess to verify `stop()` unblocks `prompt_and_wait` promptly and raises `RpcProcessExitError`.
- Updated Kimi compatibility tests to distinguish Moonshot-hosted models from OpenCode-hosted ones for `reasoning_content` and assistant-content tool-call behavior.
This commit is contained in:
can1357
2026-05-15 05:45:48 +02:00
parent dec8e6886f
commit 7af87f773d
4 changed files with 153 additions and 12 deletions
+9 -4
View File
@@ -484,13 +484,18 @@ class RpcClient:
process.stderr.close()
except OSError:
pass
self._fail_pending(RpcProcessExitError("RPC process stopped"))
# Mark the client closed so any thread blocked in
# `_wait_for_agent_end` raises `RpcProcessExitError` instead of
# waiting for its request timeout. The stdout reader loop would
# normally do this when it observes the closed pipe, but it
# guards on `if not self._stopping:` — which is True by the time
# we get here — and so skips it. Calling `_mark_closed` directly
# closes the gap. It is idempotent: a second call (e.g. from the
# reader's exception path) returns early.
self._mark_closed(RpcProcessExitError("RPC process stopped"))
self._pending_host_tool_calls.clear()
self._pending_host_uri_requests.clear()
self._process = None
self._ready.set()
with self._event_condition:
self._event_condition.notify_all()
if self._stdout_thread is not None:
self._stdout_thread.join(timeout=1.0)
if self._stderr_thread is not None: