fix: async plan isolation, blocking API call, and CORS for production#205
Open
angziii wants to merge 1 commit intohuggingface:mainfrom
Open
fix: async plan isolation, blocking API call, and CORS for production#205angziii wants to merge 1 commit intohuggingface:mainfrom
angziii wants to merge 1 commit intohuggingface:mainfrom
Conversation
- plan_tool.py: Replace module-level _current_plan list with per-session _session_plans dict to prevent cross-session plan corruption when multiple concurrent sessions use the plan tool. - hf_repo_git_tool.py: Wrap get_repo_discussions in _async_call to avoid blocking the event loop with a synchronous HTTP request. - backend/main.py: Add SPACE_HOST env var to CORS allow_origins so the production HF Spaces frontend is not rejected by the middleware. - terminal_display.py / main.py: Thread session through plan display functions for session-aware plan retrieval.
|
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
Three targeted fixes:
plan_tool.py: Per-session plan isolation — The module-level
_current_planlist was shared across all sessions, causing concurrent sessions to overwrite each other's plans. Replaced with a per-session dict keyed bysession_id. Updatedget_current_plan(),format_plan_display(), andprint_plan()to be session-aware.hf_repo_git_tool.py: Async wrapper for
get_repo_discussions— Every otherHfApicall in this file uses_async_call()to run in a thread pool, butget_repo_discussionswas called synchronously, blocking the event loop during the HTTP request. Wrapped it in_async_call()with the list materialized inside the thread.backend/main.py: CORS origins for production —
allow_originswas hardcoded to localhost-only, causing CORS middleware to reject browser requests when deployed to HF Spaces. AddedSPACE_HOSTenv var to the allow list dynamically.Test plan
get_repo_discussionsno longer blocks the event loopSPACE_HOSTis set