Skip to content

feat(core): let long shell commands yield and follow them with command_status - #488

Merged
lg2m merged 6 commits into
mainfrom
feat/long-running-shell
Oct 28, 2026
Merged

lg2m merged 6 commits into
mainfrom
feat/long-running-shell

Conversation

@lg2m

@lg2m lg2m commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Change

Long shell commands no longer block or fail a turn (plan section C).

  • shell and exec take yield_after_seconds (default 30 s). A command still running then returns exit=running id=c<call8> with its output so far and keeps running.
  • New command_status(id, wait_seconds ≤ 600, cancel) waits for a yielded command and returns its normal result, or its output so far; cancel=true kills it. It is offered exactly when shell or exec is. A run keeps at most 16 yielded commands, and they stop when the run ends.
  • A command ends when its main process exits; its process group is killed then, so sleep 600 & no longer holds the turn until the timeout.
  • Output is captured up to just under the 8 MiB spill cap, so read_tool_result can search the middle of a long build log.
  • Commands get TERM=dumb, and NO_COLOR=1, PAGER=cat, GIT_PAGER=cat unless already set.
  • A timeout names its timeout_seconds limit and suggests a larger timeout or yield mode.
  • A tool argument over 64 KiB becomes a tool error naming the limit; the run continues.

Verification

  • New tests: a long command yields and completes via command_status; cancel and teardown stop yielded commands; a full run yields, follows up, and ends with a command still running that teardown stops; sleep 600 & returns; a 1 MiB log is searchable via read_tool_result; a 70 KiB write_file gets a tool error and the run continues; the timeout text; the env defaults.
  • The 64 KiB, background-process, 1 MiB log and timeout-text tests fail on origin/main (the yield tests need the new API to compile).
  • cargo xtask check: passed on this tree.

Known impact

  • Commands that run longer than 30 s now return early by default; the model has to call command_status for the result.
  • The tool-schema hash changes (new argument and tool).
  • xtask/src/legacy-sleeps.txt line numbers shifted for six existing sleeps; no new sleeps.
  • Windows builds through the shared code paths but was not run.

…d_status

A shell or exec call still running after yield_after_seconds (default
30 s) returns a command id and keeps running; command_status waits on,
reads, or cancels it. Yielded commands stop when the run ends.

A command now ends when its leader exits, so a background child holding
the pipe no longer blocks the turn. Output is captured up to the spill
item cap, so read_tool_result reaches the middle of a long log. Commands
get TERM=dumb and, unless set, NO_COLOR=1, PAGER=cat and GIT_PAGER=cat.
Timeouts name their limit and suggest a larger timeout or yield mode.

Tool arguments over 64 KiB become a tool error naming the limit instead
of failing the run.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T22:17:38.619195Z 88c3a53 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: efc018f13b

ℹ️ 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".

Comment thread crates/qq-core/src/lib.rs Resolved
lg2m added 5 commits October 28, 2026 14:02
…r call

- command_status cancel=true now waits a bounded time; a command task that
  never finishes can no longer hold the turn.
- A full table of yielded commands forgets its oldest finished, unread
  result instead of refusing to yield.
- Command ids carry the call id prefix, so an id from an earlier run never
  names a command of a later one.
- A command whose leader already exited no longer reports as running.
- A yielded command's final result moves to command_status, not copied.
- Drop StopYieldedOnDrop: it lived in initialization and fired before any
  command existed; the run's own cancellation already stops them.
@lg2m
lg2m merged commit b6cdf6a into main Oct 28, 2026
9 checks passed
@lg2m
lg2m deleted the feat/long-running-shell branch October 28, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant