Skip to content

test(agents): session-transport-macos flakes with ENOTEMPTY in gentle-agents teardown #1840

Closed

Description

@Alan-TheGentleman

Before submitting

  • I searched open and closed issues and did not find a report of this problem.
  • I reviewed this report and removed credentials, tokens, private paths, hostnames, and other sensitive data.

Problem

The session-transport-macos CI job fails intermittently with ENOTEMPTY while a tests/gentle-agents.test.ts case removes its temporary profile directory. It has failed on at least two PRs (#1832 and #1835) in different tests and passed on rerun both times, so it blocks merges for no product reason.

Root cause: session_shutdown persists finished subagent history asynchronously (persist() calls void saveTask(...) into the profile's tasks directory). The test then calls rmSync(profile, { recursive: true, force: true }) right after shutdown. On macOS the late history write can land between the recursive deletion of the children and the removal of the directory, so rmdir sees a non-empty directory.

Steps to reproduce

  1. Run the session-transport-macos job (or node --experimental-strip-types --test tests/gentle-agents.test.ts on macOS) repeatedly.
  2. Observe an occasional failure in a teardown rmSync of a gentle-agents-continue-* or similar temporary directory.

Expected and actual behavior

Expected: test teardown removes its temporary directories reliably.
Actual: Error: ENOTEMPTY, Directory not empty: <tmp>/gentle-agents-continue-XXXX in "a writer continuation without its own section inherits the admitted surfaces end to end" (PR #1835) and in "a subdirectory session cwd and workspace_root ... share one writer key" (PR #1832).

gentle-pi version

main at aa2c038 (package 4.0.0)

Pi version

1.0.0 (development dependency)

Operating system

macOS

Relevant logs or error output (optional)

✖ a writer continuation without its own section inherits the admitted surfaces end to end (55.832875ms)
  Error: ENOTEMPTY, Directory not empty: <tmp>/gentle-agents-continue-ZJrSQZ
    code: 'ENOTEMPTY',

Activity

  1. added
    bugSomething isn't working
    status:approvedIssue approved by maintainer; PR may be opened
    and removed on Oct 6, 2026
  2. added a commit that references this issue on Oct 7, 2026
    e692cf4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus:approvedIssue approved by maintainer; PR may be opened

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions