feat(sdk): report why a session agent was disposed (#8738)
* feat(sdk): report why a session agent was disposed A request for a session whose agent left the registry now states whether the whole runtime is shutting down, the SDK server is shutting down, or only the agent loop was unloaded. During runtime shutdown it names the last process event observed before teardown; for an agent-loop unload it gives the time and the plugin whose unload began first. The liveness check reads the registry as optional, so both stages of root disposal report the same failure. Refs #8737 * fix(sdk): keep the runtime observation out of the plugin entry exports The static gates reject a new read of the Cordis root context, a value export from a function plugin entry, and new assertions to unknown. The plugin entry now passes the server an observation built from the root fiber it already holds, the helper lives in the internal process-events module, and the new tests complete the handshake instead of casting the server. Refs #8737 * fix(sdk): keep the process-event record from throwing and state the unload origin as an observation A rejection value without a string form made the failure text throw inside a prepended listener, which would end the dispatch before the listener that owns the event. The text now falls back to a fixed marker. The plugin named for an agent-loop unload is the first one unloading at that time, which overlapping unloads can make unrelated, so the message and README say that. Refs #8737 * feat(python-sdk): log the runtime's stderr lines as they arrive The runtime writes its fatal report, including the stack of an unhandled rejection that ends the process, to its own stderr. The SDK kept those lines in memory and attached them only to initialization, timeout, and transport failures, so a host saw none of it for an ordinary JSON-RPC error. Each line now also goes to the Python logger deepseek_harness.runtime at INFO. Refs #8737
This commit is contained in:
1 parent
6fcc447c7f
commit
0750436cb4
19 files changed
+629
-16
No files matched your search
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import queue
|
||||
import subprocess
|
||||
@@ -18,6 +19,8 @@ from .errors import JsonRpcError, SdkProtocolError, TransportClosedError
|
||||
from .models import CommandExecution, IncomingRequest, InitializeResponse, JsonObject, JsonValue, Notification, ResumeSessionOptions, UserQuestionAnswer, UserQuestionRequest
|
||||
|
||||
ModelT = TypeVar("ModelT", bound=BaseModel)
|
||||
# Every line the runtime writes to stderr, as it arrives. The host's logging configuration decides whether it is shown.
|
||||
_runtime_logger = logging.getLogger("deepseek_harness.runtime")
|
||||
NotificationFilter: TypeAlias = Callable[[Notification], bool]
|
||||
UserQuestionHandler: TypeAlias = Callable[[UserQuestionRequest, threading.Event], UserQuestionAnswer | JsonObject]
|
||||
|
||||
@@ -459,7 +462,9 @@ class HarnessClient:
|
||||
if proc is None or proc.stderr is None:
|
||||
return
|
||||
for line in proc.stderr:
|
||||
self._stderr_lines.append(line.rstrip())
|
||||
text = line.rstrip()
|
||||
self._stderr_lines.append(text)
|
||||
_runtime_logger.info("dsh runtime[%d] stderr: %s", proc.pid, text)
|
||||
|
||||
def _handle_message(self, message: object) -> None:
|
||||
if not isinstance(message, dict):
|
||||
|
||||
Reference in new issue
Block a user