Skip to content

Commit dbf1558

Browse files
committed
Use max agent steps constant in more places
1 parent 780e00d commit dbf1558

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

backend/src/loop-main-prompt.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
12
import { mainPrompt } from './main-prompt'
23

34
import type { MainPromptOptions } from './main-prompt'
@@ -9,8 +10,6 @@ import type {
910
} from '@codebuff/common/types/session-state'
1011
import type { WebSocket } from 'ws'
1112

12-
const DEFAULT_MAX_ITERATIONS = 20
13-
1413
export async function loopMainPrompt(
1514
ws: WebSocket,
1615
action: ClientAction<'prompt'>,
@@ -20,7 +19,7 @@ export async function loopMainPrompt(
2019
toolCalls: Array<ClientToolCall>
2120
toolResults: Array<ToolResult>
2221
}> {
23-
const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS
22+
const maxIterations = options.maxIterations ?? MAX_AGENT_STEPS_DEFAULT
2423
let { sessionState, toolResults, toolCalls } = await mainPrompt(
2524
ws,
2625
action,

backend/src/tools/handlers/tool/spawn-agent-inline.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {
1515
} from '@codebuff/common/types/session-state'
1616
import type { ProjectFileContext } from '@codebuff/common/util/file'
1717
import type { WebSocket } from 'ws'
18+
import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
1819

1920
export const handleSpawnAgentInline = ((params: {
2021
previousToolCallFinished: Promise<void>
@@ -135,7 +136,7 @@ export const handleSpawnAgentInline = ((params: {
135136
agentContext: agentState!.agentContext, // Inherit parent context directly
136137
subagents: [],
137138
messageHistory: getLatestState().messages, // Share the same message array
138-
stepsRemaining: 20, // MAX_AGENT_STEPS
139+
stepsRemaining: MAX_AGENT_STEPS_DEFAULT,
139140
output: undefined,
140141
parentId: agentState!.agentId,
141142
}

backend/src/tools/handlers/tool/spawn-agents-async.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
} from '@codebuff/common/types/session-state'
1919
import type { ProjectFileContext } from '@codebuff/common/util/file'
2020
import type { WebSocket } from 'ws'
21+
import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
2122

2223
export const handleSpawnAgentsAsync = ((params: {
2324
previousToolCallFinished: Promise<void>
@@ -184,7 +185,7 @@ export const handleSpawnAgentsAsync = ((params: {
184185
agentContext: {},
185186
subagents: [],
186187
messageHistory: subAgentMessages,
187-
stepsRemaining: 20, // MAX_AGENT_STEPS
188+
stepsRemaining: MAX_AGENT_STEPS_DEFAULT,
188189
output: undefined,
189190
// Add parent ID to agent state for communication
190191
parentId: agentState!.agentId,

backend/src/tools/handlers/tool/spawn-agents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
} from '@codebuff/common/types/session-state'
1515
import type { ProjectFileContext } from '@codebuff/common/util/file'
1616
import type { WebSocket } from 'ws'
17+
import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
1718

1819
export type SendSubagentChunk = (data: {
1920
userInputId: string
@@ -163,7 +164,7 @@ export const handleSpawnAgents = ((params: {
163164
agentContext: {},
164165
subagents: [],
165166
messageHistory: subAgentMessages,
166-
stepsRemaining: 20, // MAX_AGENT_STEPS
167+
stepsRemaining: MAX_AGENT_STEPS_DEFAULT,
167168
output: undefined,
168169
parentId: agentState!.agentId,
169170
}

0 commit comments

Comments
 (0)