Skip to content

feat(sdk-java): Project Runtime tool replies onto the broker contract - #3

Draft
doudouOUC wants to merge 1 commit into
cursor/upstream-main-3df3from
cursor/http-runtime-transport-3df3
Draft

doudouOUC wants to merge 1 commit into
cursor/upstream-main-3df3from
cursor/http-runtime-transport-3df3

Conversation

@doudouOUC

Copy link
Copy Markdown
Owner

What this PR does

Makes the Java HTTP client for the Managed Runtime a RuntimeTransport. Execute still returns the settled result. Status and cancel answers are projected to the Broker's closed shape: only state, plus result when the state is settled. protocolVersion and lastSequence stay on the wire, where they are still validated, and are not handed to the Broker. Acquire, control, and release fail closed with runtime_session_verb_unsupported, because those session verbs are not part of the merged v2 tool contract.

Why it's needed

The Broker already calls RuntimeTransport for dispatch, cancellation, and original-execution lookup. The HTTP client had the three tool operations, but it was not that interface, and a status reply still carried wire-only fields that the reconciler rejects. This is the adapter slice between the merged client and a future caller that passes this transport into the Broker. It does not mount the worker or change session lifecycle.

Reviewer Test Plan

How to verify

From packages/sdk-java/runtime-broker on JDK 21:

mvn -Dtest=HttpRuntimeTransportTest test
mvn checkstyle:check

A status or cancel reply that includes protocolVersion and lastSequence comes back as only state and, when settled, result. Invalid sequences still fail before that projection. acquire completes with HTTP 501 runtime_session_verb_unsupported and is not retryable.

Evidence (Before & After)

N/A

Local result: HttpRuntimeTransportTest 42 tests passed, and Checkstyle reported no violations.

Tested on

OS Status
🍏 macOS ⚠️
🪟 Windows ⚠️
🐧 Linux ✅

Environment (optional)

JDK 21, Maven 3.8.7, Linux.

Risk & Scope

  • Main risk or tradeoff: a caller that previously read lastSequence from the status map no longer sees it. The Broker contract already required that field to be stripped.
  • Not validated / out of scope: Broker service wiring, worker handlers, and the session verbs acquire, control, and release. Those routes are not in the v2 tool contract, so this transport refuses them instead of calling a missing path.
  • Breaking changes / migration notes: none for production callers. No production class constructed this client as a RuntimeTransport before this change.

Related to QwenLM#12380. Split from the preview in QwenLM#12358.

中文说明

这个 PR 做了什么

Java 的 Managed Runtime HTTP 客户端现在实现 RuntimeTransport。execute 仍返回已结算结果。status 和 cancel 的应答被投影成 Broker 的封闭形态:只有 state,并且仅在 settled 时带 result。protocolVersion 和 lastSequence 仍在线上校验,不再交给 Broker。acquire、control 和 release 以 runtime_session_verb_unsupported 失败关闭,因为这些会话动词不在已合入的 v2 工具契约里。

为什么需要

Broker 已经通过 RuntimeTransport 做 dispatch、取消和按原执行查询。HTTP 客户端有这三个工具操作,但实现的不是这个接口,status 应答还带着对账器会拒绝的线上字段。这一笔是已合入客户端和未来调用方之间的适配切片,不挂载 worker,也不改会话生命周期。

评审测试计划

在 packages/sdk-java/runtime-broker 上运行 mvn -Dtest=HttpRuntimeTransportTest test 和 mvn checkstyle:check。带 protocolVersion 和 lastSequence 的 status/cancel 应答只回 state,settled 时还回 result。非法序号仍在投影前失败。acquire 以 HTTP 501 runtime_session_verb_unsupported 结束,且不可重试。

本地:42 个测试通过,Checkstyle 无违规。Linux 已测,macOS 和 Windows 未测。

风险与范围

以前从 status map 读 lastSequence 的调用方不再看到该字段。Broker 契约本来就要求剥掉它。不包含 Broker 服务接线、worker 处理器,以及 acquire/control/release。这些路由不在 v2 工具契约中,因此本传输直接拒绝,而不去调一条不存在的路径。

关联 QwenLM#12380,从预览 QwenLM#12358 拆出。

Open in Web Open in Cursor 

HttpRuntimeTransport now implements RuntimeTransport. Status and cancel
answers keep only state and a settled result, and session verbs that the
v2 tool contract does not define fail closed.

Co-authored-by: jinye <doudouOUC@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants