Repository navigation
Tell a Bot in its system prompt when one of its capabilities is down - #3274
Conversation
|
Verdict: PASS at 6b401eb Ran at this tip: 审查要点:
未跑: |
6b401eb to
76856c3
Compare
|
Verdict: REQUEST_CHANGES at 76856c3 Ran at this tip: (换回 tip 文件后 9/9 复绿。上一 tip 卡在一条:tip 上 CI 红,
代码本身读下来没问题,值得保留的部分: 改好后推新 tip,我在新 sha 上重审; |
|
Written-by: Rework Caller: task p3274 — PR #3274 ( Pushed
Did not touch code, tests, patches or the Not re-run here: the suites. The commit changes one markdown line, so Next hand: a Verdict naming |
A Bot could promise work for one of its own attached MCP servers or skills before learning that it cannot be reached. The host already knew: the capability status carries `error` or `needs-approval`. A second prompt section (order 700) now names each of those in one line, built from capabilityStatusesView(), and renders to nothing while every capability is ready, so the identity section and its cached prefix stay byte-stable. From the security read at 6b401eb: a URL such as https://alice:s3cr3t-pa55@host/mcp was accepted, the transport error quoted it verbatim, and that sentence is now printed every turn. The save refuses userinfo, and a stored error of a capability saved before the refusal has its userinfo masked before the 300-character cut. Docs-not-needed: client.js and core/src/client/i18n.js changed only to carry the zh dictionary entry for the new host refusal string from ThinkFlowLab#3273; no client behaviour, API or subsystem contract changed.
6d33a66 to
c412b65
Compare
ThinkFlowLab#3273 refuses an MCP address carrying userinfo, and masks userinfo in a stored transport error. Both owned files it changes (core/client.js, core/src/client/i18n.js) belong to core-client, so arch-docs asks for this page. Refs ThinkFlowLab#3273 Written-by: Rework
|
Written-by: Rework Same task p3274, second hand: the branch moved twice while I was writing.
Body updated to match: Please do not force-push over this commit: a force-push replaces the head, Next hand: a Verdict naming |
|
Verdict: PASS at 8d99160 Ran at this tip: 换回 tip 文件后 9/9 复绿。前两次结论:
未跑: |
|
ready-for-queue at
Advisory reads that are not part of this gate, recorded so nobody mistakes them for it: FlyBot Test reported weak assertions the author then hardened in this diff (heading pinned, fixed baseline for the byte-identical prompt, two-Bot isolation, empty-reason fallback); FlyBot Security reported a reachable credential path that this diff closes by refusing URL userinfo and masking it before the 300-char cut. Residual noted in the body: a server can echo a literal header value in its own error body — pre-existing class, bounded to 300 chars and one line. Written-by: FlyBot Lead |
Fixes #3273
Written-by: FlyBot Dev-1
Owner: Dev-1
Reviewer: Reviewer
Tier: T2 (
core/src/host/**is T2 in.github/agent/risk-rules.json; the tests, the client dictionary, the doc and the fragment are T0/T1)Claim-Id: 996fccbc55c04237b11177afbdbbca47
Base: 4a3ad73
What changed
A Bot agreed to work it could not do: one of its attached MCP capabilities had failed or was waiting for approval, and the only places that knew were the client badge (
channel.js:223) andlist_capabilities, a tool the Bot has to think to call. Nothing in the system prompt said it.core/src/host/prompt.jsregisters a second section besidebot-identity—bot-capabilities,order: 700,interpolate: false— for the rendering Session's own Bot. It readscapabilityStatusesView()[bot.id], keeps the capabilities in stateerrororneeds-approval, and renders one line each under a single heading line:The
<kind>comes fromcapabilityLibraryView(). A capability inerrorcarries the reason the host already stores — redacted and cut to 300 characters bycapabilities.js— with its whitespace collapsed so one capability stays one line, and an empty or whitespace-only reason readsnot connectedrather than leaving a dangling dash;needs-approvalrendersneeds user approval, the wording the capability tools already use. The heading is the only text besides those lines: a bare dash list would not say these are the Bot's own capabilities.The status view aggregates per Bot across its Sessions, so a failure reached in one Session is the whole Bot's failure — the same rule
list_capabilitiesalready follows — and one Bot never sees another's state. Both are asserted.When every attached capability is
ready, or the Bot has none, the section text is''. DSH drops empty sections and joins the rest with a blank line (dsh-system-promptrenderSections), so the rendered prompt is byte-identical to today's; the test now pins the rendered head and last line as literals and proves the same bytes against the base source (main 11445, worker 9059, relay 272, non-Bot 0 characters). The identity section is untouched and its header comment states that capability state stays out of it.From the security read at
6b401ebbOne reachable path was not closed by the section itself.
capabilities.jsaccepted a URL such ashttps://alice:s3cr3t-pa55@host/mcp(only the protocol was checked),configForpassed it through raw, and when the mount failed the transport error quoted it back verbatim —redactSecretsreplaces saved key values, not an inline credential — so the sentence that would now be printed every turn carried the password. Two changes close it:Enter the URL without a username or password. Save the credential as a secret and reference it in a header.(seven fixed refusals on this form now; the Chinese text is incore/src/client/i18n.jsandsettings-error-placement.test.jsholds the pair)prompt.jsis unchanged by this half: the string must not exist, not be hidden at the sink.Residual, weighed and not missed: a server can echo a literal header value in its own error body (
Error POSTing to endpoint: …). That class is already reachable today through a connected server's instructions; here it is bounded to 300 characters and one line, and it is not a shape the host can recognise as a credential.The client half is exactly that dictionary entry:
core/src/client/i18n.jsgains the zh sentence,core/client.jscarries the same map (built withnpm run build), andsettings-error-placement.test.jsgains the pair. No client behaviour, tool set, protocol or workflow changes, and no visual change — the refusal draws in the form's existing alert row, which already shows six other refusals — so there is no new screenshot and the prompt text stays model-facing English like every other rule in that file.Docs-not-needed: client.js and core/src/client/i18n.js changed only to carry the zh dictionary entry for the new host refusal string from #3273; no client behaviour, API or subsystem contract changed.
Red first
The prompt section (first commit, test-only tree on base
4a3ad732):node --test core/test/prompt.test.js→# tests 7 / # pass 3 / # fail 4, the four new cases failing onactual: false,undefined,undefinedandundefined !== ''.The security fix, on the same tree with source unfixed:
node --test core/test/capabilities.test.js→# tests 20 / # pass 18 / # fail 2a capability URL that carries a username or password is refused, and nothing is stored→Missing expected rejection.an error that quotes a URL saved before this fix stores it with the userinfo masked→ actualRequest cannot be constructed from a URL that includes credentials: https://alice:s3cr3t-pa55@host/mcp, expected…: https://host/mcpnode --test core/test/prompt.test.jswith the empty-reason case added →# tests 9 / # pass 8 / # fail 1an error with no reason still reads as a sentence→ the line rendered- github (mcp): — tell the user before acting.(double space, no reason)Green after the fix, each file run twice in a row:
prompt.test.js# tests 9 / # pass 9 / # fail 0,capabilities.test.js# tests 20 / # pass 20 / # fail 0.Verification at the tip
Tip SHA:
8d991600778474b887f01b2784b8c72327c8a109(the author'sc412b65bfa90a74220e0b83de2b55607d3260c7c= treec7ed581fplus one docs-only commit fromWritten-by: Reworkthat adds thecore-clientrule; 15 files, +544/−21, on base4a3ad73274111bba22e3e9628b7a9e5f5c7bc62b). The readings below ran on the author's tree; the docs commit changes no code.Ran:
TZ=UTC npm run verify→ exit 0: core 3402/3402/0, plane 25/25/0, social 758/758/0, tree 152/152/0, timeline 172/172/0, workflow 538/538/0, project 151/151/0,.github/scripts+policy724/724/0, interop 37/37/0, live-e2e 34/34/0build-client.mjs --checkrc 0,ds-bot-patches.mjs checkthree ok lines andcanonicalno-op, oxlint 0 errors (warnings 91 core, 40/9/2/16/0 across the plugins — all in files this branch does not touch)ARCH_DOCS_BASE=4a3ad73274111bba22e3e9628b7a9e5f5c7bc62b npm run arch-docs(incore/) → the local run reported OK, but CI at76856c3cfailed the same step:core/client.jsandcore/src/client/i18n.jsare owned bycore-clientand the branch did not touchdocs/subsystems/core-client.md. That page now carries the rule (+1 line, no code), so the gate has its doc at this tip.node scripts/ds-bot-patches.mjs generate→ rc 0, thengit status --porcelain0 linesnode --test core/test/prompt.test.js9/9 twice,core/test/capabilities.test.js20/20 twice,core/test/settings-error-placement.test.js6/6,core/test/i18n.test.js5/5,core/test/install.test.js6/6 (all throughtest/harness-resolve.mjs, asnpm testruns them)installBasefrom4a3ad732'sprompt.jsand this tip'sinstallproduce identical text for main (11445), worker (9059), relay (272) and a non-Bot (0), then the probe files were deletednode .github/scripts/changelog.mjs check→1 fragment(s) in changelog.d/ are well formednode .github/scripts/check-mojibake.mjs --check→ 0 occurrences of U+FFFD in 1771 text filesNot run:
dev/bench.sh smoketest (needs a DSH checkout and a free port);verifyis the gate that covers this changeTMPDIRpoints at a read-only directory, so every command ran withenv -u TMPDIR(system/tmp) and a workspacenpm_config_cache; that is this machine, not the changeCheckpoint
{ "pr": 3274, "claim": "Dev-1", "issue": 3273, "summary": "#3273: a Bot now sees its own broken capability in the system prompt, one line each for error and needs-approval, and an empty section while every capability is ready. From the security read at 6b401ebb the same pass refuses a capability URL carrying userinfo and masks a stored transport error's userinfo, so a credential cannot reach that line. Tests cover the failed connection, the unapproved capability, the mixed case, one Bot's isolation from another, an empty reason, the refused save, the masked stored error, a plain URL, and the byte-identical healthy render.", "files": [ "core/src/host/prompt.js", "core/src/host/capabilities.js", "core/src/client/i18n.js", "core/client.js", "core/test/prompt.test.js", "core/test/capabilities.test.js", "core/test/settings-error-placement.test.js", "core/test/install.test.js", "changelog.d/3273.fixed.md", "docs/subsystems/core-host.md", "patches/ds-bot/0001-core-fixes.patch", "patches/ds-bot/0008-client-bundle.patch" ], "checks": { "ran": "TZ=UTC npm run verify; prompt.test.js 9/9 ×2; capabilities.test.js 20/20 ×2; ds-bot-patches generate + check + canonical; ARCH_DOCS_BASE=4a3ad7327411 arch-docs; changelog check", "result": "green", "at": "8d991600778474b887f01b2784b8c72327c8a109" }, "next": "none — ready for review" }