Skip to content

fix(agents): escape terminal controls in creation summaries - #183360

Merged
steipete merged 4 commits into
openclaw:mainfrom
Alix-007:alix/fix-agents-terminal-controls-20261025
Oct 26, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
Alix-007:alix/fix-agents-terminal-controls-20261025

Conversation

@Alix-007

@Alix-007 Alix-007 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes terminal actions and forged summary rows caused by control characters in agent workspace paths, model labels, routing conflicts, and team creation notes.

User Impact

Human creation summaries show readable escaped text. Saved workspaces, configuration, and JSON retain their original values.

Why This Change Was Made

Apply the existing sanitizeTerminalText policy only at human display boundaries. Reuse already-formatted conflict descriptions for the non-interactive summary; keep the shared formatter raw because JSON also consumes it. Thanks @Alix-007 for the fix and regression coverage.

Evidence

Integrated head: 8c279c04e809f238e3e0411bdd3d2458a486dc1e; contributor commits are preserved. After merging main d9eeeb976a20, the affected files remained byte-identical and all 36 tests passed again (wrapper 169.96s; Vitest 147.58s). Exact-head CI run 40246936667 is green. The repository CI watcher reports GREEN; GitHub’s aggregate still includes ten superseded checks. GitHub mergeability may lag while main advances; local merge-tree verification is recorded in the handoff. ClawSweeper’s final-head review found no code findings.

  • On main 6d808362dd8a, the focused regression run fails on all three human-output cases while both JSON cases pass (3 failed, 2 passed; wrapper 179.32s). With the fix, all 36 tests in agents.add.test.ts and agents.roles.test.ts pass (wrapper 348.92s; Vitest 330.57s). Native worker compilation and real team creation dominate runtime; these tests cover actual directory/config preservation as well as display output.
  • Targeted type-aware oxlint, oxfmt, and git diff --check pass. Independent Codex autoreview is scoped-clean at P0–P2. Supplemental check-changed passed conflict, line-cap, max-lines, assertion, and SQLite worker checks; it was stopped during the unrelated SQLite dialect scan, so that supplemental command is incomplete.
  • Production +13/−7 (+6), tests +99, docs +4. Reusing the payload's conflict descriptions removes duplicate formatting; remaining growth applies the canonical sanitizer at distinct human output boundaries without changing shared raw formatters.

Not live-tested independently on the integrated head: a fresh built CLI would add build/setup work on the shared host. Contributor Linux CLI traces below are retained at the original head: agent and team summaries lose controls while configuration and created directories retain their original names. These are prior-head results.

Contributor CLI proof retained from original head cfac4f3 (prior-head evidence)

JSON escaping makes control bytes inspectable without executing them. Temporary roots are replaced with $FIXTURE.

{
  "phase": "red",
  "head": "e8b251188f502b088dd037936062a1711ea302e1",
  "at": "2026-10-25T06:06:00.407Z",
  "runs": [
    {
      "label": "create",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "add",
        "proof",
        "--non-interactive",
        "--workspace",
        "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007"
      ],
      "code": 0,
      "signal": null,
      "stdout": "Updated config: $FIXTURE/openclaw.json\n  Backup: $FIXTURE/openclaw.json.bak\nAgent: proof\nWorkspace: $FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007\nAgent dir: $FIXTURE/state/agents/proof/agent\n",
      "stderr": "",
      "seconds": 11.386979862
    },
    {
      "label": "list",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "list",
        "--json"
      ],
      "code": 0,
      "signal": null,
      "stdout": "[\n  {\n    \"id\": \"main\",\n    \"workspace\": \"$FIXTURE/workspace\",\n    \"agentDir\": \"$FIXTURE/state/agents/main/agent\",\n    \"bindings\": 0,\n    \"isDefault\": true\n  },\n  {\n    \"id\": \"proof\",\n    \"name\": \"proof\",\n    \"identityName\": \"proof\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007\",\n    \"agentDir\": \"$FIXTURE/state/agents/proof/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792908371538\n  }\n]\n",
      "stderr": "",
      "seconds": 7.294184885999999
    },
    {
      "label": "ordinary",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "add",
        "ordinary",
        "--non-interactive",
        "--workspace",
        "$FIXTURE/ordinary",
        "--json"
      ],
      "code": 0,
      "signal": null,
      "stdout": "{\n  \"agentId\": \"ordinary\",\n  \"name\": \"ordinary\",\n  \"workspace\": \"$FIXTURE/ordinary\",\n  \"agentDir\": \"$FIXTURE/state/agents/ordinary/agent\",\n  \"bindings\": {\n    \"added\": [],\n    \"updated\": [],\n    \"skipped\": [],\n    \"conflicts\": []\n  }\n}\n",
      "stderr": "",
      "seconds": 7.666955358999999
    },
    {
      "label": "team",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "team",
        "create",
        "--non-interactive",
        "--workspace-root",
        "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007"
      ],
      "code": 0,
      "signal": null,
      "stdout": "Created team with coordinator \"coordinator\":\n- coordinator: $FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/coordinator\n- researcher: $FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/researcher\n- writer: $FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/writer\n- reviewer: $FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/reviewer\nambient owner stays main; talk to the coordinator by name\nTalk to the coordinator: openclaw agent --agent coordinator --message \"Describe your task\"\n",
      "stderr": "",
      "seconds": 14.621298238
    },
    {
      "label": "team-readback",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "list",
        "--json"
      ],
      "code": 0,
      "signal": null,
      "stdout": "[\n  {\n    \"id\": \"main\",\n    \"workspace\": \"$FIXTURE/workspace\",\n    \"agentDir\": \"$FIXTURE/state/agents/main/agent\",\n    \"bindings\": 0,\n    \"isDefault\": true\n  },\n  {\n    \"id\": \"proof\",\n    \"name\": \"proof\",\n    \"identityName\": \"proof\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007\",\n    \"agentDir\": \"$FIXTURE/state/agents/proof/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792908371538\n  },\n  {\n    \"id\": \"ordinary\",\n    \"name\": \"ordinary\",\n    \"identityName\": \"ordinary\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/ordinary\",\n    \"agentDir\": \"$FIXTURE/state/agents/ordinary/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792908386577\n  },\n  {\n    \"id\": \"coordinator\",\n    \"name\": \"coordinator\",\n    \"identityName\": \"Chief of Staff\",\n    \"identityEmoji\": \"🧭\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/coordinator\",\n    \"agentDir\": \"$FIXTURE/state/agents/coordinator/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792908395122\n  },\n  {\n    \"id\": \"researcher\",\n    \"name\": \"researcher\",\n    \"identityName\": \"Researcher\",\n    \"identityEmoji\": \"🔎\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/researcher\",\n    \"agentDir\": \"$FIXTURE/state/agents/researcher/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792908397224\n  },\n  {\n    \"id\": \"writer\",\n    \"name\": \"writer\",\n    \"identityName\": \"Writer\",\n    \"identityEmoji\": \"✍️\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/writer\",\n    \"agentDir\": \"$FIXTURE/state/agents/writer/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792908399173\n  },\n  {\n    \"id\": \"reviewer\",\n    \"name\": \"reviewer\",\n    \"identityName\": \"Reviewer\",\n    \"identityEmoji\": \"🔍\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/reviewer\",\n    \"agentDir\": \"$FIXTURE/state/agents/reviewer/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792908401213\n  }\n]\n",
      "stderr": "",
      "seconds": 7.037669995999997
    }
  ],
  "observations": [
    {
      "label": "agent-create",
      "controls": 3,
      "forgedLine": true,
      "escapedLine": false,
      "unicode": true
    },
    {
      "label": "team-create",
      "controls": 12,
      "forgedLine": true,
      "escapedLine": false,
      "unicode": true
    }
  ],
  "readback": {
    "rawWorkspace": "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007",
    "persistedWorkspace": "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007",
    "workspaceExists": true,
    "ordinaryWorkspace": "$FIXTURE/ordinary",
    "ordinaryExists": true,
    "teamWorkspaces": [
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/coordinator",
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/researcher",
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/writer",
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/reviewer"
    ],
    "teamDirectoriesExist": true
  },
  "result": "PASS"
}
{
  "phase": "green",
  "head": "cfac4f3b0595ea4bef7b7e9166ebec27e8827d1d",
  "at": "2026-10-25T06:45:22.946Z",
  "runs": [
    {
      "label": "create",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "add",
        "proof",
        "--non-interactive",
        "--workspace",
        "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007"
      ],
      "code": 0,
      "signal": null,
      "stdout": "Updated config: $FIXTURE/openclaw.json\n  Backup: $FIXTURE/openclaw.json.bak\nAgent: proof\nWorkspace: $FIXTURE/café\\noperator-forged\\tend\\rrow\nAgent dir: $FIXTURE/state/agents/proof/agent\n",
      "stderr": "",
      "seconds": 11.182838064
    },
    {
      "label": "list",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "list",
        "--json"
      ],
      "code": 0,
      "signal": null,
      "stdout": "[\n  {\n    \"id\": \"main\",\n    \"workspace\": \"$FIXTURE/workspace\",\n    \"agentDir\": \"$FIXTURE/state/agents/main/agent\",\n    \"bindings\": 0,\n    \"isDefault\": true\n  },\n  {\n    \"id\": \"proof\",\n    \"name\": \"proof\",\n    \"identityName\": \"proof\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007\",\n    \"agentDir\": \"$FIXTURE/state/agents/proof/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792910733919\n  }\n]\n",
      "stderr": "",
      "seconds": 7.015276287000001
    },
    {
      "label": "ordinary",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "add",
        "ordinary",
        "--non-interactive",
        "--workspace",
        "$FIXTURE/ordinary",
        "--json"
      ],
      "code": 0,
      "signal": null,
      "stdout": "{\n  \"agentId\": \"ordinary\",\n  \"name\": \"ordinary\",\n  \"workspace\": \"$FIXTURE/ordinary\",\n  \"agentDir\": \"$FIXTURE/state/agents/ordinary/agent\",\n  \"bindings\": {\n    \"added\": [],\n    \"updated\": [],\n    \"skipped\": [],\n    \"conflicts\": []\n  }\n}\n",
      "stderr": "",
      "seconds": 8.24476051
    },
    {
      "label": "team",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "team",
        "create",
        "--non-interactive",
        "--workspace-root",
        "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007"
      ],
      "code": 0,
      "signal": null,
      "stdout": "Created team with coordinator \"coordinator\":\n- coordinator: $FIXTURE/team-café\\noperator-forged\\tend\\rrow/coordinator\n- researcher: $FIXTURE/team-café\\noperator-forged\\tend\\rrow/researcher\n- writer: $FIXTURE/team-café\\noperator-forged\\tend\\rrow/writer\n- reviewer: $FIXTURE/team-café\\noperator-forged\\tend\\rrow/reviewer\nambient owner stays main; talk to the coordinator by name\nTalk to the coordinator: openclaw agent --agent coordinator --message \"Describe your task\"\n",
      "stderr": "",
      "seconds": 16.080778688000002
    },
    {
      "label": "team-readback",
      "args": [
        "$CHECKOUT/openclaw.mjs",
        "agents",
        "list",
        "--json"
      ],
      "code": 0,
      "signal": null,
      "stdout": "[\n  {\n    \"id\": \"main\",\n    \"workspace\": \"$FIXTURE/workspace\",\n    \"agentDir\": \"$FIXTURE/state/agents/main/agent\",\n    \"bindings\": 0,\n    \"isDefault\": true\n  },\n  {\n    \"id\": \"proof\",\n    \"name\": \"proof\",\n    \"identityName\": \"proof\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007\",\n    \"agentDir\": \"$FIXTURE/state/agents/proof/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792910733919\n  },\n  {\n    \"id\": \"ordinary\",\n    \"name\": \"ordinary\",\n    \"identityName\": \"ordinary\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/ordinary\",\n    \"agentDir\": \"$FIXTURE/state/agents/ordinary/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792910749196\n  },\n  {\n    \"id\": \"coordinator\",\n    \"name\": \"coordinator\",\n    \"identityName\": \"Chief of Staff\",\n    \"identityEmoji\": \"🧭\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/coordinator\",\n    \"agentDir\": \"$FIXTURE/state/agents/coordinator/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792910757975\n  },\n  {\n    \"id\": \"researcher\",\n    \"name\": \"researcher\",\n    \"identityName\": \"Researcher\",\n    \"identityEmoji\": \"🔎\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/researcher\",\n    \"agentDir\": \"$FIXTURE/state/agents/researcher/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792910760760\n  },\n  {\n    \"id\": \"writer\",\n    \"name\": \"writer\",\n    \"identityName\": \"Writer\",\n    \"identityEmoji\": \"✍️\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/writer\",\n    \"agentDir\": \"$FIXTURE/state/agents/writer/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792910763023\n  },\n  {\n    \"id\": \"reviewer\",\n    \"name\": \"reviewer\",\n    \"identityName\": \"Reviewer\",\n    \"identityEmoji\": \"🔍\",\n    \"identitySource\": \"config\",\n    \"workspace\": \"$FIXTURE/team-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/reviewer\",\n    \"agentDir\": \"$FIXTURE/state/agents/reviewer/agent\",\n    \"bindings\": 0,\n    \"isDefault\": false,\n    \"createdVia\": \"operator\",\n    \"creatorAgentId\": null,\n    \"createdAt\": 1792910765269\n  }\n]\n",
      "stderr": "",
      "seconds": 7.237302484
    }
  ],
  "observations": [
    {
      "label": "agent-create",
      "controls": 0,
      "forgedLine": false,
      "escapedLine": true,
      "unicode": true
    },
    {
      "label": "team-create",
      "controls": 0,
      "forgedLine": false,
      "escapedLine": true,
      "unicode": true
    }
  ],
  "readback": {
    "rawWorkspace": "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007",
    "persistedWorkspace": "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007",
    "workspaceExists": true,
    "ordinaryWorkspace": "$FIXTURE/ordinary",
    "ordinaryExists": true,
    "teamWorkspaces": [
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/coordinator",
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/researcher",
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/writer",
      "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/reviewer"
    ],
    "teamDirectoriesExist": true
  },
  "result": "PASS"
}
Replay scripts, focused checks and independent review

Save the following two files together in a directory outside both product checkouts. Set CHECKOUT to the absolute clean checkout of either SHA, HARNESS_DIR to that external script directory, and PHASE=red for base or PHASE=green for head. Build each checkout normally; do not copy output or edit build stamps.

cd "$CHECKOUT"
pnpm install --frozen-lockfile
OPENCLAW_TYPECHECKER=tsgo node --import ./scripts/tsx.mjs scripts/build-all.mts cliStartup
cd "$HARNESS_DIR"
node proof-agents.mjs "$CHECKOUT" "$PHASE"

proof-common.mjs:

import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import {createHash} from 'node:crypto';
import {execFileSync, spawn} from 'node:child_process';

export const unusual = 'café\x1b[31m\noperator-forged\tend\rrow\x07';

export function fixture(name) {
 const checkout=path.resolve(process.argv[2]);
 const phase=process.argv[3];
 assert.ok(['red','green'].includes(phase));
 const head=execFileSync('git',['rev-parse','HEAD'],{cwd:checkout,encoding:'utf8'}).trim();
 assert.equal(execFileSync('git',['status','--porcelain'],{cwd:checkout,encoding:'utf8'}).trim(),'');
 const stamp=JSON.parse(fs.readFileSync(path.join(checkout,'dist/.buildstamp')));
 assert.equal(stamp.head,head);
 assert.equal(stamp.inputsClean,true);
 const root=fs.mkdtempSync(path.join(os.tmpdir(),`alix-escape-${name}-`));
 for(const leaf of ['home','state','workspace','tmp'])fs.mkdirSync(path.join(root,leaf));
 const configPath=path.join(root,'openclaw.json');
 const config={agents:{ownership:'explicit',defaults:{systemAgent:{agentId:'main'}},entries:{main:{workspace:path.join(root,'workspace')}}},tools:{profile:'minimal'},plugins:{allow:[],slots:{memory:'none'}},logging:{level:'warn',consoleLevel:'warn',file:path.join(root,'runtime.log')}};
 const writeConfig=()=>fs.writeFileSync(configPath,JSON.stringify(config),{mode:0o600});
 writeConfig();
 const env={PATH:`${path.dirname(process.execPath)}:/usr/bin:/bin`,HOME:path.join(root,'home'),TMPDIR:path.join(root,'tmp'),LANG:'C.UTF-8',TZ:'UTC',TERM:'dumb',NO_COLOR:'1',COLUMNS:'320',CI:'1',DO_NOT_TRACK:'1',OPENCLAW_CONFIG_PATH:configPath,OPENCLAW_STATE_DIR:path.join(root,'state'),OPENCLAW_NO_RESPAWN:'1',OPENCLAW_DISABLE_BONJOUR:'1'};
 const receipt={name,phase,head,at:new Date().toISOString(),root,runs:[],observations:[],readback:{}};
 const save=()=>fs.writeFileSync(path.join(root,'receipt.json'),JSON.stringify(receipt,null,2));
 async function command(label, executable, args, options={}){
  const started=performance.now();
  const row=await new Promise((resolve,reject)=>{
   const child=spawn(executable,args,{cwd:checkout,env:{...env,...options.env},stdio:['ignore','pipe','pipe']});
   let stdout='',stderr='';
   const timer=setTimeout(()=>child.kill('SIGKILL'),90000);
   child.stdout.setEncoding('utf8').on('data',x=>{stdout+=x;});
   child.stderr.setEncoding('utf8').on('data',x=>{stderr+=x;});
   child.on('error',reject);
   child.on('close',(code,signal)=>{clearTimeout(timer);resolve({label,args,code,signal,stdout,stderr,seconds:(performance.now()-started)/1000});});
  });
  receipt.runs.push(row);save();
  assert.equal(row.signal,null,`${label}: setup/timeout is not product RED`);
  assert.equal(row.code,options.exit??0,`${label}: ${row.stderr}`);
  return row;
 }
 const run=async(label,args,options)=>command(label,process.execPath,[path.join(checkout,'openclaw.mjs'),...args],options);
 function text(label,output,options={}){
  const controls=[...output.matchAll(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g)].length;
  const forgedLine=output.includes('\noperator-forged');
  const observation={label,controls,forgedLine,escapedLine:output.includes('\\noperator-forged'),unicode:output.includes('café')};
  receipt.observations.push(observation);save();
  assert.equal(controls>0,phase==='red',`${label}: control result`);
  if(!options.table)assert.equal(forgedLine,phase==='red',`${label}: injected report row`);
  assert.equal(observation.unicode,true,`${label}: Unicode control`);
  if(phase==='green')assert.equal(observation.escapedLine,true,`${label}: retain visible escaped line`);
 }
 function finish(){receipt.result='PASS';save();console.log(JSON.stringify({name,phase,head,result:'PASS',receipt:path.join(root,'receipt.json'),observations:receipt.observations,readback:receipt.readback}));}
 return {checkout,root,configPath,config,writeConfig,env,receipt,run,command,text,save,finish,hash:bytes=>createHash('sha256').update(bytes).digest('hex')};
}

proof-agents.mjs:

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import {fixture,unusual} from './proof-common.mjs';
const f=fixture('agents');
const workspace=path.join(f.root,unusual);
const report=await f.run('create',['agents','add','proof','--non-interactive','--workspace',workspace]);
f.text('agent-create',report.stdout);
const list=JSON.parse((await f.run('list',['agents','list','--json'])).stdout);
const row=list.find(a=>a.id==='proof');
assert.equal(row.workspace,workspace);
assert.ok(fs.statSync(workspace).isDirectory());
const config=JSON.parse(fs.readFileSync(f.configPath,'utf8'));
assert.equal(config.agents.entries.proof.workspace,workspace);
const ordinary=path.join(f.root,'ordinary');
const created=JSON.parse((await f.run('ordinary',['agents','add','ordinary','--non-interactive','--workspace',ordinary,'--json'])).stdout);
assert.equal(created.workspace,ordinary);
assert.ok(fs.statSync(ordinary).isDirectory());
const teamRoot=path.join(f.root,`team-${unusual}`);
f.text('team-create',(await f.run('team',['agents','team','create','--non-interactive','--workspace-root',teamRoot])).stdout);
const teamList=JSON.parse((await f.run('team-readback',['agents','list','--json'])).stdout).filter(row=>row.workspace.startsWith(teamRoot));
assert.ok(teamList.length>=2);
for(const agent of teamList)assert.ok(fs.statSync(agent.workspace).isDirectory());
f.receipt.readback={rawWorkspace:row.workspace,persistedWorkspace:config.agents.entries.proof.workspace,workspaceExists:true,ordinaryWorkspace:created.workspace,ordinaryExists:true,teamWorkspaces:teamList.map(row=>row.workspace),teamDirectoriesExist:true};
f.finish();
{
  "focusedChecks": [
    {
      "log": "agents-tests-repair-final.log",
      "seconds": 363.74,
      "tests": "36 passed (36)",
      "command": "OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/commands/agents.add.test.ts src/commands/agents.roles.test.ts --maxWorkers=1"
    }
  ],
  "independentReview": {
    "sourceVerdict": "pass",
    "findings": [],
    "scope": [
      "Complete base-to-candidate production/test/documentation diff including root resolution delta",
      "Full agentsAddCommand and agentsTeamCreateCommand modules",
      "CLI registrations, createAgentTeam ID/workspace/config source, ID normalization and config reference validation",
      "Binding formatter and both interactive/noninteractive conflict notes; human and raw JSON branches",
      "Existing safe shared list renderer, ANSI/C0/C1 sanitization owner, regression test boundaries and baseline RED proof harness/continuous receipts"
    ],
    "hashes": {
      "src/commands/agents.commands.add.ts": "e93e89e786cb168aa9cbdb15c64516fb4bf51782e5d813a9c60982309c670c26",
      "src/commands/agents.commands.team.ts": "2cd1cc6f139398b0dc24d5cd7f0e95bc789f060b234e93b6c8c154c27987ae39",
      "src/commands/agents.add.test.ts": "ff3561da636939ab4b078040948fa30b8525d09fe0e4c72e7bb14e89c548b478",
      "src/commands/agents.roles.test.ts": "ffbe7c476f28cba45bfc8a7e644118f08d89b7ed2bac4ba62379164bfc168630",
      "docs/cli/agents.md": "84c149651b6874ae3c1d6fecc3404ac78c7473fbd86de7bdd043ef39394dc73d"
    },
    "staticGates": {
      "diffCheck": "pass",
      "targetedTypecheck": "pass exit 0 on final bytes: supported OPENCLAW_TYPECHECKER=tsgo repository run-tsgo.mjs -p ../agents-review-types.json --declaration false --singleThreaded --checkers 1 with600000ms compiler budget; two touched test roots plus canonical ambient declarations, no diagnostics; see agents-independent-typecheck-final.log. Earlier180000ms watchdog under cold parallel worker compilation retained in agents-independent-typecheck-targeted.log as non-pass history",
      "targetedLint": "pass exit 0 on final bytes: repository run-oxlint.mjs with normal type-aware config/tsconfig/oxlint.core.json on all four changed TypeScript files, normal native-build lock queue honored; see agents-independent-lint-final.log",
      "targetedFormat": "pass exit 0 on final bytes: OPENCLAW_FORMAT_TOOL=oxfmt repository run-format.mts --check on all five changed files; see agents-independent-format-final.log"
    },
    "exactHeadProof": {
      "status": "PASS",
      "productHead": "cfac4f3b0595ea4bef7b7e9166ebec27e8827d1d",
      "observations": [
        {
          "label": "agent-create",
          "controls": 0,
          "forgedLine": false,
          "escapedLine": true,
          "unicode": true
        },
        {
          "label": "team-create",
          "controls": 0,
          "forgedLine": false,
          "escapedLine": true,
          "unicode": true
        }
      ],
      "readback": {
        "rawWorkspace": "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007",
        "persistedWorkspace": "$FIXTURE/café\u001b[31m\noperator-forged\tend\rrow\u0007",
        "workspaceExists": true,
        "ordinaryWorkspace": "$FIXTURE/ordinary",
        "ordinaryExists": true,
        "teamWorkspaces": [
          "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/coordinator",
          "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/researcher",
          "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/writer",
          "$FIXTURE/team-café\u001b[31m\noperator-forged\tend\rrow\u0007/reviewer"
        ],
        "teamDirectoriesExist": true
      }
    }
  }
}
status: PASS
product_sha: cfac4f3b0595ea4bef7b7e9166ebec27e8827d1d
base_sha: e8b251188f502b088dd037936062a1711ea302e1
claims: C1=Human CLI reports prevent terminal actions and embedded-row injection while preserving raw values.
covered_by: C1=Same normal-built CLI scenario before/after, exact stdout byte checks and scenario-specific external readback described below.
entry: agents add / agents team create via normally built openclaw.mjs
owner: src/commands/agents.commands.add.ts, src/commands/agents.commands.team.ts executed unmocked
boundary: subprocess,config-file,disk
readback: agents list --json plus saved configuration retain raw workspace paths; individual and all four team directories exist; ordinary workspace creates successfully.
proof_command: node proof-agents.mjs "$CHECKOUT" "$PHASE"
harness: proof-common.mjs sha256=8a6d2e48b1b076878e98641b0791f7fb064f44bbff9522fe43d1d34c6ffb007f; proof-agents.mjs sha256=70179edce850fdfd6b33b13f6c7374bb71121c9158062e9f7fe3e1c471a5938d
before: RED agent-create: 3 controls; forgedRow=true; escapedNewline=false; team-create: 12 controls; forgedRow=true; escapedNewline=false
after: GREEN agent-create: 0 controls; forgedRow=false; escapedNewline=true; team-create: 0 controls; forgedRow=false; escapedNewline=true
negative_claim: yes
control: Ordinary non-interactive JSON creation succeeds; 4 team directories exist; Unicode retained; 0 embedded C0/C1 controls in affected human summaries on head. Focused tests cover raw JSON and ambient-owner notes.
consumers: Canonical human report owner and related JSON/sibling consumers reviewed; existing terminal-core sanitizer reused. No shared formatter, storage, routing, protocol or endpoint policy change.
tests: OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/commands/agents.add.test.ts src/commands/agents.roles.test.ts --maxWorkers=1 => 36 passed (36); exit 0
tests_changed: yes
test_cost: 363.74 seconds measured native wrapper wall time; includes native test-worker compilation, module transformation and artifact verification, not only assertions.
visual: no
screenshots: N/A: terminal text output; inspectable JSON-escaped stdout below
published: pr-body
not_tested: Non-interactive Linux creation and existing guided conflict report siblings inspected; no interactive terminal UX, provider onboarding or native Windows/macOS claim. Broad upstream CI is pending.
reuse: N/A: fresh native clean CLI build and real scenario on exact product head; full-suite results before final assertion-only fixture edits are labeled separately.

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: S labels Oct 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Escape terminal controls in human-readable agent and team creation summaries while preserving raw JSON and stored values.

Example: Create an agent whose workspace is /tmp/café followed by a newline and forged.

  • Before: The summary prints forged on a separate line.
  • After: The summary displays /tmp/café\nforged on one line, while the directory retains its original name.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful repair with shipped-CLI evidence, meaningful regressions, preserved data contracts, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Contributor-supplied Linux CLI traces exercise real agents add and agents team create before and after the fix, with safe human output and raw config/JSON/directory readback; the prior-head scenarios remain applicable after the equivalent conflict-formatting simplification, supported by reported integrated-head regression results.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Control characters in workspace paths or configured labels can trigger terminal actions or forge rows in creation summaries.
Reason: The patch extends the established display-safety contract without adding options, changing defaults, or altering persisted data.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current terminal-output defect with a focused implementation and no actionable findings; exact-head CI remains pending.

Priority: P2
Reviewed head: 8c279c04e809f238e3e0411bdd3d2458a486dc1e

Before merge

None.

Findings

None.

Agent review details

How this fits together

Agent CLI commands receive creation-service results after workspace and configuration writes, then render human summaries or machine-readable JSON.

flowchart LR
  A[CLI options] --> B[Agent creation services]
  B --> C[Configuration and directories]
  B --> D[Creation results]
  D --> E[Human output sanitizer]
  D --> F[Raw JSON output]
  E --> G[Terminal]
