fix: harden scenario/optimizer tools for AI agent reliability#3
Merged
nialloulton merged 1 commit intomainfrom Apr 6, 2026
Merged
fix: harden scenario/optimizer tools for AI agent reliability#3nialloulton merged 1 commit intomainfrom
nialloulton merged 1 commit intomainfrom
Conversation
Made-with: Cursor
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
rebuild_model=Trueinrun_scenario— the model graph is never available after S3 load, so prediction always requires rebuildingrun_optimizerdocstring: document channel naming requirements, bounds format (percentages), CPM discovery from templateget_scenario_templatedocstring: emphasize it as a required pre-step for both optimizer and scenario toolsrun_scenariopolling requirement (must callget_scenario_resultsafter)Context
An AI agent test revealed that the core upload-fit-results workflow works end-to-end, but optimizer and scenario tools fail due to:
rebuild_model=False, but PyMC model is not loaded from S3)Test plan
rebuild_model: trueby defaultMade with Cursor
Note
Medium Risk
Behavior changes by defaulting
run_scenarioto rebuild the model graph, which can impact performance and could alter scenario execution in existing clients. Other changes are docstring-only but affect how agents/clients construct optimizer/scenario payloads.Overview
Hardens MCP scenario/optimizer tools for agent reliability.
run_scenarionow defaultsrebuild_model=Trueand only includes therebuild_modelflag in the API payload when enabled.Documentation for
run_optimizerandget_scenario_templateis expanded to makeget_scenario_templatethe required first step and to spell out exact channel-key matching requirements, bounds-as-percentages format, period array length constraints, and CPM discovery;run_scenariodocs now explicitly require pollingget_scenario_resultsand clarify expectedscenario_data/spend_metadatashapes.Reviewed by Cursor Bugbot for commit 380fde4. Bugbot is set up for automated code reviews on this repo. Configure here.