Skip to content

Commit 95c4a50

Browse files
authored
Merge pull request #3193 from liam-hq/devin/1753856803-consolidate-hasToolCalls
refactor: consolidate hasToolCalls function into shared utility
2 parents f1ec31f + 40bdc84 commit 95c4a50

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { BaseMessage } from '@langchain/core/messages'
21
import type { WorkflowState } from '../../chat/workflow/types'
2+
import { hasToolCalls } from '../../utils/hasToolCalls'
33

44
/**
55
* Determines the next node based on whether the last message contains tool calls
@@ -16,14 +16,3 @@ export const routeAfterDesignSchema = (
1616

1717
return 'generateTestcase'
1818
}
19-
20-
/**
21-
* Checks if a message contains tool calls
22-
*/
23-
const hasToolCalls = (message: BaseMessage): boolean => {
24-
return (
25-
'tool_calls' in message &&
26-
Array.isArray(message.tool_calls) &&
27-
message.tool_calls.length > 0
28-
)
29-
}

frontend/internal-packages/agent/src/pm-agent/routing/routeAfterAnalyzeRequirements.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { BaseMessage } from '@langchain/core/messages'
21
import { WorkflowTerminationError } from '../../shared/errorHandling'
2+
import { hasToolCalls } from '../../utils/hasToolCalls'
33
import type { PmAgentState } from '../pmAgentAnnotations'
44

55
const MAX_ANALYSIS_RETRY_COUNT = 3
@@ -39,14 +39,3 @@ export const routeAfterAnalyzeRequirements = (
3939
// 4. No tool calls and requirements not set -> re-analyze
4040
return 'analyzeRequirements'
4141
}
42-
43-
/**
44-
* Checks if a message contains tool calls
45-
*/
46-
const hasToolCalls = (message: BaseMessage): boolean => {
47-
return (
48-
'tool_calls' in message &&
49-
Array.isArray(message.tool_calls) &&
50-
message.tool_calls.length > 0
51-
)
52-
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { BaseMessage } from '@langchain/core/messages'
2+
3+
/**
4+
* Check if a message contains tool calls
5+
* @param message - The BaseMessage to check
6+
* @returns true if the message has non-empty tool_calls array
7+
*/
8+
export const hasToolCalls = (message: BaseMessage): boolean => {
9+
return (
10+
'tool_calls' in message &&
11+
Array.isArray(message.tool_calls) &&
12+
message.tool_calls.length > 0
13+
)
14+
}

0 commit comments

Comments
 (0)