Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Ask cards: the draft card asks only about text it can show

Barack Sokullua09c786bc865
diff --git a/docs/guards.md b/docs/guards.md
index 14c6e4ae8..d22f0fb41 100644
--- a/docs/guards.md
+++ b/docs/guards.md
@@ -104,7 +104,7 @@ When a guard cannot verify a consequential step and its `onCannotDecide` is
|---|---|---|
| `github-commit-evidence-binding` | The file editor was replaced but could not be read back exactly (CodeMirror), and path, branch and commit message bind | The editor's text |
| `github-commit-split-write-required` | A script, Enter or `set_field` submit that may or may not commit, when a commit click would be allowed | The editor's text |
-| `social-publication-draft-quality` | The X/Bluesky draft's body or media does not read back as requested, or the composer could not be read, when the user asked to publish (the publication audit still runs) | The composer's text |
+| `social-publication-draft-quality` | The X/Bluesky draft's text does not read back as requested or could not be read, when the user asked to publish (the publication audit still runs). Media that does not match and a composer that was not read completely still refuse: the card shows only the text | The composer's text |
| `steer-prior-submission-target-unresolved` | After a correction, a submit-capable control the probe could not identify | Nothing (check the page) |
| `clickax-task-click-lock` (hard, Chrome) | An earlier trusted click on the same target may have landed and was never verified | Nothing (check the page) |
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index b9150fc47..b91726c0d 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -23817,21 +23817,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
+ '. Resolve publicationValidation before retrying. For body_mismatch, use the exact contract body; preserve every space and line break. A pending text write must first be verified or restored.'),
publicationValidation: { issues } };
// social-publication-draft-quality (quality) cannot decide when the
- // only issues are the draft's readback: a body or media that does not
- // match the contract, or a body, composer or post baseline it could not
+ // only issues are the draft's text: a body that does not match the
+ // contract or could not be read, or a post baseline it could not
// observe. The user asked to publish here (the contract action is
// eligible), so WebBrain asks on its card, showing the composer's text,
- // instead of refusing. The account, the reply or quote target and the
- // number of posts are not readback: their issues keep the refusal, and
- // the independent publication audit (unrequested_publication) still
- // runs on the observed draft after a 'once'. Strict checks refuse.
- const draftIssues = new Set(['body_mismatch', 'media_mismatch', 'body_unobserved', 'composer_incomplete', 'baseline_incomplete']);
+ // instead of refusing. The card shows only that text, so media that
+ // does not match and a composer that was not read completely keep the
+ // refusal: neither the user nor a timeout could judge them from the
+ // card. The account, the reply or quote target and the number of posts
+ // are not readback either. The independent publication audit
+ // (unrequested_publication) still runs on the observed draft after a
+ // 'once'. Strict checks refuse.
+ const draftIssues = new Set(['body_mismatch', 'body_unobserved', 'baseline_incomplete']);
if (!issues.every(issue => draftIssues.has(issue.reason))
|| this._guardOutcome('social-publication-draft-quality', { decided: false }) !== 'ask') return refusal;
if (!this._unverifiedStepApproval(tabId, 'social-publication-draft-quality', key)) {
const bodies = (Array.isArray(snapshot?.posts) ? snapshot.posts : [])
.map(post => (typeof post?.bodyText === 'string' ? post.bodyText : '')).filter(Boolean);
- const unobserved = issues.some(issue => ['body_unobserved', 'composer_incomplete'].includes(issue.reason)) || !bodies.length;
+ const unobserved = issues.some(issue => issue.reason === 'body_unobserved') || !bodies.length;
return { ...refusal, unverifiedStepConfirmation: { guardId: 'social-publication-draft-quality', hard: false,
action: 'publish', reason: unobserved ? 'draft_unobserved' : 'draft_unverified', host: normalizeHost(pageUrl),
contentLabel: 'composer', text: bodies.join('\n\n'), stepKey: key } };
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 67604faeb..7990efa5a 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -20999,21 +20999,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
+ '. Resolve publicationValidation before retrying. For body_mismatch, use the exact contract body; preserve every space and line break. A pending text write must first be verified or restored.'),
publicationValidation: { issues } };
// social-publication-draft-quality (quality) cannot decide when the
- // only issues are the draft's readback: a body or media that does not
- // match the contract, or a body, composer or post baseline it could not
+ // only issues are the draft's text: a body that does not match the
+ // contract or could not be read, or a post baseline it could not
// observe. The user asked to publish here (the contract action is
// eligible), so WebBrain asks on its card, showing the composer's text,
- // instead of refusing. The account, the reply or quote target and the
- // number of posts are not readback: their issues keep the refusal, and
- // the independent publication audit (unrequested_publication) still
- // runs on the observed draft after a 'once'. Strict checks refuse.
- const draftIssues = new Set(['body_mismatch', 'media_mismatch', 'body_unobserved', 'composer_incomplete', 'baseline_incomplete']);
+ // instead of refusing. The card shows only that text, so media that
+ // does not match and a composer that was not read completely keep the
+ // refusal: neither the user nor a timeout could judge them from the
+ // card. The account, the reply or quote target and the number of posts
+ // are not readback either. The independent publication audit
+ // (unrequested_publication) still runs on the observed draft after a
+ // 'once'. Strict checks refuse.
+ const draftIssues = new Set(['body_mismatch', 'body_unobserved', 'baseline_incomplete']);
if (!issues.every(issue => draftIssues.has(issue.reason))
|| this._guardOutcome('social-publication-draft-quality', { decided: false }) !== 'ask') return refusal;
if (!this._unverifiedStepApproval(tabId, 'social-publication-draft-quality', key)) {
const bodies = (Array.isArray(snapshot?.posts) ? snapshot.posts : [])
.map(post => (typeof post?.bodyText === 'string' ? post.bodyText : '')).filter(Boolean);
- const unobserved = issues.some(issue => ['body_unobserved', 'composer_incomplete'].includes(issue.reason)) || !bodies.length;
+ const unobserved = issues.some(issue => issue.reason === 'body_unobserved') || !bodies.length;
return { ...refusal, unverifiedStepConfirmation: { guardId: 'social-publication-draft-quality', hard: false,
action: 'publish', reason: unobserved ? 'draft_unobserved' : 'draft_unverified', host: normalizeHost(pageUrl),
contentLabel: 'composer', text: bodies.join('\n\n'), stepKey: key } };
diff --git a/test/guard-ask-cards.mjs b/test/guard-ask-cards.mjs
index 51efe7a17..d34a3a6ee 100644
--- a/test/guard-ask-cards.mjs
+++ b/test/guard-ask-cards.mjs
@@ -676,6 +676,33 @@ for (const { build, Agent, adapters, Scheduler } of builds) {
assert.equal(ask.unverifiedStepConfirmation.text, '');
});
+ test(`${build}: media that does not match, or a composer read only in part, keeps the refusal without a card`, async () => {
+ // The card shows only the composer's text. An attachment the request did
+ // not ask for, or a part of the composer that was never read, cannot be
+ // judged from it by the user, let alone by a timeout.
+ const image = [{ type: 'image', src: 'https://pbs.twimg.com/media/unrequested.jpg' }];
+ const check = f => f.agent._workflowPreSubmitDispatchBlock(f.tab, 'click_ax', { ref_id: 'ref_post' }, f.detected, f.provider);
+ const media = socialFixture();
+ media.detected.publicationSnapshot.posts[0].bodyText = 'Hello';
+ media.detected.publicationSnapshot.posts[0].attachments = image;
+ const wrongMedia = await check(media);
+ assert.equal(wrongMedia.noDispatch, true);
+ assert.deepEqual(wrongMedia.publicationValidation.issues.map(issue => issue.reason), ['media_mismatch']);
+ assert.equal(wrongMedia.unverifiedStepConfirmation, undefined, 'the card cannot show the media');
+ const both = socialFixture();
+ both.detected.publicationSnapshot.posts[0].attachments = image;
+ const textAndMedia = await check(both);
+ assert.deepEqual(textAndMedia.publicationValidation.issues.map(issue => issue.reason), ['body_mismatch', 'media_mismatch']);
+ assert.equal(textAndMedia.unverifiedStepConfirmation, undefined, 'a text issue does not open the card for the media');
+ const partial = socialFixture();
+ partial.detected.publicationSnapshot.complete = false;
+ partial.detected.publicationSnapshot.posts[0].bodyText = 'Hello';
+ const incomplete = await check(partial);
+ assert.deepEqual(incomplete.publicationValidation.issues.map(issue => issue.reason), ['composer_incomplete']);
+ assert.equal(incomplete.unverifiedStepConfirmation, undefined, 'a readable body does not vouch for the unread part');
+ for (const f of [media, both, partial]) assert.equal(f.audits.length, 0, 'nothing reached the publication audit');
+ });
+
// ── steer-prior-submission-target-unresolved ───────────────────────────
test(`${build}: after a correction, an unidentified control asks instead of refusing`, async () => {
for (const strict of [false, true]) {