Skip to content

fix: keep command cron turns lightweight - #81868

Merged
steipete merged 1 commit into
mainfrom
codex-cron-command-light-context
May 14, 2026
Merged

steipete merged 1 commit into
mainfrom
codex-cron-command-light-context

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Default command-style cron payloads to lightweight bootstrap context unless the job explicitly sets lightContext: false.
  • Propagate cron bootstrap context mode through both embedded and CLI agent execution paths.
  • Reword Codex cron instructions so the model uses injected context but does not reload workspace bootstrap, memory, or project-doc files before executing an exact cron command.
  • Add a changelog entry for the cron/Codex behavior fix.

Verification

Behavior addressed: exact-command cron jobs could time out after the Codex migration because scheduled turns loaded workspace identity/bootstrap context before running the command.

Real environment tested: local OpenClaw source checkout, with focused cron isolated-agent tests and Codex app-server turn construction tests.

Exact steps or command run after this patch: pnpm test src/cron/isolated-agent.session-identity.test.ts; pnpm test extensions/codex/src/app-server/run-attempt.test.ts -t "cron Codex|lightweight cron"; pnpm exec oxfmt --check --threads=1 CHANGELOG.md extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/thread-lifecycle.ts src/agents/cli-runner/prepare.ts src/agents/cli-runner/types.ts src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run-executor.ts; node scripts/run-oxlint.mjs extensions/codex/src/app-server/thread-lifecycle.ts src/agents/cli-runner/prepare.ts src/agents/cli-runner/types.ts src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run-executor.ts; git diff --check.

Evidence after fix: cron regression tests assert command-style payloads get bootstrapContextMode=lightweight, natural-language cron payloads keep the default context, and lightContext: false opts out; the Codex app-server test asserts the revised cron instructions.

Observed result after fix: all listed checks passed.

What was not tested: live gateway cron execution against a real scheduled job; this PR covers the focused cron/Codex execution seams.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: codex size: S maintainer Maintainer-authored PR labels May 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb4772d5e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

const COMMAND_STYLE_CRON_PREFIX =
/^(?:(?:[A-Z_][A-Z0-9_]*=\S+\s+)+)?(?:cd\s+\S+|(?:\.{1,2}|~)?\/\S+|[A-Za-z]:[\\/]\S+|(?:bash|bun|cargo|deno|docker|gh|git|go|make|node|npm|npx|pnpm|python|python3|ruby|sh|tsx|uv|zsh)\b)/u;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expand command detection to cover generic shell commands

The new auto-lightweight path only triggers when the cron message matches a small allowlist of command prefixes (bash|bun|...|zsh, cd, or path-like forms), so many valid exact commands such as ls -la, echo ok, or sed ... are treated as natural language and keep full bootstrap context. That means the timeout/token-bloat regression this commit targets can still occur for common command-style cron jobs unless users manually set lightContext, which contradicts the commit’s “default exact-command” behavior.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
This PR defaults command-style cron agent-turn payloads to lightweight bootstrap context, threads the mode through embedded and CLI runners, adjusts Codex cron instructions, and adds focused tests plus a changelog entry.

Reproducibility: no. high-confidence live reproduction was established. Source inspection shows current main only honors explicit lightContext and the PR targets that seam, but no failing current-main cron run or after-fix live cron run was executed here.

Real behavior proof
Needs real behavior proof before merge: The PR body provides focused tests and checks but no redacted terminal output, logs, screenshot, recording, or artifact showing a real after-fix cron run; contributors should redact IPs, API keys, phone numbers, private endpoints, and similar private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Needs contributor/maintainer follow-up for real behavior proof and the command-classifier repair; automation should not proceed while the external PR proof is only test-based.

Security
Cleared: The diff changes cron context selection and Codex instructions without adding dependencies, workflow permissions, secret handling, downloads, or package execution hooks.

Review findings

  • [P2] Expand command detection for generic shell commands — src/cron/isolated-agent/run-executor.ts:65
Review details

Best possible solution:

Land a version that broadens exact-command detection across embedded and CLI cron paths, preserves the explicit lightContext:false opt-out, and includes redacted real cron run proof.

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

No high-confidence live reproduction was established. Source inspection shows current main only honors explicit lightContext and the PR targets that seam, but no failing current-main cron run or after-fix live cron run was executed here.

Is this the best way to solve the issue?

No. The direction is right, but the proposed command detector needs to cover generic exact shell commands before the PR reliably fixes the described cron timeout/token-bloat regression.

