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): require verified delivery for artifact publication requests (#8244)
Mike Bradleycfa23354cc38
diff --git a/.github/workflows/portal-runtime.yml b/.github/workflows/portal-runtime.ymlindex d2b0a5ad4..b1d3730cc 100644--- a/.github/workflows/portal-runtime.yml+++ b/.github/workflows/portal-runtime.yml@@ -67,6 +67,8 @@ jobs:run: node --test ods/extensions/services/pixel-agent/tests/host_workspace_artifact_continuation.test.mjs- name: Verify activity and downloads across native attemptsrun: 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 intent+ run: 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 bounded preview delivery across platformsrun: |node --test ods/extensions/services/pixel-agent/tests/preview_delivery_recovery.test.mjsdiff --git a/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs b/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjsindex 713399a25..b8d4f9383 100644--- a/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs+++ b/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs@@ -4978,6 +4978,29 @@ function ownerRequestsFileHandoff(lane) {});}+// An explicit artifact-tool request is a file handoff even when the owner+// says "re-publish" instead of "download". Keep the verb, object and tool in+// one direct request; publishing a site or quoting an example does not count.+function ownerRequestsArtifactPublication(lane) {+ const clauses=lane.split(/[!?;\n]+|\.(?=\s|$)/).map(value=>value.trim());+ const named=String.raw`["'\x60]?(?:[A-Za-z0-9_.-]+[/\\])*[A-Za-z0-9_.-]+\.(?:md|txt|csv|tsv|json|pdf|zip|rar|docx|xlsx|pptx)["'\x60]?`;+ const object=`(?:(?:the|this|that|my|our|a|an)\\s+)?(?:project|files?|documents?|archives?|bundle|${named})`;+ const request=new RegExp(`^(?:please\\s+)?(?:(?:can|could|would|will)\\s+you\\s+(?:please\\s+)?)?`++ `(?:re-?publish|publish)\\s+(${object})\\s+(?:with|using|via)\\s+(?:the\\s+)?`++ `(?:(?:sourcePath\\s+)?(?:workspace\\s+)?artifact(?:\\s+publication)?|pixel_ods_workspace_artifact)\\s+tool`++ `(?:\\s*,?\\s+and\\s+(?:give|provide|return)\\s+(?:me\\s+)?(?:a\\s+)?(?:concise\\s+)?final\\s+(?:response|answer))?\\s*$`,'i');+ const withdrawal=new RegExp(`^(?:actually,?\\s+)?(?:please\\s+)?(?:do\\s+not|don['’]t|never|must\\s+not|should\\s+not)\\s+`++ `(?:re-?publish|publish|send|attach|deliver)\\s+(anything|it|them|${object})(?:\\s+(?:with|using|via)\\s+.*)?\\s*$`,'i');+ const normalize=value=>value.toLowerCase().replace(/^(?:the|this|that|my|our|a|an)\s+/,'').replace(/["'`]/g,'');+ const refused=clauses.map(clause=>withdrawal.exec(clause)?.[1]).filter(Boolean).map(normalize);+ return clauses.some(clause=>{+ const match=request.exec(clause);+ if(!match)return false;+ const target=normalize(match[1]);+ return !refused.some(value=>['anything','it','them','files','documents','archives'].includes(value)||value===target);+ });+}+// This selects prompt guidance only; it grants no tool or publication authority.export function userMessageRequestsWorkspaceDocumentDelivery(messages, prompt = undefined) {const text = currentOwnerIntentText(messages, prompt);@@ -5018,6 +5041,7 @@ export function userMessageRequestsWorkspaceDocumentDelivery(messages, prompt =// a publication request. Preserve the existing download/attachment phrases// and deliver verb without combining a schedule with a file mention.if (ownerRequestsFileHandoff(lane)) return true;+ if (ownerRequestsArtifactPublication(lane)) return true;return /\b(?:download(?:able)?|attach(?:ment)?|deliver)\b/i.test(positive) &&(/\.(?:md|markdown|txt|csv|tsv|json|pdf|zip|rar|docx|xlsx|pptx)\b/i.test(positive) ||(/\b(?:documents?|files?|archives?|projects?|source\s+(?:code|filenames?))\b/i.test(positive) &&diff --git a/ods/extensions/services/pixel-agent/tests/artifact_publication_intent.test.mjs b/ods/extensions/services/pixel-agent/tests/artifact_publication_intent.test.mjsnew file mode 100644index 000000000..856328fe4--- /dev/null+++ b/ods/extensions/services/pixel-agent/tests/artifact_publication_intent.test.mjs@@ -0,0 +1,50 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import {createToolLoopGuard, userMessageRequestsWorkspaceDocumentDelivery as selectsDelivery} from '../plugin/tool-loop-guard.mjs';++const actual = 'The corrected code and archive layout now pass all 16 supplied tests plus six independent checks. Finish the README cleanup only: the example total is 109.97, not 89.99; remove the duplicate Running Tests section containing python and retain one python3 command. Keep code and tests unchanged. Re-publish the project with the sourcePath artifact tool, and give a concise final response.';+const positives = [actual,+ 'Publish project.zip with the artifact tool.',+ 'Please republish the archive using the workspace artifact tool.',+ 'Could you re-publish report.csv via the artifact publication tool?',+ 'Publish the project with the pixel_ods_workspace_artifact tool.',+ 'Publish new.zip with the artifact tool. Do not republish old.zip.',+];+const negatives = [+ 'The project was already published with the artifact tool.',+ 'How do I publish project.zip with the artifact tool?',+ 'Explain how to republish the project with the sourcePath artifact tool.',+ 'The docs say "Publish project.zip with the artifact tool".',+ '> Publish project.zip with the artifact tool.',+ '```\nPublish project.zip with the artifact tool.\n```',+ 'Do not republish project.zip with the artifact tool.',+ 'Please do not publish project.zip with the artifact tool.',+ 'Do not use tools. Publish project.zip with the artifact tool.',+ 'Publish the website with the artifact tool.',+ 'Publish the blog page with the artifact tool.',+ 'Publish the project to example.com.',+ 'Ask Alice to publish project.zip with the artifact tool.',+ 'Publish new.zip with the artifact tool. Actually, do not republish anything.',+ 'Publish new.zip with the artifact tool. Do not publish new.zip.',+ 'Publish the project with the artifact tool. Never republish the project.',+ 'The sourcePath example is `Publish project.zip with the artifact tool`.',+];+test('direct artifact publication requests select verified file delivery', () => {+ for (const prompt of positives) assert.equal(selectsDelivery([], prompt), true, prompt);+});+test('explanations, quoted requests, withdrawals and website publication do not select file delivery', () => {+ for (const prompt of negatives) assert.equal(selectsDelivery([], prompt), false, prompt);+});+test('the actual no-tool completion claim gets one artifact repair and cannot count as delivered', () => {+ const guard=createToolLoopGuard();+ const context={agentId:'pixel',runId:'publish',sessionId:'session',sessionKey:'agent:pixel:openai-user:ods-'+'d'.repeat(64),trigger:'user'};+ guard.observeRun(context,'pixel',{prompt:actual});+ const event={runId:context.runId,lastAssistantMessage:'README cleaned and ZIP republished.',messages:[{role:'assistant',content:[{type:'text',text:'README cleaned and ZIP republished.'}]}]};+ const revision=guard.beforeAgentFinalize(event,context);+ assert.equal(revision?.retry?.idempotencyKey,'pixel-ods-workspace-document-delivery');+ assert.equal(revision.retry.maxAttempts,1);+ assert.match(revision.retry.instruction,/pixel_ods_workspace_artifact/);+ assert.notEqual(guard.beforeAgentFinalize(event,context)?.retry?.idempotencyKey,revision.retry.idempotencyKey);+ assert.equal(guard.deliveryVerificationForRun('publish').status,'failed');+ assert.equal(guard.deliveryVerificationForRun('publish').artifacts,undefined);+});