Skip to content

Commit 584ac10

Browse files
author
Theodore Li
committed
Revert "Feat(logs) upgrade mothership chat messages to error (#3772)"
This reverts commit 9d1b976.
1 parent 1235625 commit 584ac10

File tree

9 files changed

+41
-44
lines changed

9 files changed

+41
-44
lines changed

apps/sim/app/api/copilot/chat/route.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export async function POST(req: NextRequest) {
194194

195195
const userMessageIdToUse = userMessageId || crypto.randomUUID()
196196
try {
197-
logger.error(
197+
logger.info(
198198
appendCopilotLogContext('Received chat POST', {
199199
requestId: tracker.requestId,
200200
messageId: userMessageIdToUse,
@@ -251,7 +251,7 @@ export async function POST(req: NextRequest) {
251251
actualChatId
252252
)
253253
agentContexts = processed
254-
logger.error(
254+
logger.info(
255255
appendCopilotLogContext('Contexts processed for request', {
256256
requestId: tracker.requestId,
257257
messageId: userMessageIdToUse,
@@ -358,7 +358,7 @@ export async function POST(req: NextRequest) {
358358
)
359359

360360
try {
361-
logger.error(
361+
logger.info(
362362
appendCopilotLogContext('About to call Sim Agent', {
363363
requestId: tracker.requestId,
364364
messageId: userMessageIdToUse,
@@ -572,7 +572,7 @@ export async function POST(req: NextRequest) {
572572
provider: typeof requestPayload?.provider === 'string' ? requestPayload.provider : undefined,
573573
}
574574

575-
logger.error(
575+
logger.info(
576576
appendCopilotLogContext('Non-streaming response from orchestrator', {
577577
requestId: tracker.requestId,
578578
messageId: userMessageIdToUse,
@@ -617,7 +617,7 @@ export async function POST(req: NextRequest) {
617617

618618
// Start title generation in parallel if this is first message (non-streaming)
619619
if (actualChatId && !currentChat.title && conversationHistory.length === 0) {
620-
logger.error(
620+
logger.info(
621621
appendCopilotLogContext('Starting title generation for non-streaming response', {
622622
requestId: tracker.requestId,
623623
messageId: userMessageIdToUse,
@@ -633,7 +633,7 @@ export async function POST(req: NextRequest) {
633633
updatedAt: new Date(),
634634
})
635635
.where(eq(copilotChats.id, actualChatId!))
636-
logger.error(
636+
logger.info(
637637
appendCopilotLogContext(`Generated and saved title: ${title}`, {
638638
requestId: tracker.requestId,
639639
messageId: userMessageIdToUse,
@@ -662,7 +662,7 @@ export async function POST(req: NextRequest) {
662662
.where(eq(copilotChats.id, actualChatId!))
663663
}
664664

665-
logger.error(
665+
logger.info(
666666
appendCopilotLogContext('Returning non-streaming response', {
667667
requestId: tracker.requestId,
668668
messageId: userMessageIdToUse,
@@ -795,7 +795,7 @@ export async function GET(req: NextRequest) {
795795
...(streamSnapshot ? { streamSnapshot } : {}),
796796
}
797797

798-
logger.error(
798+
logger.info(
799799
appendCopilotLogContext(`Retrieved chat ${chatId}`, {
800800
messageId: chat.conversationId || undefined,
801801
})

apps/sim/app/api/copilot/chat/stream/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function GET(request: NextRequest) {
3636
const toParam = url.searchParams.get('to')
3737
const toEventId = toParam ? Number(toParam) : undefined
3838

39-
logger.error(
39+
logger.info(
4040
appendCopilotLogContext('[Resume] Received resume request', {
4141
messageId: streamId || undefined,
4242
}),
@@ -53,7 +53,7 @@ export async function GET(request: NextRequest) {
5353
}
5454

5555
const meta = (await getStreamMeta(streamId)) as StreamMeta | null
56-
logger.error(appendCopilotLogContext('[Resume] Stream lookup', { messageId: streamId }), {
56+
logger.info(appendCopilotLogContext('[Resume] Stream lookup', { messageId: streamId }), {
5757
streamId,
5858
fromEventId,
5959
toEventId,
@@ -72,7 +72,7 @@ export async function GET(request: NextRequest) {
7272
if (batchMode) {
7373
const events = await readStreamEvents(streamId, fromEventId)
7474
const filteredEvents = toEventId ? events.filter((e) => e.eventId <= toEventId) : events
75-
logger.error(appendCopilotLogContext('[Resume] Batch response', { messageId: streamId }), {
75+
logger.info(appendCopilotLogContext('[Resume] Batch response', { messageId: streamId }), {
7676
streamId,
7777
fromEventId,
7878
toEventId,
@@ -124,7 +124,7 @@ export async function GET(request: NextRequest) {
124124
const flushEvents = async () => {
125125
const events = await readStreamEvents(streamId, lastEventId)
126126
if (events.length > 0) {
127-
logger.error(
127+
logger.info(
128128
appendCopilotLogContext('[Resume] Flushing events', { messageId: streamId }),
129129
{
130130
streamId,

apps/sim/app/api/mothership/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export async function POST(req: NextRequest) {
113113
const userMessageId = providedMessageId || crypto.randomUUID()
114114
userMessageIdForLogs = userMessageId
115115

116-
logger.error(
116+
logger.info(
117117
appendCopilotLogContext('Received mothership chat start request', {
118118
requestId: tracker.requestId,
119119
messageId: userMessageId,

apps/sim/app/api/v1/copilot/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export async function POST(req: NextRequest) {
8484
const chatId = parsed.chatId || crypto.randomUUID()
8585

8686
messageId = crypto.randomUUID()
87-
logger.error(
87+
logger.info(
8888
appendCopilotLogContext('Received headless copilot chat start request', { messageId }),
8989
{
9090
workflowId: resolved.workflowId,

apps/sim/lib/copilot/chat-payload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export async function buildCopilotRequestPayload(
201201
})
202202
}
203203
if (mcpTools.length > 0) {
204-
logger.error(
204+
logger.info(
205205
appendCopilotLogContext('Added MCP tools to copilot payload', {
206206
messageId: userMessageId,
207207
}),

apps/sim/lib/copilot/chat-streaming.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export function createSSEStream(params: StreamingOrchestrationParams): ReadableS
467467
})
468468

469469
if (abortController.signal.aborted) {
470-
logger.error(
470+
logger.info(
471471
appendCopilotLogContext('Stream aborted by explicit stop', { requestId, messageId })
472472
)
473473
await eventWriter.close().catch(() => {})
@@ -483,7 +483,7 @@ export function createSSEStream(params: StreamingOrchestrationParams): ReadableS
483483
'An unexpected error occurred while processing the response.'
484484

485485
if (clientDisconnected) {
486-
logger.error(
486+
logger.info(
487487
appendCopilotLogContext('Stream failed after client disconnect', {
488488
requestId,
489489
messageId,
@@ -539,7 +539,7 @@ export function createSSEStream(params: StreamingOrchestrationParams): ReadableS
539539
}
540540
} catch (error) {
541541
if (abortController.signal.aborted) {
542-
logger.error(
542+
logger.info(
543543
appendCopilotLogContext('Stream aborted by explicit stop', { requestId, messageId })
544544
)
545545
await eventWriter.close().catch(() => {})
@@ -548,7 +548,7 @@ export function createSSEStream(params: StreamingOrchestrationParams): ReadableS
548548
return
549549
}
550550
if (clientDisconnected) {
551-
logger.error(
551+
logger.info(
552552
appendCopilotLogContext('Stream errored after client disconnect', {
553553
requestId,
554554
messageId,

apps/sim/lib/copilot/orchestrator/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export async function orchestrateCopilotStream(
136136
let claimedToolCallIds: string[] = []
137137
let claimedByWorkerId: string | null = null
138138

139-
logger.error(withLogContext('Starting copilot orchestration'), {
139+
logger.info(withLogContext('Starting copilot orchestration'), {
140140
goRoute,
141141
workflowId,
142142
workspaceId,
@@ -155,7 +155,7 @@ export async function orchestrateCopilotStream(
155155
for (;;) {
156156
context.streamComplete = false
157157

158-
logger.error(withLogContext('Starting orchestration loop iteration'), {
158+
logger.info(withLogContext('Starting orchestration loop iteration'), {
159159
route,
160160
hasPendingAsyncContinuation: Boolean(context.awaitingAsyncContinuation),
161161
claimedToolCallCount: claimedToolCallIds.length,
@@ -168,7 +168,7 @@ export async function orchestrateCopilotStream(
168168
const d = (event.data ?? {}) as Record<string, unknown>
169169
const response = (d.response ?? {}) as Record<string, unknown>
170170
if (response.async_pause) {
171-
logger.error(withLogContext('Detected async pause from copilot backend'), {
171+
logger.info(withLogContext('Detected async pause from copilot backend'), {
172172
route,
173173
checkpointId:
174174
typeof (response.async_pause as Record<string, unknown>)?.checkpointId ===
@@ -201,7 +201,7 @@ export async function orchestrateCopilotStream(
201201
loopOptions
202202
)
203203

204-
logger.error(withLogContext('Completed orchestration loop iteration'), {
204+
logger.info(withLogContext('Completed orchestration loop iteration'), {
205205
route,
206206
streamComplete: context.streamComplete,
207207
wasAborted: context.wasAborted,
@@ -210,7 +210,7 @@ export async function orchestrateCopilotStream(
210210
})
211211

212212
if (claimedToolCallIds.length > 0) {
213-
logger.error(withLogContext('Marking async tool calls as delivered'), {
213+
logger.info(withLogContext('Marking async tool calls as delivered'), {
214214
toolCallIds: claimedToolCallIds,
215215
})
216216
await Promise.all(
@@ -223,7 +223,7 @@ export async function orchestrateCopilotStream(
223223
}
224224

225225
if (options.abortSignal?.aborted || context.wasAborted) {
226-
logger.error(withLogContext('Stopping orchestration because request was aborted'), {
226+
logger.info(withLogContext('Stopping orchestration because request was aborted'), {
227227
pendingToolCallCount: Array.from(context.toolCalls.values()).filter(
228228
(toolCall) => toolCall.status === 'pending' || toolCall.status === 'executing'
229229
).length,
@@ -241,13 +241,13 @@ export async function orchestrateCopilotStream(
241241

242242
const continuation = context.awaitingAsyncContinuation
243243
if (!continuation) {
244-
logger.error(withLogContext('No async continuation pending; finishing orchestration'))
244+
logger.info(withLogContext('No async continuation pending; finishing orchestration'))
245245
break
246246
}
247247

248248
let resumeReady = false
249249
let resumeRetries = 0
250-
logger.error(withLogContext('Processing async continuation'), {
250+
logger.info(withLogContext('Processing async continuation'), {
251251
checkpointId: continuation.checkpointId,
252252
runId: continuation.runId,
253253
pendingToolCallIds: continuation.pendingToolCallIds,
@@ -443,7 +443,7 @@ export async function orchestrateCopilotStream(
443443
}
444444
if (resumeRetries < 3) {
445445
resumeRetries++
446-
logger.error(withLogContext('Retrying async resume after claim contention'), {
446+
logger.info(withLogContext('Retrying async resume after claim contention'), {
447447
checkpointId: continuation.checkpointId,
448448
runId: continuation.runId,
449449
workerId: resumeWorkerId,
@@ -474,7 +474,7 @@ export async function orchestrateCopilotStream(
474474
]
475475
claimedByWorkerId = claimedToolCallIds.length > 0 ? resumeWorkerId : null
476476

477-
logger.error(withLogContext('Resuming async tool continuation'), {
477+
logger.info(withLogContext('Resuming async tool continuation'), {
478478
checkpointId: continuation.checkpointId,
479479
runId: continuation.runId,
480480
workerId: resumeWorkerId,
@@ -540,7 +540,7 @@ export async function orchestrateCopilotStream(
540540
checkpointId: continuation.checkpointId,
541541
results,
542542
}
543-
logger.error(withLogContext('Prepared async continuation payload for resume endpoint'), {
543+
logger.info(withLogContext('Prepared async continuation payload for resume endpoint'), {
544544
route,
545545
checkpointId: continuation.checkpointId,
546546
resultCount: results.length,
@@ -569,7 +569,7 @@ export async function orchestrateCopilotStream(
569569
usage: context.usage,
570570
cost: context.cost,
571571
}
572-
logger.error(withLogContext('Completing copilot orchestration'), {
572+
logger.info(withLogContext('Completing copilot orchestration'), {
573573
success: result.success,
574574
chatId: result.chatId,
575575
hasRequestId: Boolean(result.requestId),

apps/sim/lib/copilot/orchestrator/sse/handlers/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
328328
const rid = typeof event.data === 'string' ? event.data : undefined
329329
if (rid) {
330330
context.requestId = rid
331-
logger.error(
331+
logger.info(
332332
appendCopilotLogContext('Mapped copilot message to Go trace ID', {
333333
messageId: context.messageId,
334334
}),

apps/sim/lib/copilot/orchestrator/sse/handlers/tool-execution.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ async function maybeWriteOutputToFile(
187187
contentType
188188
)
189189

190-
logger.error(
190+
logger.info(
191191
appendCopilotLogContext('Tool output written to file', { messageId: context.messageId }),
192192
{
193193
toolName,
@@ -401,7 +401,7 @@ async function maybeWriteOutputToTable(
401401
}
402402
})
403403

404-
logger.error(
404+
logger.info(
405405
appendCopilotLogContext('Tool output written to table', { messageId: context.messageId }),
406406
{
407407
toolName,
@@ -528,7 +528,7 @@ async function maybeWriteReadCsvToTable(
528528
}
529529
})
530530

531-
logger.error(
531+
logger.info(
532532
appendCopilotLogContext('Read output written to table', { messageId: context.messageId }),
533533
{
534534
toolName,
@@ -599,14 +599,11 @@ export async function executeToolAndReport(
599599
toolCall.status = 'executing'
600600
await markAsyncToolRunning(toolCall.id, 'sim-stream').catch(() => {})
601601

602-
logger.error(
603-
appendCopilotLogContext('Tool execution started', { messageId: context.messageId }),
604-
{
605-
toolCallId: toolCall.id,
606-
toolName: toolCall.name,
607-
params: toolCall.params,
608-
}
609-
)
602+
logger.info(appendCopilotLogContext('Tool execution started', { messageId: context.messageId }), {
603+
toolCallId: toolCall.id,
604+
toolName: toolCall.name,
605+
params: toolCall.params,
606+
})
610607

611608
try {
612609
let result = await executeToolServerSide(toolCall, execContext)
@@ -693,7 +690,7 @@ export async function executeToolAndReport(
693690
: raw && typeof raw === 'object'
694691
? JSON.stringify(raw).slice(0, 200)
695692
: undefined
696-
logger.error(
693+
logger.info(
697694
appendCopilotLogContext('Tool execution succeeded', { messageId: context.messageId }),
698695
{
699696
toolCallId: toolCall.id,

0 commit comments

Comments
 (0)