Full review comments:

  • [P2] Expand command detection for generic shell commands — src/cron/isolated-agent/run-executor.ts:65
    The new auto-lightweight path only recognizes a small prefix allowlist, so exact cron commands such as ls -la, echo ok, or sed ... still run with full bootstrap context unless users manually set lightContext. That leaves the timeout/token-bloat regression in place for common command-style scheduled jobs.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.86

What I checked:

  • Live PR metadata: GitHub API shows this PR is open, based on c9b6b0b, headed at fb4772d, and labeled maintainer. (fb4772d5e099)
  • Current main embedded cron context behavior: On current main, embedded cron execution sets bootstrapContextMode only when payload.lightContext is truthy, so command payloads without the flag keep the default context path. (src/cron/isolated-agent/run-executor.ts:237, c9b6b0be0e36)
  • Current main CLI bootstrap behavior: prepareCliRunContext resolves bootstrap context without contextMode/runKind on current main; the PR's CLI propagation targets this gap. (src/agents/cli-runner/prepare.ts:161, c9b6b0be0e36)
  • Lightweight bootstrap contract: The bootstrap helper keeps cron/default lightweight mode empty, so setting bootstrapContextMode=lightweight is the relevant runtime switch for the reported timeout/token-bloat path. (src/agents/bootstrap-files.ts:184, c9b6b0be0e36)
  • PR classifier gap: The existing review thread identifies that the new COMMAND_STYLE_CRON_PREFIX allowlist misses common exact commands such as ls, echo, and sed, leaving those cron jobs on full bootstrap context. (src/cron/isolated-agent/run-executor.ts:65, fb4772d5e099)
  • Real behavior proof gap: The PR body lists focused tests, format, lint, and diff checks, and explicitly says live gateway cron execution against a real scheduled job was not tested. (fb4772d5e099)

Likely related people:

  • steipete: GitHub commit history shows recent merged work on the same cron, CLI runner, and Codex-adjacent surfaces, including cron model-start/pre-model stall fixes and CLI/Codex refactors; included for prior current-main history, not merely this PR authorship. (role: recent area contributor; confidence: high; commits: 916015590219, 5b3e2497bd55, f28a98744237; files: src/cron/isolated-agent/run-executor.ts, src/agents/cli-runner/prepare.ts, extensions/codex/src/app-server/thread-lifecycle.ts)
  • jalehman: Recent merged commits touched Codex app-server cron automation compatibility and harness behavior near the collaboration-instruction surface this PR edits. (role: recent Codex app-server contributor; confidence: medium; commits: 6395117142e8, 1ee0d51e92f6; files: extensions/codex/src/app-server/thread-lifecycle.ts, extensions/codex/src/app-server/run-attempt.test.ts)
  • legolaz8451: Recent merged timeout-watchdog work changed src/cron/isolated-agent/run-executor.ts, which is the central cron execution path for this PR's runtime behavior. (role: recent cron execution contributor; confidence: medium; commits: 336ba2a2b3f1; files: src/cron/isolated-agent/run-executor.ts)

Remaining risk / open question:

  • The PR's exact-command classifier is too narrow and can leave common shell commands on full bootstrap context, preserving the timeout/token-bloat regression for those jobs.
  • The PR body provides focused test proof only; it does not show an after-fix real cron run in a live gateway/source checkout setup.

Codex review notes: model gpt-5.5, reasoning high; reviewed against c9b6b0be0e36.

@steipete
steipete force-pushed the codex-cron-command-light-context branch from fb4772d to 09c59b0 Compare May 14, 2026 19:07
@steipete steipete added the proof: override Maintainer override for the external PR real behavior proof gate. label May 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09c59b0108

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

const COMMAND_STYLE_CRON_PREFIX =
/^(?:(?:[A-Z_][A-Z0-9_]*=\S+\s+)+)?(?:cd\s+\S+|(?:\.{1,2}|~)?\/\S+|[A-Za-z]:[\\/]\S+|(?:bash|bun|cargo|deno|docker|gh|git|go|make|node|npm|npx|pnpm|python|python3|ruby|sh|tsx|uv|zsh)\b)/u;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid classifying verb-led prose as exact shell commands

The command-style detector treats any single-line cron message starting with allowlisted binaries like make or go as an exact command, so natural-language payloads such as "make sure the nightly report is posted" are misclassified as command-style and forced into lightweight bootstrap mode. This drops normal workspace/bootstrap context for prose requests, changing behavior for legitimate non-command cron turns and making summaries/planning prompts less reliable.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 686b93e into main May 14, 2026
93 of 95 checks passed
@steipete
steipete deleted the codex-cron-command-light-context branch May 14, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex maintainer Maintainer-authored PR proof: override Maintainer override for the external PR real behavior proof gate. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant