fix: Dont fetch entire thread history

This commit is contained in:
bracesproul 2025-07-10 16:51:30 -07:00
parent ba38da81c3
commit 9fb80bbd6a
10 changed files with 58 additions and 14 deletions

View file

@ -89,7 +89,7 @@ Run these commands from the repository root:
```json
{
"resolutions": {
"@langchain/langgraph-sdk": "^0.0.85",
"@langchain/langgraph-sdk": "^0.0.92",
"@langchain/core": "^0.3.58"
}
}

View file

@ -28,7 +28,7 @@
"@langchain/core": "^0.3.56",
"@langchain/google-genai": "^0.2.9",
"@langchain/langgraph": "^0.3.3",
"@langchain/langgraph-sdk": "^0.0.85",
"@langchain/langgraph-sdk": "^0.0.92",
"@langchain/mcp-adapters": "^0.5.2",
"@langchain/openai": "^0.5.10",
"@mendable/firecrawl-js": "^1.29.1",

View file

@ -21,7 +21,7 @@
"dependencies": {
"@langchain/core": "^0.3.57",
"@langchain/langgraph": "^0.3.3",
"@langchain/langgraph-sdk": "^0.0.85",
"@langchain/langgraph-sdk": "^0.0.92",
"@octokit/app": "^16.0.1",
"@open-swe/shared": "*",
"@radix-ui/react-alert-dialog": "^1.1.14",

View file

@ -28,6 +28,7 @@ export default function ThreadPage({
assistantId: MANAGER_GRAPH_ID,
threadId: thread_id,
reconnectOnMount: true,
fetchStateHistory: false,
});
const { threads, threadsLoading } = useThreads<GraphState>(MANAGER_GRAPH_ID);

View file

@ -94,6 +94,35 @@ const isNewRunRequest = (reqUrlStr: string, reqMethod: string) => {
}
};
const isGetStateRequest = (reqUrlStr: string, reqMethod: string) => {
try {
const reqPathnameParts = new URL(reqUrlStr).pathname.split("/");
const isGetStateReq =
reqPathnameParts?.[1] === "api" &&
reqPathnameParts?.[2] === "threads" &&
validate(reqPathnameParts?.[3]) &&
reqPathnameParts?.[4] === "state";
reqMethod.toLowerCase() === "get";
return isGetStateReq;
} catch {
return false;
}
};
const isSearchThreadsRequest = (reqUrlStr: string, reqMethod: string) => {
try {
const reqPathnameParts = new URL(reqUrlStr).pathname.split("/");
const isGetStateReq =
reqPathnameParts?.[1] === "api" &&
reqPathnameParts?.[2] === "threads" &&
reqPathnameParts?.[3] === "search";
reqMethod.toLowerCase() === "get";
return isGetStateReq;
} catch {
return false;
}
};
async function getInstallationNameFromReq(
req: Request,
installationId: string,
@ -101,14 +130,23 @@ async function getInstallationNameFromReq(
try {
const requestJson = await req.json();
const installationName = requestJson?.input?.targetRepository?.owner;
return installationName;
if (installationName) {
return installationName;
}
} catch {
// no-op
}
try {
if (isNewRunRequest(req.url, req.method)) {
if (
isNewRunRequest(req.url, req.method) ||
isGetStateRequest(req.url, req.method) ||
isSearchThreadsRequest(req.url, req.method)
) {
console.log("Trying to get installation name from request");
return await getInstallationName(installationId);
} else {
console.log("is not a new run req", req.url);
}
return "";
} catch {

View file

@ -119,6 +119,7 @@ export function ActionsRenderer<State extends PlannerGraphState | GraphState>({
setCustomNodeEvents((prev) => [...prev, event]);
}
},
fetchStateHistory: false,
});
const { cancelRun } = useCancelStream<State>({

View file

@ -57,6 +57,7 @@ export function TerminalInput({
apiUrl,
assistantId,
reconnectOnMount: true,
fetchStateHistory: false,
});
const handleSend = async () => {

View file

@ -20,7 +20,7 @@
"typescript": "^5"
},
"resolutions": {
"@langchain/langgraph-sdk": "^0.0.85",
"@langchain/langgraph-sdk": "^0.0.92",
"@langchain/core": "^0.3.58"
},
"packageManager": "yarn@3.5.1"

View file

@ -19,7 +19,7 @@
"dependencies": {
"@langchain/core": "^0.3.56",
"@langchain/langgraph": "^0.3.3",
"@langchain/langgraph-sdk": "^0.0.85",
"@langchain/langgraph-sdk": "^0.0.92",
"@octokit/rest": "^22.0.0",
"zod": "^3.25.32"
},

View file

@ -2556,9 +2556,9 @@ __metadata:
languageName: node
linkType: hard
"@langchain/langgraph-sdk@npm:^0.0.85":
version: 0.0.85
resolution: "@langchain/langgraph-sdk@npm:0.0.85"
"@langchain/langgraph-sdk@npm:^0.0.92":
version: 0.0.92
resolution: "@langchain/langgraph-sdk@npm:0.0.92"
dependencies:
"@types/json-schema": ^7.0.15
p-queue: ^6.6.2
@ -2567,12 +2567,15 @@ __metadata:
peerDependencies:
"@langchain/core": ">=0.2.31 <0.4.0"
react: ^18 || ^19
react-dom: ^18 || ^19
peerDependenciesMeta:
"@langchain/core":
optional: true
react:
optional: true
checksum: f6d206c718cf4cb5d69dd677f2afa38325fdd69b485310a6beb61f06f24b2b4a8c0446eacbe7911c02cedc8bd4b719e22894c6f9b93572e6665c6a609cc9f511
react-dom:
optional: true
checksum: 905380f0785da27dd5638b37e6215f3f2655cd0cb9111f6178e4b72085e930f1e250dfbfa6bb3b0ce4b7dc7f129f988095fac2240b420c09f63d65c3a8d5b8d6
languageName: node
linkType: hard
@ -3457,7 +3460,7 @@ __metadata:
"@langchain/google-genai": ^0.2.9
"@langchain/langgraph": ^0.3.3
"@langchain/langgraph-cli": latest
"@langchain/langgraph-sdk": ^0.0.85
"@langchain/langgraph-sdk": ^0.0.92
"@langchain/mcp-adapters": ^0.5.2
"@langchain/openai": ^0.5.10
"@mendable/firecrawl-js": ^1.29.1
@ -3506,7 +3509,7 @@ __metadata:
"@eslint/js": ^9.19.0
"@langchain/core": ^0.3.56
"@langchain/langgraph": ^0.3.3
"@langchain/langgraph-sdk": ^0.0.85
"@langchain/langgraph-sdk": ^0.0.92
"@octokit/rest": ^22.0.0
"@octokit/types": ^12.0.0
"@tsconfig/recommended": ^1.0.8
@ -3531,7 +3534,7 @@ __metadata:
"@eslint/js": ^9.19.0
"@langchain/core": ^0.3.57
"@langchain/langgraph": ^0.3.3
"@langchain/langgraph-sdk": ^0.0.85
"@langchain/langgraph-sdk": ^0.0.92
"@octokit/app": ^16.0.1
"@octokit/types": ^14.1.0
"@open-swe/shared": "*"