Skip to content

fix(server): scope --reload watching to source dirs (#569)#611

Open
voidborne-d wants to merge 1 commit intoOpenBMB:mainfrom
voidborne-d:fix/reload-exclude-warehouse
Open

fix(server): scope --reload watching to source dirs (#569)#611
voidborne-d wants to merge 1 commit intoOpenBMB:mainfrom
voidborne-d:fix/reload-exclude-warehouse

Conversation

@voidborne-d
Copy link
Copy Markdown
Contributor

Summary

Closes #569.

When python server_main.py --reload is used during development, uvicorn defaults reload_dirs to the current working directory and StatReload recursively walks the tree for *.py files. Because the agent writes generated code into WareHouse/session_<uuid>/code_workspace/<file>.py, every time a workflow produces code the server restarts mid-run, the in-flight session is cancelled, and the webui is left waiting indefinitely.

Both READMEs already ship a warning telling users to drop --reload, but that removes exactly the feedback loop developers need.

Fix

server_main.py now passes uvicorn:

  • an explicit reload_dirs list restricted to the project's Python source folders (check, entity, functions, mcp_example, runtime, schema_registry, server, tools, utils, workflow), so StatReload — which ignores reload_excludes entirely — never walks WareHouse/ or logs/;
  • a matching reload_excludes list (WareHouse/*, logs/*, data/*, temp/*, node_modules/*) so watchfiles-backed installs also stop observing output dirs. This set mirrors .gitignore.

Users can override either list via repeatable --reload-dir / --reload-exclude flags.

The reload-kwargs construction is extracted into a pure helper (build_reload_kwargs) so the behaviour is unit-testable without spinning up a server.

Changes

  • server_main.py: define RELOAD_SOURCE_DIRS / RELOAD_EXCLUDES, add build_reload_kwargs() + build_parser() helpers, wire new CLI flags, pass the resulting kwargs to uvicorn.run(...).
  • tests/test_server_main_reload.py: 9 new tests (defaults exclude WareHouse, include server/runtime; overrides win; repeatable flags; returned lists are copies). Uses an importlib.util spec loader + monkeypatch.setitem(sys.modules, ...) so stubs for runtime.bootstrap / server.app are fully isolated from the rest of the test suite.
  • README.md / README-zh.md: replaced the "remove --reload" workaround note with a description of the new default and the override flags.

Verification

$ uv run python -m pytest tests/test_server_main_reload.py tests/test_websocket_send_message_sync.py -v
...
16 passed in 22.07s
  • build_parser().print_help() renders the new --reload-dir / --reload-exclude options.
  • No change to the non---reload code path.
  • CI (Validate YAML Workflows) does not watch these paths, so it should stay green.

When ``python server_main.py --reload`` was used, uvicorn's default
reload_dirs is the current working directory and StatReload walks the
whole tree for ``*.py`` files. Agent-generated code under
``WareHouse/session_<uuid>/code_workspace/<file>.py`` therefore triggers
a server restart mid-workflow; the webui is left waiting indefinitely
and the in-flight session is cancelled.

The project already ships a warning in both READMEs telling users to
drop ``--reload``, but that is exactly the tool dev loops need.

Fix: pass an explicit ``reload_dirs`` list containing only the server's
Python source folders (check, entity, functions, mcp_example, runtime,
schema_registry, server, tools, utils, workflow) and a matching
``reload_excludes`` set (WareHouse, logs, data, temp, node_modules) so
watchfiles-backed installs also stop observing output directories.

Users can override either list via repeatable ``--reload-dir`` and
``--reload-exclude`` flags.

The reload-kwargs construction is extracted into a pure helper so the
behaviour is unit-tested without spinning up a real server; nine new
tests cover the default behaviour, user overrides, argparse wiring, and
that the returned lists are defensive copies.

README / README-zh have been updated to reflect the new default.

Fixes OpenBMB#569
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.

Workflow appears to trigger the server to restart leaving the webui waiting indefinitely

1 participant