open-swe/apps/open-swe-v2/src/agent.ts

22 lines
855 B
TypeScript
Raw Normal View History

import "@langchain/langgraph/zod";
import { createDeepAgent } from "deepagents";
import { codeReviewerAgent, testGeneratorAgent } from "./subagents.js";
import { getCodingInstructions } from "./prompts.js";
import { createAgentPostModelHook } from "./post-model-hook.js";
import { CodingAgentState } from "./state.js";
import { executeBash, httpRequest, webSearch } from "./tools.js";
const codingInstructions = getCodingInstructions();
const postModelHook = createAgentPostModelHook();
const agent = createDeepAgent({
tools: [executeBash, httpRequest, webSearch],
instructions: codingInstructions,
subagents: [codeReviewerAgent, testGeneratorAgent],
isLocalFileSystem: true,
postModelHook: postModelHook,
stateSchema: CodingAgentState,
}).withConfig({ recursionLimit: 1000 }) as any;
export { agent, executeBash, httpRequest, webSearch };