diff --git a/blocks/blocks/agent.ts b/blocks/blocks/agent.ts index d6fc2273f2..e8c0839260 100644 --- a/blocks/blocks/agent.ts +++ b/blocks/blocks/agent.ts @@ -75,24 +75,52 @@ export const AgentBlock: BlockConfig = { properties: { name: { type: 'string', - minLength: 1, + description: 'Name of the field', }, type: { type: 'string', enum: ['string', 'number', 'boolean', 'array', 'object'], + description: 'Type of the field', + }, + isArray: { + type: 'boolean', + description: 'Whether this field contains multiple values', + }, + items: { + type: 'object', + description: 'Schema for array items (required when isArray is true)', + properties: { + type: { + type: 'string', + enum: ['string', 'number', 'boolean', 'object'], + }, + properties: { + type: 'array', + items: { + type: 'object', + properties: { + name: { type: 'string' }, + type: { + type: 'string', + enum: ['string', 'number', 'boolean'], + }, + }, + required: ['name', 'type'], + }, + }, + }, }, description: { type: 'string', + description: 'Description of what this field represents', }, }, required: ['name', 'type'], additionalProperties: false, }, - minItems: 1, }, }, required: ['fields'], - additionalProperties: false, }, }, temperature: { type: 'number', required: false }, diff --git a/executor/index.ts b/executor/index.ts index ea2759b327..84f0456a63 100644 --- a/executor/index.ts +++ b/executor/index.ts @@ -296,7 +296,9 @@ export class Executor { const response = await executeProviderRequest(providerId, { model, systemPrompt: inputs.systemPrompt, - context: inputs.context, + context: Array.isArray(inputs.context) + ? JSON.stringify(inputs.context, null, 2) + : inputs.context, tools: tools.length > 0 ? tools : undefined, temperature: inputs.temperature, maxTokens: inputs.maxTokens, @@ -512,13 +514,22 @@ export class Executor { // If a valid leaf is found if (replacementValue !== undefined) { - // Replace the placeholder in the string - resolvedValue = resolvedValue.replace( - match, - typeof replacementValue === 'object' - ? JSON.stringify(replacementValue) - : String(replacementValue) - ) + // Special handling for context field to ensure proper formatting + if (key === 'context') { + // If it's not a string, stringify it for context + resolvedValue = + typeof replacementValue === 'string' + ? replacementValue + : JSON.stringify(replacementValue, null, 2) + } else { + // For all other fields, use existing logic + resolvedValue = resolvedValue.replace( + match, + typeof replacementValue === 'object' + ? JSON.stringify(replacementValue) + : String(replacementValue) + ) + } } else { throw new Error( `No value found at path "${path}" in block "${sourceBlock.metadata?.title}".`