Quantago: Strategy Parameter Deletion + Comparison Tool
Summary
This update fixes strategy-parameter deletion behavior in bot chat flows, adds explicit replace/delete semantics for parameter updates, and introduces a new AI tool named parameter_comparison_check that compares schema-defined parameters against what strategy code actually reads.
What Changed
1. update_bot_parameters now supports deletion and replacement
File: services/backend/src/routes/bots/bots-chat-handlers.ts
- Added optional
modeargument:merge(default): patch existing parametersreplace: start from an empty object, then apply provided parameters
- Added optional
removeKeys: string[]to explicitly delete parameter keys. - Updated runtime behavior to apply updates via a shared mutation helper (
applyParameterMutation). - Return payload now includes:
moderemovedKeysstrategyVersionstrategySnapshotId
Reasoning:
- Previous behavior was merge-only (
{ ...current, ...patch }), which made deletions impossible and caused AI chat to report cleanup without real removal.
2. New tool: parameter_comparison_check
File: services/backend/src/routes/bots/bots-chat-handlers.ts
- Added new read-only tool definition:
parameter_comparison_check. - Added execution branch in
runToolthat computes:definedkeys fromparameter_schema.propertiesusedInCodekeys by static extraction fromcode_text(input.parameters.*, bracket access, aliases, destructuring)- default keys from strategy params/default config
- Returns:
summarycountsonlyDefinedandonlyUsedcomparisonRowssuitable for rendering a user-facing comparison table
Reasoning:
- AI needs a deterministic way to audit mismatches between declared parameters and actual runtime usage before mutating config.
3. update_strategy_parameter_schema now supports delete/replace semantics
File: services/backend/src/routes/bots/bots-chat-handlers.ts
- Added optional arguments:
defaultConfigMode: 'merge' | 'replace'removeDefaultConfigKeys: string[]
- Replaced merge-only defaults update with
applyParameterMutation. - Ensured live-branch persistence and runtime notify paths use the same mutation semantics.
- Included
defaultConfigMode+ removed keys in activity changes and response payload.
Reasoning:
- Removing/cleaning strategy defaults previously left stale keys in place.
4. Prompt updates so AI uses the new tool correctly
Files:
-
services/backend/src/routes/bots/prompts/core.ts -
services/backend/src/routes/bots/prompts/strategy.ts -
Documented new tool and new delete/replace arguments.
-
Added explicit workflow guidance:
- call
parameter_comparison_checkbefore parameter/schema mutations - present comparison as a table
- confirm resulting version/branch after save
- call
5. Test coverage updates
File: services/backend/tests/bot-chat-tools.test.ts
- Updated
update_bot_parametersassertions for new response fields. - Added explicit test for replace/delete behavior.
- Added test case for
parameter_comparison_check. - Added missing tool coverage case for
check_candle_data_availabilityso tool-suite coverage remains complete.
Validation
Executed successfully:
pnpm typecheck(repo root)pnpm test:tools(backend)
Executed with pre-existing warnings (not introduced by this change):
pnpm lint(repo root)
Key Snippet
const mode = args.mode === 'replace' ? 'replace' : 'merge';
const removeKeys = Array.isArray(args.removeKeys)
? args.removeKeys.map((key) => String(key).trim()).filter(Boolean)
: [];
const next = applyParameterMutation(current, (args.parameters as Record<string, unknown>) ?? {}, mode, removeKeys);
This is the core fix enabling true delete/update/replace behavior for strategy parameters from AI chat.