Skip to content

Background server reuse ignores the requested session mode #70

Description

@benagentai93-dot

Baseline

Reproduced from v1.3.1 at 5a306f8956cb1eeae69f9709de0e4d61b44e11e7.

Reproduction

  1. Start the local background server through a normal agents-cli run. This starts it with the historical default USE_IN_MEMORY_SESSION=true.
  2. In the same project, run local eval generation. _run_against_local_server() calls ensure_server(..., use_in_memory_session=False).
  3. The PID metadata has no session-mode field, and ensure_server() reuses any live, non-idle server without comparing the requested mode.

The same behavior is reproducible without launching a process by providing live PID metadata to ensure_server() and requesting the opposite use_in_memory_session value.

Actual behavior

The eval path reuses a server configured for in-memory sessions even though it explicitly requested persistent sessions. The reverse mismatch is also accepted.

Expected behavior

Reuse only when the existing server's session mode matches the requested mode. For legacy metadata with no field, preserve the historical default of true: normal run may reuse it, while eval's false request must fail closed and tell the user to stop the old server first. A mismatch must not terminate the existing process.

Minimal fix

Record use_in_memory_session in the PID metadata and compare it before reuse. Treat a missing field as true; reject a mismatch with a concise Click error before idle cleanup or any mutation.

Reference implementation: benagentai93-dot@970ed96

Test evidence

Runnable regressions cover matching true/false reuse, both mismatches, legacy normal-run reuse, legacy eval fail-closed, no cleanup on mismatch, and metadata persistence.

Fork verification:

  • focused lifecycle suite: 22 passed
  • full root suite: 41 passed
  • ruff check src tests: passed
  • ty check src: passed
  • uv build: passed
  • installed-wheel agents-cli --version: 1.3.1 on Python 3.11 and 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions