Repository navigation
feat(shell): improve background job control - #3673
Conversation
Greptile SummaryThe PR improves persistent-shell stdin isolation and expands background-job management with waiting, incremental output, and reader-drain tracking.
Confidence Score: 4/5The PR is not yet safe to merge because a normal The drain fix preserves jobs only while the reader thread is alive; once it terminates, cleanup invoked by listing or starting jobs removes the buffered output even if no caller has read it. Files Needing Attention: gptme/tools/shell_background.py Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Background parent exits] --> B{Reader still draining?}
B -- Yes --> C[Keep job tracked]
C --> D[Descendant closes pipe]
D --> E[Reader terminates]
E --> F[Caller runs jobs or starts another job]
F --> G[Cleanup deletes finished job]
G --> H[Trailing buffered output becomes unavailable]
B -- No --> F
Reviews (2): Last reviewed commit: "fix(shell): keep tool description under ..." | Re-trigger Greptile |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
CI failed test_tool_descriptions_within_openai_limit at 1064 chars after documenting wait/output --new. Compress the tool-format instructions so the new primitives still fit, including the wait-vs-poll guidance.
|
Pushed a maintainer commit onto this branch: CI was red on the only real leftover: I compressed the tool-format instructions (not the examples) so the new primitives still fit, including when to poll vs wait. Locally the description is 840 chars with this machine's program list; worst-case all 12 candidate programs still leaves ~150 chars of headroom. Focused tests: 75 passed ( Rest of the PR looks like the right slice for #3667:
Not merging from here — waiting on CI for |
|
@greptileai review |
|
Approved the fork-PR GitHub Actions runs on Greptile's new P1 (cleanup discarding drained output) is the existing finished-job cleanup contract, not a drain regression. Still not merging until CI on |
|
CI on |
Closes #3667.
Summary
/dev/nullredirect before parsed background&operators so background processes cannot consume later commands sent to the persistent shellsleep 1 & catcannot retain the persistent shell's stdinwait <job-id> [timeout]with seconds, minutes, and hours suffix supportoutput <job-id> --newfor incremental polling without discarding accumulated outputTesting
ruff formatandruff checkon the four changed filesgetpgidis unavailable and the local WSL bash bridge does not preserve the loop variable)mypyreports 12 existing Windows-only errors for POSIXos.getpgid,os.killpg, andsignal.SIGKILLreferences; the changed code introduces no additional mypy errors.