mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-04 14:52:12 +00:00
fix: Tracing issue where LLM calls were being traced outside of the main run (#375)
This commit is contained in:
parent
1756575b4c
commit
417c2e6650
1 changed files with 13 additions and 16 deletions
|
|
@ -14,7 +14,6 @@ import { getMessageString } from "../../../utils/message/content.js";
|
||||||
import { removeLastTaskMessages } from "../../../utils/message/modify-array.js";
|
import { removeLastTaskMessages } from "../../../utils/message/modify-array.js";
|
||||||
import { Command } from "@langchain/langgraph";
|
import { Command } from "@langchain/langgraph";
|
||||||
import { ConfigurableModel } from "langchain/chat_models/universal";
|
import { ConfigurableModel } from "langchain/chat_models/universal";
|
||||||
import { traceable } from "langsmith/traceable";
|
|
||||||
import {
|
import {
|
||||||
completePlanItem,
|
completePlanItem,
|
||||||
getActivePlanItems,
|
getActivePlanItems,
|
||||||
|
|
@ -90,7 +89,7 @@ const formatUserMessage = (
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function generateTaskSummaryFunc(
|
async function generateTaskSummary(
|
||||||
state: GraphState,
|
state: GraphState,
|
||||||
model: ConfigurableModel,
|
model: ConfigurableModel,
|
||||||
): Promise<{ planItemIndex: number; summary: string }> {
|
): Promise<{ planItemIndex: number; summary: string }> {
|
||||||
|
|
@ -101,16 +100,18 @@ async function generateTaskSummaryFunc(
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Summarizing task steps...`);
|
logger.info(`Summarizing task steps...`);
|
||||||
const response = await model.withConfig({ tags: ["nostream"] }).invoke([
|
const response = await model
|
||||||
{
|
.withConfig({ tags: ["nostream"], runName: "generate-task-summary" })
|
||||||
role: "system",
|
.invoke([
|
||||||
content: formatPrompt(activePlanItems),
|
{
|
||||||
},
|
role: "system",
|
||||||
{
|
content: formatPrompt(activePlanItems),
|
||||||
role: "user",
|
},
|
||||||
content: formatUserMessage(state.internalMessages, activePlanItems),
|
{
|
||||||
},
|
role: "user",
|
||||||
]);
|
content: formatUserMessage(state.internalMessages, activePlanItems),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
planItemIndex: lastCompletedTask.index,
|
planItemIndex: lastCompletedTask.index,
|
||||||
|
|
@ -118,10 +119,6 @@ async function generateTaskSummaryFunc(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateTaskSummary = traceable(generateTaskSummaryFunc, {
|
|
||||||
name: "generate-task-summary",
|
|
||||||
});
|
|
||||||
|
|
||||||
export async function summarizeTaskSteps(
|
export async function summarizeTaskSteps(
|
||||||
state: GraphState,
|
state: GraphState,
|
||||||
config: GraphConfig,
|
config: GraphConfig,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue