Repository navigation
Conversation
The CLI's fail-fast profile-lease default (GFLOW_CLI_LEASE_WAIT_SECONDS=0) is right for a one-shot terminal command a human can just retry. The MCP server has no human in that loop: two tool calls landing close together on the same profile (a client retry, two agents sharing a profile) would otherwise hard-fail with ProfileLockedError instead of simply running after the call already in flight finishes. All three MCP entry points (stdio/http/sse) now set a 180s wait default via os.environ.setdefault before anything touches Settings (cached via lru_cache) -- long enough to outlast a typical single generation, and a no-op for anyone who has already set the var themselves. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Hyeonwoo Jo <icecream430909@gmail.com>
|
Thanks for the contribution. This PR has been marked as an external contribution and routed for maintainer review. Before merge, please make sure:
GitHub Copilot code review may be requested as an advisory first pass, but maintainer approval is still required. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe MCP server now applies a 180-second lease-wait default when the environment variable is unset. Stdio, HTTP, and SSE entry points apply the default before setup. Explicit values remain unchanged. ChangesMCP lease-wait configuration
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The default wait behavior is applied consistently while preserving operator overrides; no actionable merge risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Thank you @iceblue03 — the goal here is right: an MCP caller has nobody to retry for it, so contention should wait rather than fail. We're taking this over together with #863, tracked in #864, and shipping both in one release. Two findings from verifying it, detailed in #864:
You'll be credited in the changelog, and we'll ping you when it ships. |
|
Shipped in v0.78.0 — thank you, and sorry for the wait. Your diagnosis was right and the goal was right: an MCP caller has nobody to retry a
Credited in the changelog. Closing in favour of #868. |
|
Superseded by #868, shipped in v0.78.0. Your idea and the credit are in the changelog. |
|
Superseded by #868 — thanks for taking this further and fixing the settings-cache-timing and same-process-contention issues I missed. Closing. |
Summary
The CLI's fail-fast profile-lease default (
GFLOW_CLI_LEASE_WAIT_SECONDS=0) is right for a one-shot terminal command a human can just retry. The MCP server has no human in that loop: two tool calls landing close together on the same profile (a client retry, two agents sharing a profile) currently hard-fail withProfileLockedErrorinstead of the second call simply running after the one already in flight finishes.This adds
_apply_mcp_lease_wait_default(), called first thing in all three MCP entry points (run_stdio/run_http/run_sse), before anything touchesSettings(which is@lru_cached). It setsGFLOW_CLI_LEASE_WAIT_SECONDS=180viaos.environ.setdefault— long enough to outlast a typical single image/video generation, and a complete no-op for any operator who has already set the var themselves (including explicitly back to0for fail-fast).The underlying wait mechanism itself (
profile_lease.py, #478/#503) is untouched — this only changes which default the MCP surface starts from.Lifecycle
issue-assessment— no issue filed; this is a self-contained reliability gap noticed while exercising the MCP tools directly (concurrentgflow_*calls against the same profile).predictverdict — not applicable; no transport/auth/selector/schema surface changes, only an env-var default at the MCP process entry points.scenario+plan— skipped for a change this narrow (one function, three call sites); happy to write these up if a maintainer wants the full artifact trail before merge.check(scoped) —ruff check,ruff format --check, andpyrightall pass clean on the two touched files. I did not run the full repo-wide hygiene/doc-link/coverage suite from a fork checkout.GFLOW_CLI_LEASE_WAIT_SECONDSalready exists to let either surface override.ProfileLease, not a Flow DOM/network surface, so nothing undertests/e2e/exercises it directly. Coverage is two new focused unit tests intests/mcp/test_server.py::TestMcpLeaseWaitDefault(default applies when unset; an explicit value, including0, is never overridden), plus the three existing entry-point tests updated to patch the new call.56 passedlocally.gflow_*MCP tools back-to-back against one profile in a live session (character/instructions/credits calls fired close together), none hitProfileLockedError.pr-council-reviewand I'll address findings.Validation
TestMcpLeaseWaitDefault, 2 new tests)GFLOW_CLI_LEASE_WAIT_SECONDSitself is already documented)uv run python scripts/ci/check_doc_links.py— not run (no docs touched)uv run ruff check src tests(scoped to the 2 changed files)uv run pyright src(scoped tosrc/gflow_cli/mcp/server.py)uv run pytest -q tests/mcp/test_server.py→56 passedContribution Checklist
developSigned-off-by:(git commit -s)🤖 Generated with Claude Code
Summary by CodeRabbit
0, are preserved.