Skip to content

Commit f00d1cb

Browse files
committed
fix: ensure positive dashes length
1 parent 0efc1d7 commit f00d1cb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,11 @@ export async function executeAgent({
319319
}) {
320320
const width = 60
321321
const fullAgentName = `${agentTemplate.displayName} (${agentTemplate.id})`
322-
const dashes = '-'.repeat(Math.floor((width - fullAgentName.length - 2) / 2))
322+
const dashesLength = Math.max(
323+
0,
324+
Math.floor((width - fullAgentName.length - 2) / 2),
325+
)
326+
const dashes = '-'.repeat(dashesLength)
323327

324328
// Send agent start notification if this is the only child
325329
if (isOnlyChild) {
@@ -347,9 +351,11 @@ export async function executeAgent({
347351
// Send agent end notification if this is the only child
348352
if (isOnlyChild) {
349353
const endedFullAgentName = `Completed: ${fullAgentName}`
350-
const dashesForEndedAgent = '-'.repeat(
351-
Math.floor(width - endedFullAgentName.length - 2) / 2,
354+
const dashesLength = Math.max(
355+
0,
356+
Math.floor((width - endedFullAgentName.length - 2) / 2),
352357
)
358+
const dashesForEndedAgent = '-'.repeat(dashesLength)
353359
onResponseChunk(
354360
`\n\n${dashesForEndedAgent} ${endedFullAgentName} ${dashesForEndedAgent}\n\n`,
355361
)

0 commit comments

Comments
 (0)