Skip to content

Commit b534320

Browse files
refactor(logging): simplify log handling in QuickJS sandbox and remove verbose logging from runProgrammaticStep to reduce noise while preserving essential information.
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 4985a32 commit b534320

File tree

2 files changed

+3
-65
lines changed

2 files changed

+3
-65
lines changed

backend/src/run-programmatic-step.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ export async function runProgrammaticStep(
7474
stepNumber: number
7575
},
7676
): Promise<{ agentState: AgentState; endTurn: boolean; stepNumber: number }> {
77-
logger.info(
78-
{
79-
agentType: template.id,
80-
runId: agentState.runId,
81-
hasHandleSteps: !!template.handleSteps,
82-
handleStepsType: typeof template.handleSteps,
83-
stepNumber,
84-
stepsComplete,
85-
},
86-
'runProgrammaticStep: Starting programmatic step execution',
87-
)
88-
8977
if (!template.handleSteps) {
9078
throw new Error('No step handler found for agent template ' + template.id)
9179
}
@@ -122,13 +110,6 @@ export async function runProgrammaticStep(
122110
}
123111

124112
if (typeof template.handleSteps === 'string') {
125-
logger.info(
126-
{
127-
agentType: template.id,
128-
runId: agentState.runId,
129-
},
130-
'runProgrammaticStep: Initializing QuickJS sandbox for string-based generator',
131-
)
132113
// Initialize QuickJS sandbox for string-based generator
133114
sandbox = await sandboxManager.getOrCreateSandbox(
134115
agentState.runId,
@@ -142,13 +123,6 @@ export async function runProgrammaticStep(
142123
streamingLogger, // pass the streaming logger instance
143124
)
144125
} else {
145-
logger.info(
146-
{
147-
agentType: template.id,
148-
runId: agentState.runId,
149-
},
150-
'runProgrammaticStep: Initializing native JavaScript generator',
151-
)
152126
// Initialize native generator
153127
generator = (template.handleSteps as any)(
154128
{
@@ -159,14 +133,6 @@ export async function runProgrammaticStep(
159133
streamingLogger,
160134
)
161135
runIdToGenerator[agentState.runId] = generator
162-
logger.info(
163-
{
164-
agentType: template.id,
165-
runId: agentState.runId,
166-
generatorInitialized: !!generator,
167-
},
168-
'runProgrammaticStep: Native generator initialized successfully',
169-
)
170136
}
171137
}
172138

@@ -228,17 +194,6 @@ export async function runProgrammaticStep(
228194
creditsBefore = state.agentState.directCreditsUsed
229195
childrenBefore = state.agentState.childRunIds.length
230196

231-
logger.info(
232-
{
233-
agentType: template.id,
234-
runId: agentState.runId,
235-
usingSandbox: !!sandbox,
236-
usingGenerator: !!generator,
237-
stepsComplete,
238-
},
239-
'runProgrammaticStep: About to execute generator step',
240-
)
241-
242197
const result = sandbox
243198
? await sandbox.executeStep({
244199
agentState: getPublicAgentState(state.agentState),
@@ -251,16 +206,6 @@ export async function runProgrammaticStep(
251206
stepsComplete,
252207
})
253208

254-
logger.info(
255-
{
256-
agentType: template.id,
257-
runId: agentState.runId,
258-
resultDone: result.done,
259-
resultValue: result.value,
260-
},
261-
'runProgrammaticStep: Generator step executed, got result',
262-
)
263-
264209
if (result.done) {
265210
endTurn = true
266211
break

backend/src/util/quickjs-sandbox.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,9 @@ export class QuickJSSandbox {
103103

104104
msgStr = msg ? context.getString(msg) : undefined
105105

106-
if (logger) {
107-
if (levelStr === 'debug' && logger.debug) {
108-
logger.debug(dataObj, msgStr)
109-
} else if (levelStr === 'info' && logger.info) {
110-
logger.info(dataObj, msgStr)
111-
} else if (levelStr === 'warn' && logger.warn) {
112-
logger.warn(dataObj, msgStr)
113-
} else if (levelStr === 'error' && logger.error) {
114-
logger.error(dataObj, msgStr)
115-
}
106+
// Call the appropriate logger method if available
107+
if (logger?.[levelStr as keyof typeof logger]) {
108+
logger[levelStr as keyof typeof logger](dataObj, msgStr)
116109
}
117110
} catch (err) {
118111
// Fallback for logging errors

0 commit comments

Comments
 (0)