Merged
Conversation
When the same user submits the same prompt + model_profile within a configurable time window (default 60s, env PLANEXE_DEDUP_WINDOW_SECONDS), return the existing pending/processing plan instead of creating a new one. This prevents double-submissions from double-clicks, network retries, or agent re-attempts from consuming duplicate pipeline resources. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lumns The query now fetches only (id, timestamp_created, parameters) instead of full PlanItem objects. This avoids loading the prompt column (up to 4 GB) and any eagerly-loaded fields. Returns a lightweight dict instead of a PlanItem instance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document why the request_id approach was not adopted (LLMs cannot generate UUIDs natively) and describe the implemented server-side auto-dedup approach from PR #242. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Protects against runaway agents hammering plan_create with the same prompt overnight and draining credits. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
plan_create: if the same(user_id, prompt, model_profile)is submitted within a configurable time window (default 60s), returns the existingpending/processingplan withdeduplicated: trueinstead of creating a new onePLANEXE_DEDUP_WINDOW_SECONDSenv var (set to0to disable)Changes
mcp_cloud/db_queries.py: AddedDEDUP_WINDOW_SECONDSconstant and_find_recent_duplicate_plan()helper; modified_create_plan_syncto call it before INSERTmcp_cloud/tool_models.py: Addeddeduplicatedfield toPlanCreateOutputmcp_cloud/schemas.py: Updatedplan_createdescription and setidempotentHint: truemcp_cloud/app.py: Added_find_recent_duplicate_planto re-exportsmcp_cloud/tests/test_plan_create_tool.py: Added dedup and window=0 opt-out tests; updated existing test to patch dedup helperTest plan
python -m pytest mcp_cloud/tests/test_plan_create_tool.py -v(requires Docker)python -m pytest mcp_cloud/tests/ -vpython -m pyright mcp_cloud/plan_idwithdeduplicated: truePLANEXE_DEDUP_WINDOW_SECONDS=0→ dedup disabled, both calls create new plans🤖 Generated with Claude Code