Skip to content

Add stdin and file message inputs to agent CLI#94423

Closed
mcampsall wants to merge 1 commit into
openclaw:mainfrom
mcampsall:codex/agent-message-stdin-upstream
Closed

Add stdin and file message inputs to agent CLI#94423
mcampsall wants to merge 1 commit into
openclaw:mainfrom
mcampsall:codex/agent-message-stdin-upstream

Conversation

@mcampsall

Copy link
Copy Markdown

Summary

  • add openclaw agent --message-stdin and --message-file <path>
  • enforce exactly one message input source across inline, file, and stdin
  • reject empty file/stdin input and keep size limits before dispatch

Verification

  • node scripts/test-projects.mjs src/cli/program/register.agent.test.ts src/commands/agent-via-gateway.test.ts
  • pnpm tsgo:core
  • pnpm build
  • isolated CLI smokes for --message-stdin and --message-file reached expected no-target validation

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 18, 2026
@clawsweeper

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 2:39 PM ET / 18:39 UTC.

Summary
The branch adds --message-stdin and --message-file as alternative openclaw agent message sources, resolves exactly one input before dispatch, and adds parser/runtime tests.

PR surface: Source +88, Tests +57. Total +145 across 4 files.

Reproducibility: not applicable. as a bug reproduction; this PR adds a new CLI input mode. The review blockers are source-reproducible by comparing current main with the PR head and the merged file-only PR.

Review metrics: 1 noteworthy metric.

  • Agent CLI input contract: 1 new public input mode added; 1 current-main mode overlapped. --message-stdin is new, while --message-file already exists on main, so review should focus on additive stdin behavior without regressing the shipped file path.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal output, copied live output, logs, or a recording showing --message-stdin after rebasing; redact private paths, endpoints, API keys, phone numbers, and other private details.
  • Rebase on current main and preserve the merged --message-file semantics plus the /compact rejection.
  • Update public docs and focused tests for stdin, including mutual exclusion, empty input, and /compact handling.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The external PR needs real behavior proof before merge; the body lists commands and claimed smokes but no inspectable after-fix output or artifact for stdin/file behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The branch is currently conflicting, and a conflict resolution that keeps the PR resolver can overwrite current-main --message-file guarantees for multiline content, BOM removal, invalid UTF-8 rejection, and /compact rejection.
  • [P1] The PR body lists commands and claimed isolated smokes, but there is no inspectable after-fix terminal output, log, recording, or artifact for the new stdin behavior.
  • [P1] --message-stdin is a new public CLI input surface, so maintainers need the scope, docs, and upgrade-safe behavior settled before merge.

Maintainer options:

  1. Rebase and layer stdin onto current main (recommended)
    Preserve the merged file-message resolver, UTF-8/BOM behavior, docs, and /compact guard while adding stdin as the only new input mode.
  2. Pause if stdin scope is not approved
    If maintainers only wanted file input, close or pause this branch because feat(cli): add --message-file to openclaw agent #93351 already landed that contract.
  3. Accept stdin as a public CLI feature after proof
    Maintainers can still proceed with stdin once the branch has redacted real behavior proof and docs for the new input source.

Next step before merge

  • [P1] Human review is needed because the branch is conflicting, lacks contributor-supplied real behavior proof, and needs a maintainer scope decision for stdin after preserving current-main contracts.

Security
Cleared: No concrete security or supply-chain regression was found; the diff adds no dependencies, workflows, lockfile changes, or secret handling.

Review findings

  • [P1] Preserve the merged file-message contract — src/commands/agent-via-gateway.ts:268
  • [P1] Keep the /compact guard after resolving input — src/commands/agent-via-gateway.ts:925-926
  • [P2] Document stdin wherever agent inputs are documented — src/cli/program/register.agent-turn.ts:39
Review details

Best possible solution:

Rebase on current main, keep the merged --message-file implementation and /compact guard, then add stdin as an additive input mode with docs, focused tests, and redacted real terminal proof.

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

Not applicable as a bug reproduction; this PR adds a new CLI input mode. The review blockers are source-reproducible by comparing current main with the PR head and the merged file-only PR.

Is this the best way to solve the issue?

No. The right shape is to add stdin on top of the current main resolver, not reimplement the now-merged file-message path or bypass the current /compact guard.

Full review comments:

  • [P1] Preserve the merged file-message contract — src/commands/agent-via-gateway.ts:268
    Current main already has --message-file and tests that it preserves multiline content and a trailing newline after BOM removal while rejecting invalid UTF-8. This resolver trims every source and reads files with non-fatal UTF-8 decoding, so resolving the conflict by keeping this path would regress the merged file-input contract.
    Confidence: 0.94
  • [P1] Keep the /compact guard after resolving input — src/commands/agent-via-gateway.ts:925-926
    Current main rejects /compact after message-file resolution and before Gateway or embedded dispatch. This branch proceeds from resolved input into dispatch without that guard, so /compact sent through inline, file, or stdin input can return to the false-success no-op path.
    Confidence: 0.91
  • [P2] Document stdin wherever agent inputs are documented — src/cli/program/register.agent-turn.ts:39
    The PR adds --message-stdin as a public openclaw agent input source, but current public docs only describe --message and --message-file. If stdin remains in scope, update the CLI and tool docs with the exact mutual-exclusion and empty-input behavior.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 477b27b6f87e.

Label changes

Label justifications:

  • P2: This is a normal-priority public CLI feature with limited blast radius and no urgent production regression signal.
  • merge-risk: 🚨 compatibility: A bad conflict resolution can break current users of the already-merged --message-file path and reintroduce the /compact false-success behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The external PR needs real behavior proof before merge; the body lists commands and claimed smokes but no inspectable after-fix output or artifact for stdin/file behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +88, Tests +57. Total +145 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 99 11 +88
Tests 2 57 0 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 156 11 +145

What I checked:

  • Current main input surface: Current main already registers --message-file for openclaw agent but has no --message-stdin, so the file portion is implemented while stdin remains the unique part of this PR. (src/cli/program/register.agent-turn.ts:37, 477b27b6f87e)
  • Current main file-message contract: Current tests assert that --message-file removes an optional BOM, preserves multiline content and the trailing newline for Gateway and local dispatch, and rejects invalid UTF-8 before dispatch. (src/commands/agent-via-gateway.test.ts:311, 477b27b6f87e)
  • Current main compact guard: Current main resolves message input, then rejects /compact CLI agent messages before Gateway or embedded dispatch to avoid the historical false-success no-op path. (src/commands/agent-via-gateway.ts:905, 477b27b6f87e)
  • PR head reimplements message input: The PR head adds stdin support but also reads files with readFileSync(..., "utf8") and trims the resolved raw message, which would not preserve the merged file-message contract if used during conflict resolution. (src/commands/agent-via-gateway.ts:214, 8e58aef1685c)
  • PR head dispatch path: The PR head resolves message input and proceeds to session normalization without the current-main /compact rejection in the shown path. (src/commands/agent-via-gateway.ts:925, 8e58aef1685c)
  • Current docs: The public agent docs document --message and --message-file, but not --message-stdin; stdin would need docs if it remains in scope. Public docs: docs/cli/agent.md. (docs/cli/agent.md:26, 477b27b6f87e)

Likely related people:

  • ooiuuii: Authored the merged file-only agent CLI PR that now owns the current --message-file behavior this branch overlaps. (role: feature introducer; confidence: high; commits: 4897f2fc2005, a0fedcfb7e53; files: src/commands/agent-via-gateway.ts, src/commands/agent-via-gateway.test.ts, src/cli/program/register.agent-turn.ts)
  • Alix-007: Authored the merged sessions compact PR that added the current CLI /compact rejection this PR must preserve after message-source resolution. (role: adjacent invariant introducer; confidence: high; commits: 13b4d49fa213, e35e5f123dda; files: src/commands/agent-via-gateway.ts, src/commands/agent-via-gateway.test.ts, docs/cli/sessions.md)
  • vincentkoc: Merged the file-only agent message-file PR, which makes them relevant for routing questions about preserving that public CLI contract. (role: merger/reviewer signal; confidence: medium; commits: a0fedcfb7e53; files: src/commands/agent-via-gateway.ts, docs/cli/agent.md, docs/tools/agent-send.md)
  • sallyom: Merged the sessions compact PR that introduced the /compact guard now affected by this branch's stale dispatch path. (role: merger signal; confidence: medium; commits: e35e5f123dda; files: src/commands/agent-via-gateway.ts, src/commands/agent-via-gateway.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 19, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 16, 2026
@mcampsall mcampsall closed this Jul 21, 2026
@mcampsall
mcampsall deleted the codex/agent-message-stdin-upstream branch July 21, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant