Add Tool Call Recurse Limit slider to Chat Completion settings (#5518) * feat: add Tool Call Recurse Limit slider to Chat/Message Handling settings Agent-Logs-Url: https://github.com/SillyTavern/SillyTavern/sessions/ecbde89f-8f4d-4e91-9189-a998d12ca76b Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com> * feat: move tool call recurse limit to openai_settings under Chat Completion settings Agent-Logs-Url: https://github.com/SillyTavern/SillyTavern/sessions/132e4c28-9564-47cd-92c1-e8ab50d88905 Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com> * refactor: use CSS :has() selector instead of JS toggle for tool_call_recurse_limit_block visibility Agent-Logs-Url: https://github.com/SillyTavern/SillyTavern/sessions/c562deb5-05ce-4ebf-84a0-9eeea9d24433 Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com> * fix: wrap tool_call_recurse_limit_block in range-block for correct layout Agent-Logs-Url: https://github.com/SillyTavern/SillyTavern/sessions/4d25a367-ac12-4e54-83b0-1543eb6f370a Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com> * fix: data-i18n attribute --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>

7948886c1d6577ee771aab694847e3dfb3c85980

Copilot <198982749+Copilot@users.noreply.github.com>

Signed
4 files changed, +28 -14Showing whitespace changes
package-lock.json+0 -14
@@ -549,7 +549,6 @@
549 "resolved": "https://registry.npmjs.org/@jimp/custom/-/custom-0.22.12.tgz",549 "resolved": "https://registry.npmjs.org/@jimp/custom/-/custom-0.22.12.tgz",
550 "integrity": "sha512-xcmww1O/JFP2MrlGUMd3Q78S3Qu6W3mYTXYuIqFq33EorgYHV/HqymHfXy9GjiCJ7OI+7lWx6nYFOzU7M4rd1Q==",550 "integrity": "sha512-xcmww1O/JFP2MrlGUMd3Q78S3Qu6W3mYTXYuIqFq33EorgYHV/HqymHfXy9GjiCJ7OI+7lWx6nYFOzU7M4rd1Q==",
551 "license": "MIT",551 "license": "MIT",
552 "peer": true,
553 "dependencies": {552 "dependencies": {
554 "@jimp/core": "^0.22.12"553 "@jimp/core": "^0.22.12"
555 }554 }
@@ -1011,7 +1010,6 @@
1011 "resolved": "https://registry.npmjs.org/@jimp/plugin-resize/-/plugin-resize-1.6.0.tgz",1010 "resolved": "https://registry.npmjs.org/@jimp/plugin-resize/-/plugin-resize-1.6.0.tgz",
1012 "integrity": "sha512-uSUD1mqXN9i1SGSz5ov3keRZ7S9L32/mAQG08wUwZiEi5FpbV0K8A8l1zkazAIZi9IJzLlTauRNU41Mi8IF9fA==",1011 "integrity": "sha512-uSUD1mqXN9i1SGSz5ov3keRZ7S9L32/mAQG08wUwZiEi5FpbV0K8A8l1zkazAIZi9IJzLlTauRNU41Mi8IF9fA==",
1013 "license": "MIT",1012 "license": "MIT",
1014 "peer": true,
1015 "dependencies": {1013 "dependencies": {
1016 "@jimp/core": "1.6.0",1014 "@jimp/core": "1.6.0",
1017 "@jimp/types": "1.6.0",1015 "@jimp/types": "1.6.0",
@@ -1043,7 +1041,6 @@
1043 "resolved": "https://registry.npmjs.org/@jimp/plugin-scale/-/plugin-scale-0.22.12.tgz",1041 "resolved": "https://registry.npmjs.org/@jimp/plugin-scale/-/plugin-scale-0.22.12.tgz",
1044 "integrity": "sha512-dghs92qM6MhHj0HrV2qAwKPMklQtjNpoYgAB94ysYpsXslhRTiPisueSIELRwZGEr0J0VUxpUY7HgJwlSIgGZw==",1042 "integrity": "sha512-dghs92qM6MhHj0HrV2qAwKPMklQtjNpoYgAB94ysYpsXslhRTiPisueSIELRwZGEr0J0VUxpUY7HgJwlSIgGZw==",
1045 "license": "MIT",1043 "license": "MIT",
1046 "peer": true,
1047 "dependencies": {1044 "dependencies": {
1048 "@jimp/utils": "^0.22.12"1045 "@jimp/utils": "^0.22.12"
1049 },1046 },
@@ -1139,7 +1136,6 @@
1139 "resolved": "https://registry.npmjs.org/@jimp/plugin-blit/-/plugin-blit-0.22.12.tgz",1136 "resolved": "https://registry.npmjs.org/@jimp/plugin-blit/-/plugin-blit-0.22.12.tgz",
1140 "integrity": "sha512-xslz2ZoFZOPLY8EZ4dC29m168BtDx95D6K80TzgUi8gqT7LY6CsajWO0FAxDwHz6h0eomHMfyGX0stspBrTKnQ==",1137 "integrity": "sha512-xslz2ZoFZOPLY8EZ4dC29m168BtDx95D6K80TzgUi8gqT7LY6CsajWO0FAxDwHz6h0eomHMfyGX0stspBrTKnQ==",
1141 "license": "MIT",1138 "license": "MIT",
1142 "peer": true,
1143 "dependencies": {1139 "dependencies": {
1144 "@jimp/utils": "^0.22.12"1140 "@jimp/utils": "^0.22.12"
1145 },1141 },
@@ -1176,7 +1172,6 @@
1176 "resolved": "https://registry.npmjs.org/@jimp/plugin-color/-/plugin-color-0.22.12.tgz",1172 "resolved": "https://registry.npmjs.org/@jimp/plugin-color/-/plugin-color-0.22.12.tgz",
1177 "integrity": "sha512-xImhTE5BpS8xa+mAN6j4sMRWaUgUDLoaGHhJhpC+r7SKKErYDR0WQV4yCE4gP+N0gozD0F3Ka1LUSaMXrn7ZIA==",1173 "integrity": "sha512-xImhTE5BpS8xa+mAN6j4sMRWaUgUDLoaGHhJhpC+r7SKKErYDR0WQV4yCE4gP+N0gozD0F3Ka1LUSaMXrn7ZIA==",
1178 "license": "MIT",1174 "license": "MIT",
1179 "peer": true,
1180 "dependencies": {1175 "dependencies": {
1181 "@jimp/utils": "^0.22.12",1176 "@jimp/utils": "^0.22.12",
1182 "tinycolor2": "^1.6.0"1177 "tinycolor2": "^1.6.0"
@@ -1220,7 +1215,6 @@
1220 "resolved": "https://registry.npmjs.org/@jimp/plugin-crop/-/plugin-crop-0.22.12.tgz",1215 "resolved": "https://registry.npmjs.org/@jimp/plugin-crop/-/plugin-crop-0.22.12.tgz",
1221 "integrity": "sha512-FNuUN0OVzRCozx8XSgP9MyLGMxNHHJMFt+LJuFjn1mu3k0VQxrzqbN06yIl46TVejhyAhcq5gLzqmSCHvlcBVw==",1216 "integrity": "sha512-FNuUN0OVzRCozx8XSgP9MyLGMxNHHJMFt+LJuFjn1mu3k0VQxrzqbN06yIl46TVejhyAhcq5gLzqmSCHvlcBVw==",
1222 "license": "MIT",1217 "license": "MIT",
1223 "peer": true,
1224 "dependencies": {1218 "dependencies": {
1225 "@jimp/utils": "^0.22.12"1219 "@jimp/utils": "^0.22.12"
1226 },1220 },
@@ -1308,7 +1302,6 @@
1308 "resolved": "https://registry.npmjs.org/@jimp/plugin-resize/-/plugin-resize-0.22.12.tgz",1302 "resolved": "https://registry.npmjs.org/@jimp/plugin-resize/-/plugin-resize-0.22.12.tgz",
1309 "integrity": "sha512-3NyTPlPbTnGKDIbaBgQ3HbE6wXbAlFfxHVERmrbqAi8R3r6fQPxpCauA8UVDnieg5eo04D0T8nnnNIX//i/sXg==",1303 "integrity": "sha512-3NyTPlPbTnGKDIbaBgQ3HbE6wXbAlFfxHVERmrbqAi8R3r6fQPxpCauA8UVDnieg5eo04D0T8nnnNIX//i/sXg==",
1310 "license": "MIT",1304 "license": "MIT",
1311 "peer": true,
1312 "dependencies": {1305 "dependencies": {
1313 "@jimp/utils": "^0.22.12"1306 "@jimp/utils": "^0.22.12"
1314 },1307 },
@@ -1321,7 +1314,6 @@
1321 "resolved": "https://registry.npmjs.org/@jimp/plugin-rotate/-/plugin-rotate-0.22.12.tgz",1314 "resolved": "https://registry.npmjs.org/@jimp/plugin-rotate/-/plugin-rotate-0.22.12.tgz",
1322 "integrity": "sha512-9YNEt7BPAFfTls2FGfKBVgwwLUuKqy+E8bDGGEsOqHtbuhbshVGxN2WMZaD4gh5IDWvR+emmmPPWGgaYNYt1gA==",1315 "integrity": "sha512-9YNEt7BPAFfTls2FGfKBVgwwLUuKqy+E8bDGGEsOqHtbuhbshVGxN2WMZaD4gh5IDWvR+emmmPPWGgaYNYt1gA==",
1323 "license": "MIT",1316 "license": "MIT",
1324 "peer": true,
1325 "dependencies": {1317 "dependencies": {
1326 "@jimp/utils": "^0.22.12"1318 "@jimp/utils": "^0.22.12"
1327 },1319 },
@@ -1922,7 +1914,6 @@
1922 "integrity": "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ==",1914 "integrity": "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ==",
1923 "dev": true,1915 "dev": true,
1924 "license": "MIT",1916 "license": "MIT",
1925 "peer": true,
1926 "dependencies": {1917 "dependencies": {
1927 "@types/body-parser": "*",1918 "@types/body-parser": "*",
1928 "@types/express-serve-static-core": "^4.17.33",1919 "@types/express-serve-static-core": "^4.17.33",
@@ -2612,7 +2603,6 @@
2612 "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",2603 "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
2613 "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",2604 "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
2614 "license": "MIT",2605 "license": "MIT",
2615 "peer": true,
2616 "bin": {2606 "bin": {
2617 "acorn": "bin/acorn"2607 "acorn": "bin/acorn"
2618 },2608 },
@@ -3232,7 +3222,6 @@
3232 }3222 }
3233 ],3223 ],
3234 "license": "MIT",3224 "license": "MIT",
3235 "peer": true,
3236 "dependencies": {3225 "dependencies": {
3237 "baseline-browser-mapping": "^2.9.0",3226 "baseline-browser-mapping": "^2.9.0",
3238 "caniuse-lite": "^1.0.30001759",3227 "caniuse-lite": "^1.0.30001759",
@@ -4567,7 +4556,6 @@
4567 "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",4556 "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
4568 "dev": true,4557 "dev": true,
4569 "license": "MIT",4558 "license": "MIT",
4570 "peer": true,
4571 "dependencies": {4559 "dependencies": {
4572 "@eslint-community/eslint-utils": "^4.2.0",4560 "@eslint-community/eslint-utils": "^4.2.0",
4573 "@eslint-community/regexpp": "^4.6.1",4561 "@eslint-community/regexpp": "^4.6.1",
@@ -8125,7 +8113,6 @@
8125 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz",8113 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz",
8126 "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==",8114 "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==",
8127 "license": "MIT",8115 "license": "MIT",
8128 "peer": true,
8129 "dependencies": {8116 "dependencies": {
8130 "fast-deep-equal": "^3.1.3",8117 "fast-deep-equal": "^3.1.3",
8131 "fast-uri": "^3.0.1",8118 "fast-uri": "^3.0.1",
@@ -9143,7 +9130,6 @@
9143 "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",9130 "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
9144 "dev": true,9131 "dev": true,
9145 "license": "Apache-2.0",9132 "license": "Apache-2.0",
9146 "peer": true,
9147 "bin": {9133 "bin": {
9148 "tsc": "bin/tsc",9134 "tsc": "bin/tsc",
9149 "tsserver": "bin/tsserver"9135 "tsserver": "bin/tsserver"
public/css/toggle-dependent.css+4 -0
@@ -565,6 +565,10 @@ label[for="bind_preset_to_connection"]:has(input:checked) {
565 display: none;565 display: none;
566}566}
567567
568#openai_settings:has(#openai_function_calling:not(:checked)) #tool_call_recurse_limit_block {
569 display: none;
570}
571
568#adaptive_p_block:has([data-tg-samplers="adaptive_target"][style*="display: none"]):has([data-tg-samplers="adaptive_decay"][style*="display: none"]) {572#adaptive_p_block:has([data-tg-samplers="adaptive_target"][style*="display: none"]):has([data-tg-samplers="adaptive_decay"][style*="display: none"]) {
569 display: none;573 display: none;
570}574}
public/index.html+14 -0
@@ -2011,6 +2011,20 @@
2011 <span data-i18n="enable_functions_desc_3">Can be utilized by various extensions to provide additional functionality.</span>2011 <span data-i18n="enable_functions_desc_3">Can be utilized by various extensions to provide additional functionality.</span>
2012 <strong data-i18n="enable_functions_desc_4">Not supported when Prompt Post-Processing with "no tools" is used!</strong>2012 <strong data-i18n="enable_functions_desc_4">Not supported when Prompt Post-Processing with "no tools" is used!</strong>
2013 </div>2013 </div>
2014 <div id="tool_call_recurse_limit_block" class="range-block wide100p">
2015 <div class="range-block-title">
2016 <small data-i18n="Tool Call Recurse Limit">Tool Call Recurse Limit</small>
2017 <div class="fa-solid fa-circle-info opacity50p margin5" data-i18n="[title]Maximum number of tool call recursion steps per generation." title="Maximum number of tool call recursion steps per generation."></div>
2018 </div>
2019 <div class="range-block-range-and-counter">
2020 <div class="range-block-range">
2021 <input type="range" id="tool_call_recurse_limit" name="tool_call_recurse_limit" min="1" max="50" step="1">
2022 </div>
2023 <div class="range-block-counter">
2024 <input type="number" min="1" max="50" step="1" data-for="tool_call_recurse_limit" id="tool_call_recurse_limit_counter">
2025 </div>
2026 </div>
2027 </div>
2014 </div>2028 </div>
2015 <div class="range-block" data-source="openrouter,custom">2029 <div class="range-block" data-source="openrouter,custom">
2016 <div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10">2030 <div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10">
public/scripts/openai.js+10 -0
@@ -383,6 +383,7 @@ export const settingsToUpdate = {
383 continue_prefill: ['#continue_prefill', 'continue_prefill', true, false],383 continue_prefill: ['#continue_prefill', 'continue_prefill', true, false],
384 continue_postfix: ['#continue_postfix', 'continue_postfix', false, false],384 continue_postfix: ['#continue_postfix', 'continue_postfix', false, false],
385 function_calling: ['#openai_function_calling', 'function_calling', true, false],385 function_calling: ['#openai_function_calling', 'function_calling', true, false],
386 tool_call_recurse_limit: ['#tool_call_recurse_limit', 'tool_call_recurse_limit', false, false],
386 show_thoughts: ['#openai_show_thoughts', 'show_thoughts', true, false],387 show_thoughts: ['#openai_show_thoughts', 'show_thoughts', true, false],
387 reasoning_effort: ['#openai_reasoning_effort', 'reasoning_effort', false, false],388 reasoning_effort: ['#openai_reasoning_effort', 'reasoning_effort', false, false],
388 verbosity: ['#openai_verbosity', 'verbosity', false, false],389 verbosity: ['#openai_verbosity', 'verbosity', false, false],
@@ -492,6 +493,7 @@ const default_settings = {
492 bypass_status_check: false,493 bypass_status_check: false,
493 continue_prefill: false,494 continue_prefill: false,
494 function_calling: false,495 function_calling: false,
496 tool_call_recurse_limit: 5,
495 names_behavior: character_names_behavior.DEFAULT,497 names_behavior: character_names_behavior.DEFAULT,
496 continue_postfix: continue_postfix_types.SPACE,498 continue_postfix: continue_postfix_types.SPACE,
497 custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,499 custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
@@ -4224,6 +4226,7 @@ function loadOpenAISettings(data, settings) {
4224 setNamesBehaviorControls();4226 setNamesBehaviorControls();
4225 setContinuePostfixControls();4227 setContinuePostfixControls();
4226 setToolReasoningControls();4228 setToolReasoningControls();
4229 ToolManager.RECURSE_LIMIT = oai_settings.tool_call_recurse_limit;
42274230
4228 $('#openrouter_providers_chat').trigger('change');4231 $('#openrouter_providers_chat').trigger('change');
4229 $('#openrouter_quantizations_chat').trigger('change');4232 $('#openrouter_quantizations_chat').trigger('change');
@@ -6826,6 +6829,13 @@ export function initOpenAI() {
6826 saveSettingsDebounced();6829 saveSettingsDebounced();
6827 });6830 });
68286831
6832 $('#tool_call_recurse_limit').on('input', function () {
6833 oai_settings.tool_call_recurse_limit = Number($(this).val());
6834 $('#tool_call_recurse_limit_counter').val(oai_settings.tool_call_recurse_limit);
6835 ToolManager.RECURSE_LIMIT = oai_settings.tool_call_recurse_limit;
6836 saveSettingsDebounced();
6837 });
6838
6829 $('#tool_reasoning_mode').on('input', function () {6839 $('#tool_reasoning_mode').on('input', function () {
6830 oai_settings.tool_reasoning_mode = getToolReasoningMode({6840 oai_settings.tool_reasoning_mode = getToolReasoningMode({
6831 ...oai_settings,6841 ...oai_settings,