fix: make toolset switching atomic to prevent tool desync race (#648)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -8,7 +8,10 @@ import type {
|
||||
ApprovalCreate,
|
||||
LettaStreamingResponse,
|
||||
} from "@letta-ai/letta-client/resources/agents/messages";
|
||||
import { getClientToolsFromRegistry } from "../tools/manager";
|
||||
import {
|
||||
getClientToolsFromRegistry,
|
||||
waitForToolsetReady,
|
||||
} from "../tools/manager";
|
||||
import { isTimingsEnabled } from "../utils/timing";
|
||||
import { getClient } from "./client";
|
||||
|
||||
@@ -42,6 +45,10 @@ export async function sendMessageStream(
|
||||
|
||||
const client = await getClient();
|
||||
|
||||
// Wait for any in-progress toolset switch to complete before reading tools
|
||||
// This prevents sending messages with stale tools during a switch
|
||||
await waitForToolsetReady();
|
||||
|
||||
let stream: Stream<LettaStreamingResponse>;
|
||||
|
||||
if (process.env.DEBUG) {
|
||||
|
||||
Reference in New Issue
Block a user