Plan Phase 3 Space background workers#171
Open
akseljoonas wants to merge 2 commits intomainfrom
Open
Conversation
Document Phase 3 as a durable Mongo run queue plus a shared Hugging Face worker Space, so the next implementation can preserve browser reconnect semantics without binding agent execution to SSE lifetimes. Constraint: Mongo session persistence must be healthy before background workers can own execution. Rejected: One worker Space per session | shared workers are simpler to operate and Mongo leases already provide coordination. Confidence: high Scope-risk: narrow Directive: Keep browser/SSE as an observer; durable session_runs and workers should own execution in Phase 3. Tested: git diff --check Not-tested: Documentation-only change; no runtime tests run.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Add the Phase 3 foundation: Mongo-backed session_runs, an opt-in /api/chat enqueue path, Mongo-polled SSE replay, and a worker runtime that reuses the existing SessionManager and agent loop. The default remains the existing direct execution path until ML_INTERN_BACKGROUND_WORKERS is enabled. Constraint: External worker Spaces cannot safely execute user-scoped HF operations until token handoff is designed; in-process workers are the safe first rollout. Rejected: Persist raw user OAuth tokens in Mongo | broadens the trust boundary and should not be the default handoff mechanism. Rejected: Replay expired running tool calls | non-idempotent tools can duplicate side effects, so expired runs are marked interrupted. Confidence: medium Scope-risk: broad Directive: Keep ML_INTERN_BACKGROUND_WORKERS disabled until prod Mongo is healthy and the worker mode is smoke-tested. Tested: UV_CACHE_DIR=/tmp/uv-cache uv run --extra dev pytest tests/unit/test_session_persistence.py tests/unit/test_background_worker.py tests/unit/test_session_manager_persistence.py tests/unit/test_user_quotas.py -q Tested: UV_CACHE_DIR=/tmp/uv-cache uv run python -m py_compile agent/core/session_persistence.py backend/background_worker.py backend/worker_app.py backend/main.py backend/routes/agent.py backend/session_manager.py Tested: git diff --check Tested: import smoke for background_worker, worker_app, and main
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
closed per maintainer request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
session_runsqueue methods, indexes, claim/heartbeat/finish/interrupt-expired lifecycle/api/chatpath behindML_INTERN_BACKGROUND_WORKERSML_INTERN_PROCESS_ROLE=worker)Rollout notes
ML_INTERN_BACKGROUND_WORKERS=trueML_INTERN_BACKGROUND_WORKERS=true+ML_INTERN_RUN_WORKER_IN_PROCESS=trueTesting
UV_CACHE_DIR=/tmp/uv-cache uv run --extra dev pytest tests/unit/test_session_persistence.py tests/unit/test_background_worker.py tests/unit/test_session_manager_persistence.py tests/unit/test_user_quotas.py -qUV_CACHE_DIR=/tmp/uv-cache uv run python -m py_compile agent/core/session_persistence.py backend/background_worker.py backend/worker_app.py backend/main.py backend/routes/agent.py backend/session_manager.pygit diff --checkbackground_worker,worker_app, andmain