Skip to content

Commit

Permalink
fix: remove a dynamically added tool from an assistant
Browse files Browse the repository at this point in the history
The tool is getting added to the block's tool list. So, it must also be
 removed from this list.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Aug 22, 2024
1 parent d7b8724 commit ef69d55
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ const mount = async (
runningScript = null;
}

const stateTools = (state.tools || []).filter((t) => t !== tool);
// find the root tool and then remove the tool
for (let block of script) {
if (block.type === 'tool') {
if (!block.tools) break;
const stateTools = (state.tools || []).filter((t) => t !== tool);
block.tools = [...new Set(block.tools, ...stateTools)];
block.tools = [...new Set(block.tools.filter((t) => t !== tool))];
break;
}
}
Expand All @@ -338,7 +338,7 @@ const mount = async (

opts.chatState = JSON.stringify(currentState);
state.chatState = JSON.stringify(currentState);
state.tools = state.tools.filter((t) => t !== tool);
state.tools = stateTools;

if (threadID) {
fs.writeFile(statePath, JSON.stringify(state), (err) => {
Expand Down

0 comments on commit ef69d55

Please sign in to comment.