-
Notifications
You must be signed in to change notification settings - Fork 0
Open swe/a9cd0eb9 3172 4fe8 a64c 5ef191d4b266 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d679b92
78b1b41
3fd6139
a579aa5
cf449fe
92f31f5
9c94f1a
ec960dc
595b993
ad76493
5268ea9
b32e1ed
a6e4a33
8801574
fc1f664
1033def
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,21 +2,21 @@ import { tool } from "@langchain/core/tools"; | |||||||||||||||||||||||||||
| import { createLogger, LogLevel } from "../utils/logger.js"; | ||||||||||||||||||||||||||||
| import { createGetURLContentToolFields } from "@open-swe/shared/open-swe/tools"; | ||||||||||||||||||||||||||||
| import { FireCrawlLoader } from "@langchain/community/document_loaders/web/firecrawl"; | ||||||||||||||||||||||||||||
| import { GraphState } from "@open-swe/shared/open-swe/types"; | ||||||||||||||||||||||||||||
| import { parseUrl } from "../utils/url-parser.js"; | ||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||
| getDocumentFromCache, | ||||||||||||||||||||||||||||
| saveDocumentToCache, | ||||||||||||||||||||||||||||
| } from "../utils/http-db-client.js"; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const logger = createLogger(LogLevel.INFO, "GetURLContentTool"); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export function createGetURLContentTool( | ||||||||||||||||||||||||||||
| state: Pick<GraphState, "documentCache">, | ||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||
| export function createGetURLContentTool(runId: string) { | ||||||||||||||||||||||||||||
| const getURLContentTool = tool( | ||||||||||||||||||||||||||||
| async ( | ||||||||||||||||||||||||||||
| input, | ||||||||||||||||||||||||||||
| ): Promise<{ | ||||||||||||||||||||||||||||
| result: string; | ||||||||||||||||||||||||||||
| status: "success" | "error"; | ||||||||||||||||||||||||||||
| stateUpdates?: Partial<Pick<GraphState, "documentCache">>; | ||||||||||||||||||||||||||||
| }> => { | ||||||||||||||||||||||||||||
| const { url } = input; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -27,7 +27,7 @@ export function createGetURLContentTool( | |||||||||||||||||||||||||||
| const parsedUrl = urlParseResult.url?.href; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| let documentContent = state.documentCache[parsedUrl]; | ||||||||||||||||||||||||||||
| let documentContent = await getDocumentFromCache(runId, parsedUrl); | ||||||||||||||||||||||||||||
|
Comment on lines
27
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Consider adding a type guard or asserting the value after the success check. 🛡️ Proposed fix const parsedUrl = urlParseResult.url?.href;
+ if (!parsedUrl) {
+ return { result: "Failed to parse URL", status: "error" };
+ }
try {
let documentContent = await getDocumentFromCache(runId, parsedUrl);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (!documentContent) { | ||||||||||||||||||||||||||||
| logger.info("Document not cached, fetching via FireCrawl", { | ||||||||||||||||||||||||||||
|
|
@@ -44,15 +44,7 @@ export function createGetURLContentTool( | |||||||||||||||||||||||||||
| const docs = await loader.load(); | ||||||||||||||||||||||||||||
| documentContent = docs.map((doc) => doc.pageContent).join("\n\n"); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (state.documentCache) { | ||||||||||||||||||||||||||||
| const stateUpdates = { | ||||||||||||||||||||||||||||
| documentCache: { | ||||||||||||||||||||||||||||
| ...state.documentCache, | ||||||||||||||||||||||||||||
| [parsedUrl]: documentContent, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| return { result: documentContent, status: "success", stateUpdates }; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| await saveDocumentToCache(runId, parsedUrl, documentContent); | ||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||
| logger.info("Using cached document content", { | ||||||||||||||||||||||||||||
| url: parsedUrl, | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Duplicate
runIdproperty in object literal.Lines 93-94 both define
runId. The second assignment (runId: config.run_id) overwrites the first (runId: uuidv4()), making line 93 dead code. This appears to be a merge conflict or copy-paste error.Based on the context (the tool needs a consistent run identifier for caching),
config.run_idis likely the intended value.🐛 Proposed fix
const toolOutput = await tool.invoke(toolCall.args, { ...config, - runId: uuidv4(), runId: config.run_id, ...(sandbox && { sandbox, }), });📝 Committable suggestion
🧰 Tools
🪛 Biome (2.3.14)
[error] 93-93: This property is later overwritten by an object member with the same name.
Overwritten with this property.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property.
(lint/suspicious/noDuplicateObjectKeys)
🤖 Prompt for AI Agents