From 8fc73bd99aebc5dfebc22e7d0438a4d6b1e43099 Mon Sep 17 00:00:00 2001 From: roberttwang Date: Fri, 27 Nov 2026 07:11:39 +0000 Subject: [PATCH 1/7] fix(web): send operator context to retry and rework once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The workbench merged 补充上下文 into reason and also sent it as context. The engine composes reason + context itself (composeHumanFeedback), so the reworked or retried node got the context twice in its feedback, and a third time in the human-context section of its prompt. The pre-merged copy also skipped the server's 8000-byte context cap. Send reason and context separately, as the 从这里重跑 path already does. Co-Authored-By: Claude Code --- web/app/approvals.js | 5 +-- web/human_context_test.go | 16 ++++++++++ web/human_context_test.js | 65 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 web/human_context_test.go create mode 100644 web/human_context_test.js diff --git a/web/app/approvals.js b/web/app/approvals.js index 19dc6cfcd..04fcac50f 100644 --- a/web/app/approvals.js +++ b/web/app/approvals.js @@ -8,11 +8,12 @@ function readHumanContext(fromEl){ const root=fromEl?.closest?.('[data-human-context-root], .approval-callout, .ap-card, .issue-outcome, .node-inspector, .human-decision'); return String(root?.querySelector?.('[data-human-context]')?.value||'').trim(); } +// The server composes reason + context into the node feedback (and caps the +// context); sending them pre-merged would repeat the context in the prompt. function withHumanContext(payload){ const context=String(payload?.context||'').trim(); if(!context)return payload; - const reason=String(payload.reason||'').trim(); - return {...payload, context, reason:reason?`${reason}\n\n人工补充上下文:\n${context}`:context}; + return {...payload, context}; } function reworkTarget(node,nodes){ const id=String(node?.rejectTo||'').trim(); diff --git a/web/human_context_test.go b/web/human_context_test.go new file mode 100644 index 000000000..81d84683c --- /dev/null +++ b/web/human_context_test.go @@ -0,0 +1,16 @@ +package web + +import ( + "os/exec" + "testing" +) + +func TestWorkbenchSendsHumanContextOnce(t *testing.T) { + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node not installed") + } + if out, err := exec.Command(node, "human_context_test.js", appBundlePath(t)).CombinedOutput(); err != nil { + t.Fatalf("human context: %v\n%s", err, out) + } +} diff --git a/web/human_context_test.js b/web/human_context_test.js new file mode 100644 index 000000000..2787c8498 --- /dev/null +++ b/web/human_context_test.js @@ -0,0 +1,65 @@ +// The operator's 补充上下文 reaches the reworked node exactly once: the +// workbench sends reason and context separately and the server composes them +// (engine.composeHumanFeedback), so the client must not pre-merge them. +const fs = require('node:fs'); +const path = require('node:path'); +const vm = require('node:vm'); +const assert = require('node:assert/strict'); +function localBundle() { + const page = fs.readFileSync(path.join(__dirname, 'index.html'), 'utf8'); + const modules = [...page.matchAll(/