Loading

Technical review

Best possible solution:

Merge the focused display-boundary repair using the existing sanitizer while preserving creation inputs, stored values, and machine-readable output.

Do we have a high-confidence way to reproduce the issue?

Current-main raw interpolations match the contributor's before-fix CLI traces; this read-only review executed no target code.

Is this the best way to solve the issue?

This is the smallest complete repair: apply the existing sanitizer at human rendering sites and retain shared raw formatters for JSON consumers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 47a88380810f.

Provenance checked

  • Agent creation summaries keeps the original intent (932e8be: Canonical creation consolidated workspace and configuration writes behind one service and left the CLI as a thin result renderer.)
  • Team summaries and ambient-owner notes keeps the original intent (f77b4ef: Team onboarding reports created workspaces and preserves an existing ambient owner, including raw machine-readable results.)
  • Binding-conflict rendering keeps the original intent (f3ed9bb: Command cleanup consolidated formatter plumbing while preserving command behavior; the shared descriptions remain raw for JSON.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +6, Tests +99, Docs +4. Total +109 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 13 7 +6
Tests 2 99 0 +99
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 116 7 +109

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +13/-7; tests +99 Small display-boundary growth reuses the existing sanitizer; tests protect human/raw-output separation and actual workspace preservation.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Control-bearing paths and configured values can execute terminal controls or forge creation-summary rows, with impact confined to human CLI output.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-25T07:05:03.612Z sha cfac4f3 :: needs maintainer review before merge. :: none

Reviewed October 25, 2026, 8:01 PM ET / October 26, 2026, 00:01 UTC (Revision 2).

steipete and others added 2 commits October 25, 2026 16:52
Reuse formatted binding conflict descriptions and sanitize human reports while preserving JSON and stored values.

Co-authored-by: Alix-007 <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 78b6d76 into openclaw:main Oct 26, 2026
121 of 124 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @steipete for reviewing and merging this! I appreciate your help getting this focused fix landed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…#183360)

* fix(agents): escape terminal controls in creation summaries

* test(agents): match the JSON writer call contract

Co-authored-by: Alix-007 <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
* fix(agents): escape terminal controls in creation summaries

* test(agents): match the JSON writer call contract

Co-authored-by: Alix-007 <[email protected]>

(cherry picked from commit 78b6d76)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit b99265f14c91a46453ecf5abaf59904fc9c528e4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants