Skip to content

Commit f09556c

Browse files
committed
fix
1 parent d3a5c5b commit f09556c

3 files changed

Lines changed: 10 additions & 83 deletions

File tree

apps/sim/executor/handlers/agent/agent-handler.ts

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ const AGENT_RAW_PROVIDER_ERROR_INPUT_PATHS: readonly ResolvedSecretInputPath[] =
113113
['promptCaching'],
114114
['previousInteractionId'],
115115
]
116-
const AGENT_MEMORY_ERROR_INPUT_PATHS: readonly ResolvedSecretInputPath[] = [['conversationId']]
117116

118117
interface IndexedToolInput {
119118
tool: ToolInput
@@ -411,30 +410,14 @@ export class AgentBlockHandler implements BlockHandler {
411410
if (this.isStreamingExecution(result)) {
412411
const streamingResult = result as StreamingExecution
413412
streamingResult.diagnosticResolvedSecretTraceRegistry = providerErrorRegistry
414-
const memoryErrorRegistry = settledInputRegistry?.forkForInputPaths(
415-
AGENT_MEMORY_ERROR_INPUT_PATHS
416-
)
417413
if (filteredInputs.memoryType && filteredInputs.memoryType !== 'none') {
418-
return this.wrapStreamForMemoryPersistence(
419-
ctx,
420-
filteredInputs,
421-
streamingResult,
422-
memoryErrorRegistry
423-
)
414+
return this.wrapStreamForMemoryPersistence(ctx, filteredInputs, streamingResult)
424415
}
425416
return streamingResult
426417
}
427418

428419
if (filteredInputs.memoryType && filteredInputs.memoryType !== 'none') {
429-
const memoryErrorRegistry = settledInputRegistry?.forkForInputPaths(
430-
AGENT_MEMORY_ERROR_INPUT_PATHS
431-
)
432-
await this.persistResponseToMemory(
433-
ctx,
434-
filteredInputs,
435-
result as BlockOutput,
436-
memoryErrorRegistry
437-
)
420+
await this.persistResponseToMemory(ctx, filteredInputs, result as BlockOutput)
438421
}
439422

440423
return result
@@ -2484,8 +2467,7 @@ export class AgentBlockHandler implements BlockHandler {
24842467
private wrapStreamForMemoryPersistence(
24852468
ctx: ExecutionContext,
24862469
inputs: AgentInputs,
2487-
streamingExec: StreamingExecution,
2488-
diagnosticRegistry?: ResolvedSecretTraceRegistry
2470+
streamingExec: StreamingExecution
24892471
): StreamingExecution {
24902472
return {
24912473
...streamingExec,
@@ -2494,17 +2476,10 @@ export class AgentBlockHandler implements BlockHandler {
24942476
try {
24952477
await memoryService.appendToMemory(ctx, inputs, { role: 'assistant', content })
24962478
} catch (error) {
2497-
const memoryErrorRegistry = this.createErrorRegistry(
2498-
diagnosticRegistry,
2499-
ctx.resolvedSecretTraceRegistry
2500-
)
2501-
const diagnosticCtx = memoryErrorRegistry
2502-
? { ...ctx, resolvedSecretTraceRegistry: memoryErrorRegistry }
2503-
: ctx
25042479
logger.error(
25052480
'Failed to persist streaming response',
25062481
projectAgentDiagnosticMetadata(
2507-
diagnosticCtx,
2482+
ctx,
25082483
getErrorDiagnosticMetadata(error),
25092484
getErrorDiagnosticFallback(error)
25102485
)
@@ -2517,8 +2492,7 @@ export class AgentBlockHandler implements BlockHandler {
25172492
private async persistResponseToMemory(
25182493
ctx: ExecutionContext,
25192494
inputs: AgentInputs,
2520-
result: BlockOutput,
2521-
diagnosticRegistry?: ResolvedSecretTraceRegistry
2495+
result: BlockOutput
25222496
): Promise<void> {
25232497
const content = (result as any)?.content
25242498
if (!content || typeof content !== 'string') {
@@ -2531,17 +2505,10 @@ export class AgentBlockHandler implements BlockHandler {
25312505
workflowId: ctx.workflowId,
25322506
})
25332507
} catch (error) {
2534-
const memoryErrorRegistry = this.createErrorRegistry(
2535-
diagnosticRegistry,
2536-
ctx.resolvedSecretTraceRegistry
2537-
)
2538-
const diagnosticCtx = memoryErrorRegistry
2539-
? { ...ctx, resolvedSecretTraceRegistry: memoryErrorRegistry }
2540-
: ctx
25412508
logger.error(
25422509
'Failed to persist response to memory',
25432510
projectAgentDiagnosticMetadata(
2544-
diagnosticCtx,
2511+
ctx,
25452512
getErrorDiagnosticMetadata(error),
25462513
getErrorDiagnosticFallback(error)
25472514
)

apps/sim/executor/handlers/mothership/mothership-handler.test.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ describe('MothershipBlockHandler', () => {
912912
expect(logged).not.toContain('__sim_')
913913
})
914914

915-
it('retains exact provenance when a resolved conversation ID is echoed to output', async () => {
915+
it('does not treat conversation IDs as secret-bearing result content', async () => {
916916
const registry = new ResolvedSecretTraceRegistry([
917917
{ name: 'CONVERSATION_ID', plaintext: 'x', encryptedValue: 'encrypted-conversation-id' },
918918
])
@@ -936,38 +936,14 @@ describe('MothershipBlockHandler', () => {
936936
expect(JSON.parse(String(options.body)).chatId).toBe('x')
937937
expect(result).toMatchObject({ conversationId: 'x' })
938938
expect(inputs.conversationId).toBe('x')
939-
expect(context.resolvedSecretTraceRegistry?.getActiveMatches()).toEqual([
940-
{ plaintext: 'x', replacement: '{{CONVERSATION_ID}}' },
941-
])
939+
expect(context.resolvedSecretTraceRegistry?.getActiveMatches()).toEqual([])
942940
expect(context.resolvedSecretTraceRegistry?.exportCommittedProvenanceForValue(result)).toEqual({
943941
version: 1,
944942
complete: true,
945-
entries: [{ name: 'CONVERSATION_ID', encryptedValue: 'encrypted-conversation-id' }],
943+
entries: [],
946944
})
947945
})
948946

949-
it('does not carry a low-entropy conversation ID into terminal error provenance', async () => {
950-
const registry = new ResolvedSecretTraceRegistry([
951-
{ name: 'CONVERSATION_ID', plaintext: 'x', encryptedValue: 'encrypted-conversation-id' },
952-
])
953-
registry.recordResolvedAtInputPath('CONVERSATION_ID', 'x', ['conversationId'])
954-
registry.recordResolvedInputProjection(['conversationId'], 'x', '{{CONVERSATION_ID}}')
955-
context.resolvedSecretTraceRegistry = registry
956-
mockGenerateId.mockReturnValueOnce('message-uuid').mockReturnValueOnce('request-uuid')
957-
mockExtractAPIErrorMessage.mockResolvedValueOnce('Box')
958-
fetchMock.mockResolvedValue(new Response(JSON.stringify({ error: 'Box' }), { status: 500 }))
959-
960-
await expect(
961-
handler.execute(context, block, {
962-
prompt: 'Continue this thread',
963-
conversationId: 'x',
964-
})
965-
).rejects.toThrow('Sim execution failed: Box')
966-
967-
expect(context.resolvedSecretTraceRegistry?.getActiveMatches()).toEqual([])
968-
expect(context.errorResolvedSecretTraceRegistry?.getActiveMatches()).toEqual([])
969-
})
970-
971947
it('forwards only enabled MCP tools and selected skills', async () => {
972948
mockGenerateId
973949
.mockReturnValueOnce('chat-uuid')

apps/sim/executor/handlers/mothership/mothership-handler.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ function createMothershipStreamingExecution(
505505
options: {
506506
onCancel?: (reason?: unknown) => void
507507
onDone?: () => void
508-
onSuccess?: () => void
509508
registry?: ResolvedSecretTraceRegistry
510509
} = {}
511510
): StreamingExecution {
@@ -588,10 +587,7 @@ function createMothershipStreamingExecution(
588587
throw new Error('Sim execution stream ended without a final result')
589588
}
590589

591-
if (!cancelled) {
592-
options.onSuccess?.()
593-
controller.close()
594-
}
590+
if (!cancelled) controller.close()
595591
} catch (error) {
596592
if (!cancelled) {
597593
controller.error(error)
@@ -830,16 +826,6 @@ export class MothershipBlockHandler implements BlockHandler {
830826
...(ctx.executionId ? { executionId: ctx.executionId } : {}),
831827
}
832828

833-
const settledInputRegistry = ctx.resolvedSecretTraceRegistry
834-
const conversationRegistry = settledInputRegistry?.forkForInputPaths(
835-
providedConversationId ? [['conversationId']] : []
836-
)
837-
const commitConversationProvenance = (): void => {
838-
if (resultRegistry && conversationRegistry) {
839-
resultRegistry.mergeToolCallRegistry(conversationRegistry)
840-
}
841-
}
842-
843829
logger.info('Executing Mothership block', {
844830
blockId: block.id,
845831
messageId,
@@ -933,7 +919,6 @@ export class MothershipBlockHandler implements BlockHandler {
933919
}
934920
},
935921
onDone: cleanupAbortListeners,
936-
onSuccess: commitConversationProvenance,
937922
registry: resultRegistry,
938923
})
939924
streamingExecution.diagnosticResolvedSecretTraceRegistry = resultRegistry
@@ -944,7 +929,6 @@ export class MothershipBlockHandler implements BlockHandler {
944929

945930
const result = await readMothershipExecuteResponse(response, resultRegistry)
946931
const output = formatMothershipBlockOutput(result, chatId)
947-
commitConversationProvenance()
948932
if (resultRegistry) ctx.resolvedSecretTraceRegistry = resultRegistry
949933
return output
950934
} catch (error) {

0 commit comments

Comments
 (0)