Repository navigation
feat(cli): Mount the v2 tool operations on the Managed Runtime worker #12671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
bd1594e
37fd360
a5b867e
1cecf1a
be47e55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,10 +46,13 @@ export class ManagedToolConflictError extends Error { | |
| readonly code = 'managed_runtime_identity_conflict'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] R1-34: The Grep over Witness: mutation deleting the field ( Suggested fix: either delete the field (the route literals are the only truth today), or emit it — The wire string must stay exactly 中文说明
在 见证: 删除该字段的变异( 建议修复: 要么删掉字段(今天路由字面量才是唯一真值),要么真正发出它——在 无论哪种方式,线上字符串都必须保持为 — qwen3.8-max via Qwen Code /review (v0.24.6) |
||
| } | ||
|
|
||
| export class ManagedToolInvalidError extends Error {} | ||
|
|
||
| interface JournalEntry { | ||
| readonly reference: ManagedToolReference; | ||
| readonly toolName: string; | ||
| readonly input: Record<string, unknown>; | ||
| readonly inputJson: string; | ||
| state: ManagedToolExecutionState; | ||
| lastSequence: number; | ||
| result?: ManagedToolResultPayload; | ||
|
|
@@ -106,9 +109,17 @@ export class ManagedToolExecutor { | |
| toolName: string, | ||
| input: Record<string, unknown>, | ||
| ): Promise<ManagedToolResultPayload> { | ||
| let inputJson: string; | ||
| try { | ||
| inputJson = JSON.stringify(input); | ||
| } catch { | ||
| throw new ManagedToolInvalidError( | ||
| 'Managed Runtime tool request is invalid.', | ||
| ); | ||
| } | ||
| const existing = this.entries.get(reference.callId); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Critical] R1-2: [fails-closed] [new-surface] The invocation journal is keyed on
Witness (real executor, unmodified PR code): Suggested fix: key the journal on the full call identity (e.g. The composite key must not include Add a worker case: same 中文说明调用日志仅以
见证(真实 executor,未修改的 PR 代码): 建议修复: 日志主键改为完整调用身份(如 复合键不能包含 新增 worker 用例:同一 — qwen3.8-max via Qwen Code /review (v0.24.6) |
||
| if (existing) { | ||
| if (!sameInvocation(existing, reference, toolName, input)) { | ||
| if (!sameInvocation(existing, reference, toolName, inputJson)) { | ||
| throw new ManagedToolConflictError( | ||
| 'Managed Runtime invocation identity conflicts.', | ||
| ); | ||
|
|
@@ -122,15 +133,28 @@ export class ManagedToolExecutor { | |
| `Managed Runtime does not admit tool ${toolName}.`, | ||
| ); | ||
| } | ||
| if (toolName === ShellTool.Name && input['is_background'] === true) { | ||
| throw new ManagedToolConflictError( | ||
| 'Managed Runtime does not admit background shell execution.', | ||
| ); | ||
| if (toolName === ShellTool.Name) { | ||
| let isBackground = false; | ||
| try { | ||
| const params = structuredClone(input); | ||
| // Admission must see the same normalized parameters as build(). | ||
| isBackground = | ||
| tool.validateToolParams(params) === null && | ||
| params['is_background'] === true; | ||
| } catch { | ||
| // Let run() journal parameter failures through its normal error path. | ||
| } | ||
| if (isBackground) { | ||
| throw new ManagedToolConflictError( | ||
| 'Managed Runtime does not admit background shell execution.', | ||
| ); | ||
| } | ||
| } | ||
| const entry: JournalEntry = { | ||
| reference, | ||
| toolName, | ||
| input, | ||
| inputJson, | ||
| state: 'prepared', | ||
| lastSequence: 0, | ||
| controller: new AbortController(), | ||
|
|
@@ -254,12 +278,12 @@ function sameInvocation( | |
| entry: JournalEntry, | ||
| reference: ManagedToolReference, | ||
| toolName: string, | ||
| input: Record<string, unknown>, | ||
| inputJson: string, | ||
| ): boolean { | ||
| return ( | ||
| sameReference(entry.reference, reference) && | ||
| entry.toolName === toolName && | ||
| JSON.stringify(entry.input) === JSON.stringify(input) | ||
| entry.inputJson === inputJson | ||
| ); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] R1-4: Mounting the tool routes and flipping this status line to "worker handlers ... implemented" falsifies three sibling design docs this PR does not touch — in both EN and zh-CN, which AGENTS.md requires to stay synchronized.
A maintainer or Broker-side wirer reading those docs plans work that has already landed, or treats a successful
execute(200settled) as a contract violation. Stale at this commit: (a)2026-09-23-managed-runtime-process-adoption.md:17(+zh-CN:17) "The merged worker still exposes only attestation, so execute against that process is a non-retryable 404"; (b)2026-09-22-managed-runtime-attestation-contract.md:55/92/109/127(+zh-CN :5/47/77/81/98/116) "the raw gate rejects those routes until their real handlers land" / "the only admitted operation is the exact attestation route" / "the attestation-only process"; (c)managed-runtime-broker-service-core.md:117(+zh-CN:116) "The Java HTTP tool transport is implemented, but its worker routes and service adapter remain follow-up work" — only the "worker routes" half is now false ("service adapter" is still open).Witness:
not run— documentation claim; verified by reading the cited files at HEADbe47e552and confirming viagit diff --name-only merge-base..HEADthat this PR changes only 9 files, none of them these three docs.Suggested fix: in the same change, update the three sibling docs (EN and zh-CN together) to point at §3.1/§6 (four routes mounted and gate-admitted); for
broker-service-core, rewrite to name only what is still open (the service adapter), not delete the sentence.中文说明
挂载工具路由并把本状态行翻成 "worker handlers ... implemented",会使本 PR 未触及的三份兄弟设计文档失真——中英两版皆然,而 AGENTS.md 要求两版保持同步。
读到这些文档的维护者或 Broker 侧接线者会去规划已经落地的工作,或把一次成功的
execute(200settled)当成契约违背。在此 commit 已失真的有:(a)2026-09-23-managed-runtime-process-adoption.md:17(+zh-CN:17)"已经合入的 worker 仍然只暴露 attestation,所以对这个进程执行工具会得到不可重试的 404";(b)2026-09-22-managed-runtime-attestation-contract.md:55/92/109/127(+zh-CN :5/47/77/81/98/116)"在真实 handler 落地之前 raw gate 会拒绝这些路由"/"唯一放行的操作是精确的 attestation route"/"attestation-only process";(c)managed-runtime-broker-service-core.md:117(+zh-CN:116)"Java HTTP 工具 transport 已实现,但 worker 路由与服务适配层仍待后续完成"——现在只有"worker 路由"这半边为假("服务适配层"仍未完成)。见证:
not run——文档类主张;通过在该 HEADbe47e552读取被引文件、并用git diff --name-only merge-base..HEAD确认本 PR 只改 9 个文件(都不含这三份文档)核实。建议修复: 在同一笔变更中更新这三份兄弟文档(中英同步),指向 §3.1/§6(四条路由已挂载并被 gate 放行);
broker-service-core那句改写为只列仍未完成的部分(服务适配层),而非删除。— qwen3.8-max via Qwen Code /review (v0.24.6)