ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
fix(pixel): honor per-turn no-tools requests in native runtime (#8250)
Mike Bradley8bc8b542811b
diff --git a/.github/workflows/portal-runtime.yml b/.github/workflows/portal-runtime.ymlindex b1d3730cc..eec32c5ea 100644--- a/.github/workflows/portal-runtime.yml+++ b/.github/workflows/portal-runtime.yml@@ -69,6 +69,8 @@ jobs:run: node --test ods/extensions/services/pixel-agent/tests/attempt_lifecycle.test.mjs ods/extensions/services/pixel-agent/tests/task_activity.test.mjs- name: Verify explicit artifact publication intentrun: node --test ods/extensions/services/pixel-agent/tests/artifact_publication_intent.test.mjs ods/extensions/services/pixel-agent/tests/repeat_document_delivery.test.mjs+ - name: Verify per-turn no-tools policy and installed ingress layout+ run: node --test ods/extensions/services/pixel-agent/tests/ingress_owner_no_tools.test.mjs- name: Verify bounded preview delivery across platformsrun: |node --test ods/extensions/services/pixel-agent/tests/preview_delivery_recovery.test.mjs@@ -208,6 +210,18 @@ jobs:ods/extensions/services/pixel-agent/tests/runtime_stop_synthesis.integration.mjs \ods/extensions/services/pixel-agent/tests/runtime_owner_visible_reply.integration.mjs \ods/extensions/services/pixel-agent/tests/runtime_document_delivery.integration.mjs+ - name: Verify no-tools requests through the real gateway+ if: runner.os != 'Windows'+ shell: bash+ env:+ OPENCLAW_PACKAGE: ${{ runner.temp }}/read-runtime/node_modules/openclaw+ run: |+ set -euo pipefail+ python3 ods/extensions/services/pixel-agent/host/openclaw_tool_recovery.py \+ --openclaw-bin "$OPENCLAW_PACKAGE/openclaw.mjs" --state-dir "$RUNNER_TEMP/pixel-context-usage-repair" --context-usage+ python3 ods/extensions/services/pixel-agent/host/openclaw_tool_recovery.py \+ --openclaw-bin "$OPENCLAW_PACKAGE/openclaw.mjs" --state-dir "$RUNNER_TEMP/pixel-no-tools-ingress-repair" --no-tools-ingress+ node --test ods/extensions/services/pixel-agent/tests/runtime_owner_no_tools.integration.mjsruntime:runs-on: ubuntu-24.04timeout-minutes: 30diff --git a/ods/extensions/services/pixel-agent/host/openclaw-context-usage.json b/ods/extensions/services/pixel-agent/host/openclaw-context-usage.jsonindex 156d933b8..e01b3e1b0 100644--- a/ods/extensions/services/pixel-agent/host/openclaw-context-usage.json+++ b/ods/extensions/services/pixel-agent/host/openclaw-context-usage.json@@ -1,7 +1,7 @@{"version": "2026.6.33","sourceSha256": "06b4bf876c1563df9e4e88c426ec0364257064547fcafa9bc936d923d730f028",- "patchedSha256": "7676b64bf5c63b1d3b025002d1c5aecebb487b9752c3d485e43922361c863b32",+ "patchedSha256": "fafa1a4458a32d89066326b8b67db84174052f28eb13e48b65caba705abfb830","replacements": [["\t\t\tusage: params.result.meta.agentMeta?.usage",@@ -10,7 +10,22 @@["\t\t\tusage: resolveTranscriptUsage(params.assistant.usage),","\t\t\t// Without measured context, keep earlier real usage/size estimation available.\n\t\t\t...params.embeddedAssistantGapFill && !params.assistant.usage ? {} : {usage: resolveTranscriptUsage(params.assistant.usage)},"+ ],+ [+ "\t\tdisableTools: params.opts.modelRun === true,",+ "\t\tdisableTools: params.opts.modelRun === true || params.opts.disableTools === true,"]],- "previousReplacements": {}+ "previousReplacements": {+ "7676b64bf5c63b1d3b025002d1c5aecebb487b9752c3d485e43922361c863b32": [+ [+ "\t\t\tusage: params.result.meta.agentMeta?.usage",+ "\t\t\t// A transcript mirror represents the last model context, not run-wide billing.\n\t\t\tusage: gapFill ? params.result.meta.agentMeta?.lastCallUsage : params.result.meta.agentMeta?.usage"+ ],+ [+ "\t\t\tusage: resolveTranscriptUsage(params.assistant.usage),",+ "\t\t\t// Without measured context, keep earlier real usage/size estimation available.\n\t\t\t...params.embeddedAssistantGapFill && !params.assistant.usage ? {} : {usage: resolveTranscriptUsage(params.assistant.usage)},"+ ]+ ]+ }}diff --git a/ods/extensions/services/pixel-agent/host/openclaw-no-tools-ingress.json b/ods/extensions/services/pixel-agent/host/openclaw-no-tools-ingress.jsonnew file mode 100644index 000000000..6185ae92c--- /dev/null+++ b/ods/extensions/services/pixel-agent/host/openclaw-no-tools-ingress.json@@ -0,0 +1,16 @@+{+ "version": "2026.6.33",+ "sourceSha256": "f7b7e6d9226b06b2fb7ade362e8e521aada00e3f5bf5bf9b78f4c8231f7fc6e9",+ "patchedSha256": "c9e8250a66745bb836972b04e5d2a62f6380d3e1fac5ba2f2ee93e345c24cc96",+ "replacements": [+ [+ "\t\tclientTools: params.clientTools,\n\t\tmodel: params.modelOverride,",+ "\t\tclientTools: params.clientTools,\n\t\tdisableTools: params.disableTools === true,\n\t\tmodel: params.modelOverride,"+ ],+ [+ "\t\tclientTools: resolvedClientTools.length > 0 ? resolvedClientTools : void 0,\n\t\tmodelOverride,",+ "\t\tclientTools: resolvedClientTools.length > 0 ? resolvedClientTools : void 0,\n\t\tdisableTools: payload.tool_choice === \"none\",\n\t\tmodelOverride,"+ ]+ ],+ "previousReplacements": {}+}diff --git a/ods/extensions/services/pixel-agent/host/openclaw_tool_recovery.py b/ods/extensions/services/pixel-agent/host/openclaw_tool_recovery.pyindex 70fb05cad..8e1f9d1a4 100644--- a/ods/extensions/services/pixel-agent/host/openclaw_tool_recovery.py+++ b/ods/extensions/services/pixel-agent/host/openclaw_tool_recovery.py@@ -33,6 +33,7 @@ SUBAGENT_SESSION_MODULE = "agent-Dme3RrGI.js"HOOK_PROVENANCE_MODULE = "hook-agent-context-ugCMMoT5.js"RUN_ID_REDACTION_MODULE = "redact-cvFSPoXf.js"CONTEXT_USAGE_MODULE = "attempt-execution-DnVHak5f.js"+NO_TOOLS_INGRESS_MODULE = "openai-http-DkesJHcp.js"YIELD_USAGE_MODULE = "embedded-agent-CJx-nG3W.js"COMPACTION_EMPTY_MODULE = "proxy-Bsfwfsp-.js"COMPACTION_NO_WORK_MODULE = "compact-DuWIsaq_.js"@@ -136,7 +137,7 @@ def repair(runtime_root, state_dir, *, restore=False, manifest_path=MANIFEST,if module_name not in {MODULE, COMPLETION_MODULE, IMAGE_MODULE, COMPACTION_MODULE, COMPACTION_IDLE_MODULE,COMPACTION_RESUME_MODULE, COMPACTION_BUDGET_MODULE, READ_RANGE_MODULE,TOOL_RESULT_PROJECTION_MODULE, DIAGNOSTIC_STREAM_MODULE, COMMAND_ATTEMPT_MODULE, UTF8_OUTPUT_MODULE, CONTEXT_USAGE_MODULE, YIELD_USAGE_MODULE,- COMPACTION_EMPTY_MODULE, COMPACTION_NO_WORK_MODULE, SUBAGENT_ADMISSION_MODULE, SUBAGENT_SESSION_MODULE, HOOK_PROVENANCE_MODULE, RUN_ID_REDACTION_MODULE, *SANDBOX_MKDIR_MODULES.values()}:+ COMPACTION_EMPTY_MODULE, COMPACTION_NO_WORK_MODULE, SUBAGENT_ADMISSION_MODULE, SUBAGENT_SESSION_MODULE, HOOK_PROVENANCE_MODULE, RUN_ID_REDACTION_MODULE, NO_TOOLS_INGRESS_MODULE, *SANDBOX_MKDIR_MODULES.values()}:raise ValueError("unsupported runtime repair module")manifest = json.loads(manifest_path.read_text(encoding="utf-8"))package = json.loads((runtime_root / "package.json").read_text(encoding="utf-8"))@@ -347,6 +348,7 @@ def main():selection.add_argument("--hook-provenance", action="store_true")selection.add_argument("--run-id-redaction", action="store_true")selection.add_argument("--context-usage", action="store_true")+ selection.add_argument("--no-tools-ingress", action="store_true")selection.add_argument("--yield-usage", action="store_true")selection.add_argument("--compaction-empty", action="store_true")selection.add_argument("--compaction-no-work", action="store_true")@@ -396,6 +398,9 @@ def main():elif args.context_usage:options = {"module_name": CONTEXT_USAGE_MODULE,"manifest_path": MANIFEST.with_name("openclaw-context-usage.json")}+ elif args.no_tools_ingress:+ options = {"module_name": NO_TOOLS_INGRESS_MODULE,+ "manifest_path": MANIFEST.with_name("openclaw-no-tools-ingress.json")}elif args.yield_usage:options = {"module_name": YIELD_USAGE_MODULE,"manifest_path": MANIFEST.with_name("openclaw-yield-usage.json")}diff --git a/ods/extensions/services/pixel-agent/host/owner_tool_policy.mjs b/ods/extensions/services/pixel-agent/host/owner_tool_policy.mjsnew file mode 100644index 000000000..525ff1aec--- /dev/null+++ b/ods/extensions/services/pixel-agent/host/owner_tool_policy.mjs@@ -0,0 +1,32 @@+// Shared owner prose classifier. Extracted unchanged from tool-loop-guard.mjs+// so the host ingress can apply the same unqualified no-tools directive test+// without importing the full guard. This module grants no authority.++export function ownerLaneText(text, {preserveCommands = false} = {}) {+ // Classify only current owner prose. Embedded examples cannot opt a workspace+ // turn into extension work; identifiers quoted as operands remain usable.+ return String(text ?? '')+ .replace(/```[\s\S]*?(?:```|$)|~~~[\s\S]*?(?:~~~|$)/g, ' ')+ .replace(/^\s*>[^\n]*/gm, ' ')+ .replace(/"[^"\n]*"|`[^`\n]*`|(?<!\w)'[^'\n]*'(?!\w)|“[^”\n]*”/g,+ value => preserveCommands && value.startsWith('`') ? value :+ /\s/.test(value.slice(1, -1)) ? ' ' : value);+}++export function ownerForbidsTools(text) {+ const instruction = ownerLaneText(text);+ const ban = /\b(?:(?:do\s+not|don['’]t|never|must\s+not|should\s+not)\s+(?:use|call|invoke|run)|without\s+(?:using|calling|invoking|running))\s+(?:any\s+tools?|(?:the\s+)?tools)\b/gi;+ for (const match of instruction.matchAll(ban)) {+ const prefix = instruction.slice(0, match.index);+ if (!/^without\b/i.test(match[0]) &&+ !/(?:^|[.!?;,\n]\s*|\b(?:and|but|so|then)\s+)(?:please\s+|you\s+)?$/i.test(prefix)) continue;+ const qualifier = instruction.slice(match.index + match[0].length);+ // A ban on a named subset of tools still permits other tools. The+ // blanket boundary applies only to an unqualified no-tools directive.+ if (/^\s+(?:that|which|except|besides|unless|other\s+than)\b/i.test(qualifier) ||+ /^\s+to\s+(?:change|edit|write|modify|delete|create|remove|mutate)\b/i.test(qualifier) ||+ /^\s+for\s+(?:file|writing|editing|modifying|changing|mutation)\b/i.test(qualifier)) continue;+ return true;+ }+ return false;+}diff --git a/ods/extensions/services/pixel-agent/host/pixel_ingress.mjs b/ods/extensions/services/pixel-agent/host/pixel_ingress.mjsindex 62eec58db..9ad17c4e7 100644--- a/ods/extensions/services/pixel-agent/host/pixel_ingress.mjs+++ b/ods/extensions/services/pixel-agent/host/pixel_ingress.mjs@@ -23,6 +23,7 @@ import {createChatHistoryLedger,HistoryError} from './chat_history_ledger.mjs';import {createChatImageStore,createChatImageReadHandler,ChatImageError} from './chat_image_store.mjs';import {currentImageNote,decodeChatImageTurn,nativeHistoryMessages,validateImageRoute} from './chat_image_transport.mjs';import {handleAccessMode, handleModelControl, publicModelControl, readAccessOwnerKey, requestAccessController} from './access_mode_relay.mjs';+import {ownerForbidsTools} from './owner_tool_policy.mjs';// ---------------------------------------------------------------------------// Constants@@ -636,6 +637,16 @@ function readBody(req, limit) {// Allowlisted request construction.// ---------------------------------------------------------------------------+// Latest current user message raw text, restricted to type:text parts. Never+// inspects images, system/assistant/tool messages, or older user turns.+function userTextParts(message) {+ const content = message?.content;+ if (typeof content === 'string') return content;+ if (!Array.isArray(content)) return '';+ return content.filter(part => part?.type === 'text' && typeof part.text === 'string')+ .map(part => part.text).join('\n');+}+export function buildOutgoing(parsed, sessionUser) {const out = { model: "openclaw/default" };for (const key of Object.keys(ALLOWED_FIELDS)) {@@ -647,6 +658,16 @@ export function buildOutgoing(parsed, sessionUser) {out[key] = v;}if (sessionUser) out.user = sessionUser;+ // An explicit owner no-tools directive in the latest current user message+ // forces tool_choice:'none' and tools:[] for this attempt only. This is a+ // restrictive hint for any authenticated gateway client; it grants no+ // authority and is never persisted to history or config. A tool-result+ // continuation (latest message not user) never infers from earlier turns.+ const latest = Array.isArray(parsed.messages) ? parsed.messages[parsed.messages.length - 1] : undefined;+ if (latest && latest.role === 'user' && ownerForbidsTools(userTextParts(latest))) {+ out.tool_choice = 'none';+ out.tools = [];+ }return out;}diff --git a/ods/extensions/services/pixel-agent/plugin/owner-tool-policy.mjs b/ods/extensions/services/pixel-agent/plugin/owner-tool-policy.mjsnew file mode 100644index 000000000..525ff1aec--- /dev/null+++ b/ods/extensions/services/pixel-agent/plugin/owner-tool-policy.mjs@@ -0,0 +1,32 @@+// Shared owner prose classifier. Extracted unchanged from tool-loop-guard.mjs+// so the host ingress can apply the same unqualified no-tools directive test+// without importing the full guard. This module grants no authority.++export function ownerLaneText(text, {preserveCommands = false} = {}) {+ // Classify only current owner prose. Embedded examples cannot opt a workspace+ // turn into extension work; identifiers quoted as operands remain usable.+ return String(text ?? '')+ .replace(/```[\s\S]*?(?:```|$)|~~~[\s\S]*?(?:~~~|$)/g, ' ')+ .replace(/^\s*>[^\n]*/gm, ' ')+ .replace(/"[^"\n]*"|`[^`\n]*`|(?<!\w)'[^'\n]*'(?!\w)|“[^”\n]*”/g,+ value => preserveCommands && value.startsWith('`') ? value :+ /\s/.test(value.slice(1, -1)) ? ' ' : value);+}++export function ownerForbidsTools(text) {+ const instruction = ownerLaneText(text);+ const ban = /\b(?:(?:do\s+not|don['’]t|never|must\s+not|should\s+not)\s+(?:use|call|invoke|run)|without\s+(?:using|calling|invoking|running))\s+(?:any\s+tools?|(?:the\s+)?tools)\b/gi;+ for (const match of instruction.matchAll(ban)) {+ const prefix = instruction.slice(0, match.index);+ if (!/^without\b/i.test(match[0]) &&+ !/(?:^|[.!?;,\n]\s*|\b(?:and|but|so|then)\s+)(?:please\s+|you\s+)?$/i.test(prefix)) continue;+ const qualifier = instruction.slice(match.index + match[0].length);+ // A ban on a named subset of tools still permits other tools. The+ // blanket boundary applies only to an unqualified no-tools directive.+ if (/^\s+(?:that|which|except|besides|unless|other\s+than)\b/i.test(qualifier) ||+ /^\s+to\s+(?:change|edit|write|modify|delete|create|remove|mutate)\b/i.test(qualifier) ||+ /^\s+for\s+(?:file|writing|editing|modifying|changing|mutation)\b/i.test(qualifier)) continue;+ return true;+ }+ return false;+}diff --git a/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs b/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjsindex b8d4f9383..f697bcbef 100644--- a/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs+++ b/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs@@ -1,3 +1,4 @@+import {ownerLaneText, ownerForbidsTools} from './owner-tool-policy.mjs';import {validDeliveredArtifact, normalizeWorkspaceArtifact, WORKSPACE_ARTIFACT_DELIVERY_GUIDANCE} from './workspace-artifact.mjs';// Pixel per-run tool-loop guard.//@@ -5048,34 +5049,7 @@ export function userMessageRequestsWorkspaceDocumentDelivery(messages, prompt =!/\b(?:images?|photos?|audio|video|websites?|webpages?|html)\b|\.(?:png|jpe?g|gif|svg|mp3|mp4|wav|webm|html?)\b/i.test(positive)));}-function ownerLaneText(text, {preserveCommands = false} = {}) {- // Classify only current owner prose. Embedded examples cannot opt a workspace- // turn into extension work; identifiers quoted as operands remain usable.- return String(text ?? '')- .replace(/```[\s\S]*?(?:```|$)|~~~[\s\S]*?(?:~~~|$)/g, ' ')- .replace(/^\s*>[^\n]*/gm, ' ')- .replace(/"[^"\n]*"|`[^`\n]*`|(?<!\w)'[^'\n]*'(?!\w)|“[^”\n]*”/g,- value => preserveCommands && value.startsWith('`') ? value :- /\s/.test(value.slice(1, -1)) ? ' ' : value);-}--function ownerForbidsTools(text) {- const instruction = ownerLaneText(text);- const ban = /\b(?:(?:do\s+not|don['’]t|never|must\s+not|should\s+not)\s+(?:use|call|invoke|run)|without\s+(?:using|calling|invoking|running))\s+(?:any\s+tools?|(?:the\s+)?tools)\b/gi;- for (const match of instruction.matchAll(ban)) {- const prefix = instruction.slice(0, match.index);- if (!/^without\b/i.test(match[0]) &&- !/(?:^|[.!?;,\n]\s*|\b(?:and|but|so|then)\s+)(?:please\s+|you\s+)?$/i.test(prefix)) continue;- const qualifier = instruction.slice(match.index + match[0].length);- // A ban on a named subset of tools still permits other tools. The- // blanket boundary applies only to an unqualified no-tools directive.- if (/^\s+(?:that|which|except|besides|unless|other\s+than)\b/i.test(qualifier) ||- /^\s+to\s+(?:change|edit|write|modify|delete|create|remove|mutate)\b/i.test(qualifier) ||- /^\s+for\s+(?:file|writing|editing|modifying|changing|mutation)\b/i.test(qualifier)) continue;- return true;- }- return false;-}+// Must match CURRENT_IMAGE_NOTE in host/chat_image_transport.mjs, which the// trusted ingress appends after an image turn's pixels and delivery guidance.diff --git a/ods/extensions/services/pixel-agent/tests/ingress_owner_no_tools.test.mjs b/ods/extensions/services/pixel-agent/tests/ingress_owner_no_tools.test.mjsnew file mode 100644index 000000000..bb527f08c--- /dev/null+++ b/ods/extensions/services/pixel-agent/tests/ingress_owner_no_tools.test.mjs@@ -0,0 +1,132 @@+// Owner no-tools directive: buildOutgoing must force tool_choice:'none' and+// tools:[] only for an unqualified directive in the latest current user+// message, and the guard's existing no-tool behavior must remain unchanged.+import test from 'node:test';+import assert from 'node:assert/strict';+import {mkdtempSync, readFileSync, copyFileSync, rmSync} from 'node:fs';+import {tmpdir} from 'node:os';+import {join, basename} from 'node:path';+import {pathToFileURL} from 'node:url';+import {buildOutgoing} from '../host/pixel_ingress.mjs';+import {createToolLoopGuard} from '../plugin/tool-loop-guard.mjs';++const u = (content) => ({role: 'user', content});+const a = (content) => ({role: 'assistant', content});+const tools = [{type: 'function', function: {name: 'exec'}}];++function outgoing(messages, extra = {}) {+ return buildOutgoing({messages, tools, tool_choice: 'auto', ...extra}, 'ods-' + 'a'.repeat(64));+}++const REAL_PROMPT = 'Without using tools, suggest three simple vegetarian lunches using chickpeas, rice, and tomatoes. Keep it under 80 words.';++test('the separately deployed host and plugin policy copies stay identical', () => {+ assert.equal(readFileSync(new URL('../host/owner_tool_policy.mjs',import.meta.url),'utf8'),+ readFileSync(new URL('../plugin/owner-tool-policy.mjs',import.meta.url),'utf8'));+});++test('the Linux installer layout imports and applies the no-tools policy', async () => {+ const root=mkdtempSync(join(tmpdir(),'ods-ingress-layout-'));+ try {+ const script=readFileSync(new URL('../../../../installers/lib/pixel-host-install.sh',import.meta.url),'utf8');+ const declared=[...script.matchAll(/ods_sudo install[^\n]*"\$plugin_root\/host\/([^"/]+\.mjs)" \/usr\/local\/libexec\/([^\s/]+\.mjs)/g)];+ assert.ok(declared.some(([,source])=>source==='owner_tool_policy.mjs'));+ for(const [,source,target] of declared){+ assert.equal(source,basename(source)); assert.equal(target,basename(target));+ copyFileSync(new URL('../host/'+source,import.meta.url),join(root,target));+ }+ const installed=await import(pathToFileURL(join(root,'ods-pixel-ingress.mjs')).href);+ const out=installed.buildOutgoing({messages:[u(REAL_PROMPT)]},null);+ assert.equal(out.tool_choice,'none'); assert.deepEqual(out.tools,[]);+ } finally {rmSync(root,{recursive:true,force:true});}+});++test('exact real Portal prompt forces tool_choice:none and tools:[]', () => {+ const out = outgoing([u(REAL_PROMPT)]);+ assert.equal(out.tool_choice, 'none');+ assert.deepEqual(out.tools, []);+ assert.equal(out.user, 'ods-' + 'a'.repeat(64));+ assert.equal(out.model, 'openclaw/default');+});++test('text content parts are joined; image parts are ignored', () => {+ const out = outgoing([{role: 'user', content: [+ {type: 'text', text: 'Do not use any tools.'},+ {type: 'image_url', image_url: {url: 'data:image/png;base64,AAAA'}},+ ]}]);+ assert.equal(out.tool_choice, 'none');+ assert.deepEqual(out.tools, []);+});++test('an image-only latest user message does not trigger the directive', () => {+ const out = outgoing([{role: 'user', content: [+ {type: 'image_url', image_url: {url: 'data:image/png;base64,AAAA'}},+ ]}]);+ assert.equal(out.tool_choice, 'auto');+ assert.deepEqual(out.tools, tools);+});++test('quoted, fenced, and discussed no-tools text does not trigger', () => {+ for (const text of [+ 'The user said "do not use any tools" earlier.',+ 'Explain what `do not use any tools` means.',+ '```\nDo not use any tools.\n```',+ '> Do not use any tools.',+ ]) {+ const out = outgoing([u(text)]);+ assert.equal(out.tool_choice, 'auto', text);+ assert.deepEqual(out.tools, tools, text);+ }+});++test('qualified no-tools directives do not trigger', () => {+ for (const text of [+ 'Do not use any tools that modify files.',+ 'Do not use any tools to change the workspace.',+ 'Do not use any tools for file writing.',+ 'Do not use any tools except read.',+ ]) {+ const out = outgoing([u(text)]);+ assert.equal(out.tool_choice, 'auto', text);+ assert.deepEqual(out.tools, tools, text);+ }+});++test('an older user no-tools directive does not affect a new user turn', () => {+ const out = outgoing([+ u('Do not use any tools.'),+ a('Understood.'),+ u('Now run the tests.'),+ ]);+ assert.equal(out.tool_choice, 'auto');+ assert.deepEqual(out.tools, tools);+});++test('a tool-result continuation does not infer from an earlier user directive', () => {+ const out = outgoing([+ u('Do not use any tools.'),+ a(''),+ {role: 'tool', tool_call_id: 'call-1', content: 'result'},+ ]);+ assert.equal(out.tool_choice, 'auto');+ assert.deepEqual(out.tools, tools);+});++test('an explicit API tool_choice:none is forwarded unchanged when no directive is present', () => {+ const out = buildOutgoing({messages: [u('Summarize.')], tools, tool_choice: 'none'}, null);+ assert.equal(out.tool_choice, 'none');+ assert.deepEqual(out.tools, tools);+});++test('validation still runs before the policy override', () => {+ assert.throws(() => buildOutgoing({messages: 'nope'}, null), /invalid/);+ assert.throws(() => buildOutgoing({messages: [u('Do not use any tools.')], tools: 'nope'}, null), /invalid/);+});++test('guard still blocks tools after an owner no-tools directive', () => {+ const guard = createToolLoopGuard();+ const context = {trigger: 'user', sessionKey: 'agent:pixel:openai-user:ods-' + 'a'.repeat(64), agentId: 'pixel', runId: 'chatcmpl_11111111-2222-4333-8444-555555555555', sessionId: 'no-tools' };+ guard.observeRun(context, 'pixel', {prompt: 'Do not use any tools. Summarize.'});+ const blocked = guard.beforeToolCall({toolName: 'exec', params: {command: 'echo hi'}}, {...context, toolCallId: 'call-1'});+ assert.equal(blocked?.block, true);+});diff --git a/ods/extensions/services/pixel-agent/tests/runtime_owner_no_tools.integration.mjs b/ods/extensions/services/pixel-agent/tests/runtime_owner_no_tools.integration.mjsnew file mode 100644index 000000000..72d5fad4b--- /dev/null+++ b/ods/extensions/services/pixel-agent/tests/runtime_owner_no_tools.integration.mjs@@ -0,0 +1,112 @@+// Real pinned harness + real ingress, deterministic model, disposable state.+// An explicit no-tools turn must reach the provider with no callable tools;+// the next normal turn in the same session must regain them; an explicit+// tool_choice:none must suppress tools even when a client function is offered.+import test from 'node:test';+import assert from 'node:assert/strict';+import {createServer} from 'node:http';+import {once} from 'node:events';+import {spawn} from 'node:child_process';+import {mkdtempSync,mkdirSync,writeFileSync,cpSync,symlinkSync,rmSync} from 'node:fs';+import {tmpdir} from 'node:os';+import {join} from 'node:path';+import {setTimeout as delay} from 'node:timers/promises';+import {createIngressServer} from '../host/pixel_ingress.mjs';+const pkg=process.env.OPENCLAW_PACKAGE;+const LUNCH='Without using tools, suggest three simple vegetarian lunches using chickpeas, rice, and tomatoes. Keep it under 80 words.';+const NORMAL='Now list the tools you have available, one per line.';+const TOOL_OFFER={type:'function',function:{name:'fixture_echo',description:'Echo text.',parameters:{type:'object',properties:{text:{type:'string'}},required:['text']}}};++function sse(res,delta,finish){res.write('data: '+JSON.stringify({id:'fixture',object:'chat.completion.chunk',choices:[{index:0,delta,finish_reason:finish??null}]})+'\n\n');}++for (const mode of ['lunch-then-normal','explicit-none']) test(`real harness no-tools ingress: ${mode}`,+ {skip:!pkg,timeout:90000}, async () => {+ const root=mkdtempSync(join(tmpdir(),'ods-no-tools-'));+ let log='',child,ingress;+ const requests=[];+ const upstream=createServer(async(req,res)=>{+ const chunks=[];for await(const chunk of req) chunks.push(chunk);+ const parsed=JSON.parse(Buffer.concat(chunks).toString());+ requests.push({tools:parsed.tools??null,tool_choice:parsed.tool_choice??null});+ res.writeHead(200,{'Content-Type':'text/event-stream'});+ sse(res,{role:'assistant',content:'Chickpea rice bowl; tomato chickpea stew; rice salad with chickpeas and tomatoes.'});+ sse(res,{},'stop');+ res.end('data: [DONE]\n\n');+ });+ await new Promise(resolve=>upstream.listen(0,'127.0.0.1',resolve));+ const probe=createServer();await new Promise(resolve=>probe.listen(0,'127.0.0.1',resolve));+ const port=probe.address().port;await new Promise(resolve=>probe.close(resolve));+ mkdirSync(join(root,'node_modules'));symlinkSync(pkg,join(root,'node_modules','openclaw'));+ const plugin=join(root,'plugin');mkdirSync(plugin);+ cpSync(new URL('../plugin/',import.meta.url),join(plugin,'ods'),{recursive:true});+ writeFileSync(join(plugin,'package.json'),JSON.stringify({name:'no-tools-fixture',version:'1.0.0',type:'module',openclaw:{extensions:['./index.mjs']}}));+ writeFileSync(join(plugin,'openclaw.plugin.json'),JSON.stringify({id:'no-tools-fixture',activation:{onStartup:true},configSchema:{type:'object',properties:{}}}));+ writeFileSync(join(plugin,'index.mjs'),`+ import {createToolLoopGuard} from './ods/tool-loop-guard.mjs';+ const guard=createToolLoopGuard({abortRun:()=>false});+ export default {id:'no-tools-fixture',register(api){+ api.registerHttpRoute({path:'/pixel-ods/subagent-delivery',auth:'gateway',match:'exact',handler:async(req,res)=>{+ let body='';for await(const part of req)body+=part;+ res.writeHead(200,{'Content-Type':'application/json'});+ res.end(JSON.stringify({schemaVersion:1,kind:'ods-subagent-delivery',runId:JSON.parse(body).runId,status:'not-delegated'}));return true;+ }});+ api.registerHttpRoute({path:'/pixel-ods/verification',auth:'gateway',match:'exact',handler:async(req,res)=>{+ let body='';for await(const part of req)body+=part;+ res.writeHead(200,{'Content-Type':'application/json'});+ res.end(JSON.stringify(guard.deliveryVerificationForRun(JSON.parse(body).runId)));return true;+ }});+ api.on('before_prompt_build',(e,c)=>guard.observeRun(c,'pixel',e));+ api.on('model_call_started',(e,c)=>guard.observeModelCall(e,c));+ api.on('model_call_ended',(e,c)=>guard.observeModelEnd(e,c));+ api.on('before_agent_finalize',(e,c)=>guard.beforeAgentFinalize(e,c));+ api.on('reply_payload_sending',e=>guard.replyPayloadSending(e));+ }};+ `);+ const config={logging:{file:join(root,'runtime.log')},update:{checkOnStart:false},+ gateway:{mode:'local',bind:'loopback',port,auth:{mode:'token',token:'fixture-only'},http:{endpoints:{chatCompletions:{enabled:true}}}},+ agents:{defaults:{workspace:join(root,'workspace'),skipBootstrap:true,model:{primary:'fixture/test'},contextTokens:32768,heartbeat:{every:'0m'}},+ list:[{id:'pixel',default:true}]},+ models:{mode:'replace',providers:{fixture:{baseUrl:`http://127.0.0.1:${upstream.address().port}/v1`,api:'openai-completions',apiKey:'fixture-only',+ models:[{id:'test',name:'Fixture',contextWindow:32768,maxTokens:4096,reasoning:false,input:['text']}]}}},+ plugins:{allow:['no-tools-fixture'],load:{paths:[plugin]},entries:{'no-tools-fixture':{enabled:true,hooks:{allowConversationAccess:true}}}}};+ writeFileSync(join(root,'openclaw.json'),JSON.stringify(config));+ try {+ child=spawn(process.execPath,[join(pkg,'openclaw.mjs'),'gateway','run'],{cwd:root,detached:true,+ env:{PATH:process.env.PATH,HOME:root,TMPDIR:root,OPENCLAW_STATE_DIR:join(root,'state'),OPENCLAW_CONFIG_PATH:join(root,'openclaw.json'),OPENCLAW_SKIP_CHANNELS:'1'},+ stdio:['ignore','pipe','pipe']});+ child.stdout.on('data',x=>log+=x);child.stderr.on('data',x=>log+=x);+ let ready=false;+ for(let n=0;n<250;n++){+ try{ready=(await fetch(`http://127.0.0.1:${port}/health`,{signal:AbortSignal.timeout(500)})).ok;}catch{}+ if(ready)break;assert.equal(child.exitCode,null,log);await delay(100);+ }+ assert.ok(ready,log);+ ingress=createIngressServer({token:'fixture-only',gatewayPort:port});+ await new Promise(resolve=>ingress.listen(0,'127.0.0.1',resolve));+ const send=async body=>{+ const response=await fetch(`http://127.0.0.1:${ingress.address().port}/v1/chat/completions`,{method:'POST',+ headers:{'Content-Type':'application/json'},body:JSON.stringify(body),signal:AbortSignal.timeout(45000)});+ const text=await response.text();+ assert.equal(response.status,200,text+'\n'+log);+ assert.ok(text.includes('Chickpea rice bowl'),text);+ assert.ok(!text.includes('\"status\":\"failed\"'),text);+ return text;+ };+ if(mode==='lunch-then-normal'){+ await send({model:'openclaw:pixel',stream:true,user:'no-tools-fixture',messages:[{role:'user',content:LUNCH}]});+ await send({model:'openclaw:pixel',stream:true,user:'no-tools-fixture',messages:[{role:'user',content:NORMAL}]});+ assert.equal(requests.length,2,'two provider turns\n'+log);+ assert.equal(requests[0].tools?.length??0,0,'no-tools turn must reach provider with no callable tools\n'+JSON.stringify(requests));+ assert.ok(Array.isArray(requests[1].tools)&&requests[1].tools.length>0,'normal turn must regain tools\n'+JSON.stringify(requests));+ } else {+ await send({model:'openclaw:pixel',stream:true,user:'no-tools-fixture',tools:[TOOL_OFFER],tool_choice:'none',messages:[{role:'user',content:'Suggest three vegetarian lunches.'}]});+ assert.equal(requests.length,1,'one provider turn\n'+log);+ assert.equal(requests[0].tools?.length??0,0,'explicit tool_choice:none must suppress offered tools\n'+JSON.stringify(requests));+ }+ } finally {+ if(ingress){ingress.closeAllConnections();await new Promise(resolve=>ingress.close(resolve));}+ if(child&&child.exitCode===null){const closed=once(child,'close');process.kill(-child.pid,'SIGTERM');+ await Promise.race([closed,delay(3000)]);if(child.exitCode===null){process.kill(-child.pid,'SIGKILL');await closed;}}+ upstream.closeAllConnections();await new Promise(resolve=>upstream.close(resolve));rmSync(root,{recursive:true,force:true});+ }+});diff --git a/ods/extensions/services/pixel-agent/tests/test_openclaw_tool_recovery.py b/ods/extensions/services/pixel-agent/tests/test_openclaw_tool_recovery.pyindex 888b0ca00..f6dce5a45 100644--- a/ods/extensions/services/pixel-agent/tests/test_openclaw_tool_recovery.py+++ b/ods/extensions/services/pixel-agent/tests/test_openclaw_tool_recovery.py@@ -49,6 +49,7 @@ def run(installation, **kwargs):repair_module.TOOL_RESULT_PROJECTION_MODULE,repair_module.DIAGNOSTIC_STREAM_MODULE,repair_module.UTF8_OUTPUT_MODULE,+ repair_module.NO_TOOLS_INGRESS_MODULE,*repair_module.SANDBOX_MKDIR_MODULES.values()])def test_additional_module_has_separate_exact_byte_custody(installation, module_name):runtime, state, manifest, module, original, patched = installation@@ -510,6 +511,7 @@ def test_unchanged_compaction_repair_checks_its_dependency(compaction_installati('OPENCLAW_HOOK_CONTEXT_MODULE', 'openclaw-hook-provenance.json', repair_module.HOOK_PROVENANCE_MODULE),('OPENCLAW_REDACT_MODULE', 'openclaw-run-id-redaction.json', repair_module.RUN_ID_REDACTION_MODULE),('OPENCLAW_ATTEMPT_EXECUTION_MODULE', 'openclaw-context-usage.json', repair_module.CONTEXT_USAGE_MODULE),+ ('OPENCLAW_OPENAI_HTTP_MODULE', 'openclaw-no-tools-ingress.json', repair_module.NO_TOOLS_INGRESS_MODULE),('OPENCLAW_EMBEDDED_AGENT_MODULE', 'openclaw-yield-usage.json', repair_module.YIELD_USAGE_MODULE),('OPENCLAW_CORE_PROXY_MODULE', 'openclaw-compaction-empty.json', repair_module.COMPACTION_EMPTY_MODULE),('OPENCLAW_COMPACT_MODULE', 'openclaw-compaction-no-work.json', repair_module.COMPACTION_NO_WORK_MODULE),diff --git a/ods/installers/lib/pixel-host-install.sh b/ods/installers/lib/pixel-host-install.shindex fe375e1f2..d4b0e0266 100644--- a/ods/installers/lib/pixel-host-install.sh+++ b/ods/installers/lib/pixel-host-install.sh@@ -5136,6 +5136,7 @@ EOFods_sudo install -o root -g root -m 0644 "$plugin_root/host/access_mode_relay.mjs" /usr/local/libexec/access_mode_relay.mjsods_sudo install -o root -g root -m 0644 "$plugin_root/host/task_activity_schema.mjs" /usr/local/libexec/task_activity_schema.mjsods_sudo install -o root -g root -m 0644 "$plugin_root/host/questions_schema.mjs" /usr/local/libexec/questions_schema.mjs+ ods_sudo install -o root -g root -m 0644 "$plugin_root/host/owner_tool_policy.mjs" /usr/local/libexec/owner_tool_policy.mjsods_sudo install -o root -g ods-pixel -m 0640 "$stage/pixel-agent.env" /etc/ods/pixel-agent.envods_sudo install -o root -g root -m 0644 "$stage/pixel-ingress.service" /etc/systemd/system/pixel-ingress.serviceods_sudo install -o root -g root -m 0644 "$rendered_extension_manager_unit" \@@ -5458,6 +5459,7 @@ ods_pixel_install_default_agent() {&& -f "$plugin_root/host/access_mode_relay.mjs" \&& -f "$plugin_root/host/task_activity_schema.mjs" \&& -f "$plugin_root/host/questions_schema.mjs" \+ && -f "$plugin_root/host/owner_tool_policy.mjs" \&& -f "$plugin_root/host/extension_search.py" \&& -f "$plugin_root/host/extension_manager.py" \&& -f "$plugin_root/host/pixel-extension-manager.service" \@@ -5489,6 +5491,7 @@ ods_pixel_install_default_agent() {&& -f "$plugin_root/host/openclaw-utf8-output.json" \&& -f "$plugin_root/host/openclaw-image-envelope.json" \&& -f "$plugin_root/host/openclaw-context-usage.json" \+ && -f "$plugin_root/host/openclaw-no-tools-ingress.json" \&& -f "$plugin_root/host/openclaw-yield-usage.json" \&& -f "$plugin_root/host/openclaw-compaction-empty.json" \&& -f "$plugin_root/host/openclaw-compaction-no-work.json" \@@ -5936,7 +5939,7 @@ ods_pixel_install_default_agent() {--restore-foreign "$home/.openclaw/ods-runtime-patches" \--known tool-recovery completion-recovery image-envelope compaction-export \compaction-idle compaction-resume read-range tool-result-projection \- diagnostic-stream-writes command-attempt-warning utf8-output compaction-budget context-usage yield-usage compaction-empty compaction-no-work subagent-admission subagent-session hook-provenance run-id-redaction sandbox-mkdir-bridge sandbox-mkdir-secure \+ diagnostic-stream-writes command-attempt-warning utf8-output compaction-budget context-usage no-tools-ingress yield-usage compaction-empty compaction-no-work subagent-admission subagent-session hook-provenance run-id-redaction sandbox-mkdir-bridge sandbox-mkdir-secure \>>"$pixel_log" 2>&1; thenai_bad "Pixel could not restore OpenClaw runtime patches left by another ODS build. See $pixel_log."return 1@@ -6124,6 +6127,16 @@ ods_pixel_install_default_agent() {ai_bad "Pixel's context-usage repair could not verify its package bytes. See $pixel_log."return 1fi+ # An explicit no-tools turn must reach the provider with no callable tools+ # while the next normal turn in the same session regains them.+ if ! ods_pixel_run_as_owner "$owner" "$home" python3 \+ "$plugin_root/host/openclaw_tool_recovery.py" \+ --openclaw-bin "$openclaw_bin" --no-tools-ingress \+ --state-dir "$home/.openclaw/ods-runtime-patches/no-tools-ingress" \+ >>"$pixel_log" 2>&1; then+ ai_bad "Pixel's no-tools ingress repair could not verify its package bytes. See $pixel_log."+ return 1+ fiif ! ods_pixel_run_as_owner "$owner" "$home" python3 \"$plugin_root/host/openclaw_tool_recovery.py" \--openclaw-bin "$openclaw_bin" --yield-usage \diff --git a/ods/installers/macos/lib/pixel-runtime-bundle.py b/ods/installers/macos/lib/pixel-runtime-bundle.pyindex 69a89e459..a65861984 100644--- a/ods/installers/macos/lib/pixel-runtime-bundle.py+++ b/ods/installers/macos/lib/pixel-runtime-bundle.py@@ -69,6 +69,7 @@ SHARED_REPAIRS = (('openclaw-hook-provenance.json', 'hook-agent-context-ugCMMoT5.js'),('openclaw-run-id-redaction.json', 'redact-cvFSPoXf.js'),('openclaw-context-usage.json', 'attempt-execution-DnVHak5f.js'),+ ('openclaw-no-tools-ingress.json', 'openai-http-DkesJHcp.js'),('openclaw-yield-usage.json', 'embedded-agent-CJx-nG3W.js'),('openclaw-compaction-empty.json', 'proxy-Bsfwfsp-.js'),('openclaw-compaction-no-work.json', 'compact-DuWIsaq_.js'),diff --git a/ods/tests/test-pixel-host-install.sh b/ods/tests/test-pixel-host-install.shindex e4cc0464b..dd5ce2ab2 100644--- a/ods/tests/test-pixel-host-install.sh+++ b/ods/tests/test-pixel-host-install.sh@@ -3519,7 +3519,8 @@ assert "--state-dir \"$home/.openclaw/ods-runtime-patches/sandbox-mkdir-$mkdir_mmanaged.extend(["sandbox-mkdir-bridge", "sandbox-mkdir-secure"])known = installer[foreign_restore:own_repair].split("--known", 1)[1].split(">>", 1)[0]assert sorted(known.replace("\\", " ").split()) == sorted(managed)-assert len(set(managed)) == len(managed) == 22+assert len(set(managed)) == len(managed) == 23+assert "no-tools-ingress" in managedassert {"context-usage", "yield-usage", "compaction-empty", "compaction-no-work", "subagent-admission", "hook-provenance", "run-id-redaction"}.issubset(managed)assert "utf8-output" in managedassert "--utf8-output" in installerdiff --git a/ods/tests/test_macos_pixel_runtime_bundle.py b/ods/tests/test_macos_pixel_runtime_bundle.pyindex f0d4a222b..cebf88bc5 100644--- a/ods/tests/test_macos_pixel_runtime_bundle.py+++ b/ods/tests/test_macos_pixel_runtime_bundle.py@@ -180,9 +180,9 @@ def test_shared_repairs_compose_deterministically_only_in_staging(artifacts, shamanifest, _ = bundle.verify(root, expected_digest=digest)repairs = json.loads((root / 'ods-runtime-repairs.json').read_bytes())stream = json.loads((root / 'ods-runtime-patches.json').read_bytes())[0]- assert len(repairs) == 22+ assert len(repairs) == 23assert {item["manifest"] for item in repairs}.issuperset({- "openclaw-context-usage.json", "openclaw-yield-usage.json", "openclaw-compaction-empty.json", "openclaw-compaction-no-work.json", "openclaw-hook-provenance.json", "openclaw-run-id-redaction.json", "openclaw-subagent-admission.json"})+ "openclaw-context-usage.json", "openclaw-no-tools-ingress.json", "openclaw-yield-usage.json", "openclaw-compaction-empty.json", "openclaw-compaction-no-work.json", "openclaw-hook-provenance.json", "openclaw-run-id-redaction.json", "openclaw-subagent-admission.json"})assert any(item['module'] == 'windows-command-C7mWWxtt.js'and item['manifest'] == 'openclaw-utf8-output.json' for item in repairs)assert any(item['module'] == 'payloads-CC0zlj7W.js'