Skip to content

Commit ce98d27

Browse files
committed
fix(integrations): keep the agent's limit when the stored SQS and SSM field is blank
1 parent 4355f7d commit ce98d27

3 files changed

Lines changed: 40 additions & 6 deletions

File tree

‎apps/sim/blocks/blocks/aws-stale-inputs.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,28 @@ describe('AWS blocks keep stale subBlock values out of tool input', () => {
149149
expect(body.maxResults).toBeUndefined()
150150
expect(awsSsmGetParametersByPathContract.body?.safeParse(body).success).toBe(true)
151151
})
152+
153+
it('a blank stored limit still lets an Agent call pass its own limit', () => {
154+
const sqs = SQSBlock.tools.config?.params?.(
155+
{
156+
...AWS,
157+
receiveVisibilityTimeout: '',
158+
visibilityTimeout: 30,
159+
moveTaskMaxResults: '',
160+
maxResults: 5,
161+
},
162+
{ operation: 'receive_message' }
163+
)
164+
expect(sqs?.visibilityTimeout).toBe(30)
165+
const moveTasks = SQSBlock.tools.config?.params?.(
166+
{ ...AWS, moveTaskMaxResults: '', maxResults: 5 },
167+
{ operation: 'list_message_move_tasks' }
168+
)
169+
expect(moveTasks?.maxResults).toBe(5)
170+
const ssm = SSMBlock.tools.config?.params?.(
171+
{ ...AWS, pathMaxResults: '', maxResults: 5 },
172+
{ operation: 'get_parameters_by_path' }
173+
)
174+
expect(ssm?.maxResults).toBe(5)
175+
})
152176
})

‎apps/sim/blocks/blocks/sqs.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,11 @@ export const SQSBlock: BlockConfig = {
605605
},
606606
params: (params, context) => {
607607
const operation = mapperOperation(params, context)
608+
/** A blank block-only field yields, on a tool call, the model's arg under the tool's name. */
609+
const orToolArg = (blockValue: unknown, toolValue: unknown) =>
610+
blockValue === undefined || blockValue === null || blockValue === ''
611+
? toolCallArg(context, toolValue)
612+
: blockValue
608613

609614
const parseJson = (value: unknown, fieldName: string) => {
610615
if (value === undefined || value === null || value === '') return undefined
@@ -673,7 +678,7 @@ export const SQSBlock: BlockConfig = {
673678
const waitTimeSeconds = parseInteger(params.waitTimeSeconds, 'waitTimeSeconds')
674679
if (waitTimeSeconds !== undefined) result.waitTimeSeconds = waitTimeSeconds
675680
result.visibilityTimeout = parseInteger(
676-
params.receiveVisibilityTimeout ?? toolCallArg(context, params.visibilityTimeout),
681+
orToolArg(params.receiveVisibilityTimeout, params.visibilityTimeout),
677682
'visibilityTimeout'
678683
)
679684
const messageAttributeNames = parseJson(
@@ -791,7 +796,7 @@ export const SQSBlock: BlockConfig = {
791796
case 'list_message_move_tasks': {
792797
result.sourceArn = params.sourceArn
793798
result.maxResults = parseInteger(
794-
params.moveTaskMaxResults ?? toolCallArg(context, params.maxResults),
799+
orToolArg(params.moveTaskMaxResults, params.maxResults),
795800
'maxResults'
796801
)
797802
break

‎apps/sim/blocks/blocks/ssm.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,11 @@ export const SSMBlock: BlockConfig = {
805805
secretAccessKey: params.secretAccessKey,
806806
}
807807

808+
/** A blank block-only field yields, on a tool call, the model's arg under the tool's name. */
809+
const orToolArg = (blockValue: unknown, toolValue: unknown) =>
810+
blockValue === undefined || blockValue === null || blockValue === ''
811+
? toolCallArg(context, toolValue)
812+
: blockValue
808813
const setJson = (key: string, value: unknown) => {
809814
const parsed = toParsedJson(value)
810815
if (parsed !== undefined) result[key] = parsed
@@ -875,7 +880,7 @@ export const SSMBlock: BlockConfig = {
875880
setBoolean('withDecryption', params.withDecryption)
876881
setJson('parameterFilters', params.parameterFilters)
877882
result.maxResults = toOptionalNumber(
878-
params.pathMaxResults ?? toolCallArg(context, params.maxResults)
883+
orToolArg(params.pathMaxResults, params.maxResults)
879884
)
880885
setString('nextToken', params.nextToken)
881886
break
@@ -906,22 +911,22 @@ export const SSMBlock: BlockConfig = {
906911
case 'describe_instance_information':
907912
setJson('filters', params.instanceInfoFilters ?? toolCallArg(context, params.filters))
908913
result.maxResults = toOptionalNumber(
909-
params.instanceInfoMaxResults ?? toolCallArg(context, params.maxResults)
914+
orToolArg(params.instanceInfoMaxResults, params.maxResults)
910915
)
911916
setString('nextToken', params.nextToken)
912917
break
913918
case 'describe_instance_patches':
914919
result.instanceId = params.instanceId
915920
setJson('filters', params.patchFilters ?? toolCallArg(context, params.filters))
916921
result.maxResults = toOptionalNumber(
917-
params.patchMaxResults ?? toolCallArg(context, params.maxResults)
922+
orToolArg(params.patchMaxResults, params.maxResults)
918923
)
919924
setString('nextToken', params.nextToken)
920925
break
921926
case 'describe_instance_patch_states':
922927
setJson('instanceIds', params.instanceIds)
923928
result.maxResults = toOptionalNumber(
924-
params.patchMaxResults ?? toolCallArg(context, params.maxResults)
929+
orToolArg(params.patchMaxResults, params.maxResults)
925930
)
926931
setString('nextToken', params.nextToken)
927932
break

0 commit comments

Comments
 (0)