Remove the Python SDK's unused reverse RPC direction
删除 Python SDK 未使用的反向 RPC
The [Python client](../../../../python/sdk/src/deepseek_harness/client.py) keeps an incoming-request queue, close-time wake-up, and `next_request`, `respond`, `respond_error`, and `notify` methods. The [SDK server](../../../../packages/sdk/server/src/server.ts) receives requests and emits notifications; it declares no server-originated request or client-notification handler. Searches across Python sources, examples,
English
Problem
The Python client keeps an incoming-request queue, close-time wake-up, and next_request, respond, respond_error, and notify methods. The SDK server receives requests and emits notifications; it declares no server-originated request or client-notification handler. Searches across Python sources, examples, and runtime profiles found the reverse direction only in client implementation and synthetic client tests. The exported IncomingRequest model consequently has no supported runtime producer.
This proposal narrows only the Python client. The SDK server retains its durable enqueue receipt and streamed Session events; prompt responses do not represent turn completion. The shared TypeScript transport remains bidirectional because the Codex wire adapter uses requests and notifications in both directions.
Proposal
Remove the four Python methods, _requests, and IncomingRequest from the client, models, and exports. Retain an explicit guard for an unexpected frame containing both id and method before response matching, so a server request cannot settle an unrelated pending client request. Keep client requests, response validation, incoming notification subscriptions, and shutdown unchanged.
Remove the dedicated synthetic reverse-request test. Change tests that send client notifications only to trigger fixture behavior to use a request and response instead; retain their filter-exception and concurrent-write assertions. This removes one queue and its lifetime, four public methods, one public model, and roughly three dozen source lines without adding a replacement transport.
Alternatives considered
Keep a generic Python peer for external plugins. Custom runtimes could use the methods, but no SDK method describes their request ownership, cancellation, or delivery protocol. The proposal accepts this pre-stable API loss; a future bidirectional SDK feature must supply its actual method and lifecycle requirements.
Narrow the shared TypeScript transport too. Rejected because the Codex adapter is a current bidirectional consumer. The shared implementation and its tests remain.
Acceptance criteria
- Python sources and examples have no reverse-direction API or request queue; documentation and exports describe the retained client role.
- An unexpected server request reusing a pending client id cannot complete its waiter. Notification filtering, sibling delivery, final draining, malformed-frame handling, serialized writes, and shutdown still pass their existing tests.
- Prompt submission still returns the durable enqueue receipt; no per-prompt completion promise or response-based turn result is introduced.
- Run the Python client suite and installed-runtime SDK smoke and snapshot checks, plus documentation and lint checks. Preserve the TypeScript transport and released Session fixtures.
Risks
External Python callers using custom runtime plugins lose these methods. Ignoring an unsupported request does not fulfill a hypothetical server's response expectation; this is deliberate withdrawal of that direction, not protocol parity. Revisit the proposal if a supported server-originated method lands before implementation.
中文
问题
Python 客户端 维护入站请求队列、关闭时的唤醒,以及 next_request、respond、respond_error 和 notify 方法。SDK 服务端 接收请求并发送通知,没有定义服务端主动发起的请求或客户端通知处理器。搜索 Python 源码、示例和运行时 profile 后,仅在客户端实现和合成客户端测试 中发现反向通信。因此,导出的 IncomingRequest 模型没有受支持运行时的生产方。
本提案只收缩 Python 客户端。SDK 服务端 保留持久化入队回执和 Session 事件流;prompt 响应不表示轮次完成。共享 TypeScript 传输保留双向能力,因为 Codex wire 适配器 在两个方向上都使用请求和通知。
提案
从客户端、模型和导出中删除四个 Python 方法、_requests 和 IncomingRequest。在匹配响应前,保留对同时含有 id 和 method 的意外帧的显式保护,避免服务端请求完成无关的待处理客户端请求。保持客户端请求、响应校验、入站通知订阅和关闭行为。
删除专门的合成反向请求测试。仅为触发 fixture(测试前置数据)行为而发送客户端通知的测试改用请求和响应,同时保留过滤器异常与并发写入断言。该变更删除一个队列及其生命周期、四个公共方法、一个公共模型和约三十多行源码,不增加替代传输实现。
考虑过的替代方案
保留通用 Python 对等端供外部插件使用。 自定义运行时可能使用这些方法,但没有 SDK 方法规定其请求所有权、取消或交付协议。提案接受这一稳定前 API 损失;未来双向 SDK 功能必须提供实际的方法与生命周期要求。
同时收缩共享 TypeScript 传输。 否决,因为 Codex 适配器是当前双向消费方。共享实现及其测试保留。
验收标准
- Python 源码和示例不再包含反向 API 或请求队列;文档和导出描述保留的客户端角色。
- 复用待处理客户端 id 的意外服务端请求不能完成其等待方。通知过滤、同级交付、末尾排空、错误帧处理、串行写入和关闭仍通过现有测试。
- 提交提示仍返回持久化入队回执;不引入单条提示的完成承诺或基于响应的轮次结果。
- 运行 Python 客户端测试、已安装运行时的 SDK 冒烟与快照检查,以及文档和 lint 检查。保留 TypeScript 传输和已发布 Session fixture。
风险
使用自定义运行时插件的外部 Python 调用方会失去这些方法。忽略不支持的请求无法满足假想服务端的响应期待;这是有意撤回该方向,而非保持协议等价。如果受支持的服务端主动请求方法先于实现落地,需要重新评估提案。