Skip to content

Commit 38e1747

Browse files
authored
fix(wand): add shimmer to long-input while isStreaming, better prompt for system prompt generation (#852)
1 parent ab85c1a commit 38e1747

File tree

2 files changed

+105
-70
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components
    • blocks/blocks

2 files changed

+105
-70
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/long-input.tsx

Lines changed: 62 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ export function LongInput({
287287
setShowEnvVars(false)
288288
setShowTags(false)
289289
}
290+
// Prevent user input during streaming
291+
if (wandHook?.isStreaming) {
292+
e.preventDefault()
293+
}
290294
}
291295

292296
// Handle wheel events to control ReactFlow zoom
@@ -352,14 +356,19 @@ export function LongInput({
352356
/>
353357
)}
354358

355-
<div ref={containerRef} className='group relative w-full' style={{ height: `${height}px` }}>
359+
<div
360+
ref={containerRef}
361+
className={cn('group relative w-full', wandHook?.isStreaming && 'streaming-effect')}
362+
style={{ height: `${height}px` }}
363+
>
356364
<Textarea
357365
ref={textareaRef}
358366
className={cn(
359367
'allow-scroll min-h-full w-full resize-none text-transparent caret-foreground placeholder:text-muted-foreground/50',
360368
isConnecting &&
361369
config?.connectionDroppable !== false &&
362-
'ring-2 ring-blue-500 ring-offset-2 focus-visible:ring-blue-500'
370+
'ring-2 ring-blue-500 ring-offset-2 focus-visible:ring-blue-500',
371+
wandHook?.isStreaming && 'pointer-events-none cursor-not-allowed opacity-50'
363372
)}
364373
rows={rows ?? DEFAULT_ROWS}
365374
placeholder={placeholder ?? ''}
@@ -397,7 +406,7 @@ export function LongInput({
397406
</div>
398407

399408
{/* Wand Button */}
400-
{wandHook && !isPreview && (
409+
{wandHook && !isPreview && !wandHook.isStreaming && (
401410
<div className='absolute top-2 right-3 z-10 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100'>
402411
<Button
403412
variant='ghost'
@@ -415,51 +424,57 @@ export function LongInput({
415424
)}
416425

417426
{/* Custom resize handle */}
418-
<div
419-
className='absolute right-1 bottom-1 flex h-4 w-4 cursor-s-resize items-center justify-center rounded-sm bg-background'
420-
onMouseDown={startResize}
421-
onDragStart={(e) => {
422-
e.preventDefault()
423-
}}
424-
>
425-
<ChevronsUpDown className='h-3 w-3 text-muted-foreground/70' />
426-
</div>
427+
{!wandHook?.isStreaming && (
428+
<div
429+
className='absolute right-1 bottom-1 flex h-4 w-4 cursor-s-resize items-center justify-center rounded-sm bg-background'
430+
onMouseDown={startResize}
431+
onDragStart={(e) => {
432+
e.preventDefault()
433+
}}
434+
>
435+
<ChevronsUpDown className='h-3 w-3 text-muted-foreground/70' />
436+
</div>
437+
)}
427438

428-
<EnvVarDropdown
429-
visible={showEnvVars}
430-
onSelect={(newValue) => {
431-
if (onChange) {
432-
onChange(newValue)
433-
} else if (!isPreview) {
434-
emitTagSelection(newValue)
435-
}
436-
}}
437-
searchTerm={searchTerm}
438-
inputValue={value?.toString() ?? ''}
439-
cursorPosition={cursorPosition}
440-
onClose={() => {
441-
setShowEnvVars(false)
442-
setSearchTerm('')
443-
}}
444-
/>
445-
<TagDropdown
446-
visible={showTags}
447-
onSelect={(newValue) => {
448-
if (onChange) {
449-
onChange(newValue)
450-
} else if (!isPreview) {
451-
emitTagSelection(newValue)
452-
}
453-
}}
454-
blockId={blockId}
455-
activeSourceBlockId={activeSourceBlockId}
456-
inputValue={value?.toString() ?? ''}
457-
cursorPosition={cursorPosition}
458-
onClose={() => {
459-
setShowTags(false)
460-
setActiveSourceBlockId(null)
461-
}}
462-
/>
439+
{!wandHook?.isStreaming && (
440+
<>
441+
<EnvVarDropdown
442+
visible={showEnvVars}
443+
onSelect={(newValue) => {
444+
if (onChange) {
445+
onChange(newValue)
446+
} else if (!isPreview) {
447+
emitTagSelection(newValue)
448+
}
449+
}}
450+
searchTerm={searchTerm}
451+
inputValue={value?.toString() ?? ''}
452+
cursorPosition={cursorPosition}
453+
onClose={() => {
454+
setShowEnvVars(false)
455+
setSearchTerm('')
456+
}}
457+
/>
458+
<TagDropdown
459+
visible={showTags}
460+
onSelect={(newValue) => {
461+
if (onChange) {
462+
onChange(newValue)
463+
} else if (!isPreview) {
464+
emitTagSelection(newValue)
465+
}
466+
}}
467+
blockId={blockId}
468+
activeSourceBlockId={activeSourceBlockId}
469+
inputValue={value?.toString() ?? ''}
470+
cursorPosition={cursorPosition}
471+
onClose={() => {
472+
setShowTags(false)
473+
setActiveSourceBlockId(null)
474+
}}
475+
/>
476+
</>
477+
)}
463478
</div>
464479
</>
465480
)

apps/sim/blocks/blocks/agent.ts

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,56 @@ export const AgentBlock: BlockConfig<AgentResponse> = {
7272
wandConfig: {
7373
enabled: true,
7474
maintainHistory: true, // Enable conversation history for iterative improvements
75-
prompt: `You are an expert at writing system prompts for AI agents. Write a system prompt based exactly on what the user asks for.
75+
prompt: `You are an expert system prompt engineer. Create a system prompt based on the user's request.
7676
77-
Current context: {context}
77+
### CONTEXT
78+
{context}
7879
79-
IMPORTANT: Write the system prompt as if the user asked you directly to create it. Match their level of detail and complexity. If they ask for something "comprehensive" or "detailed", write a thorough, in-depth prompt. If they ask for something "simple", keep it concise.
80+
### INSTRUCTIONS
81+
Write a system prompt following best practices. Match the complexity level the user requests.
8082
81-
Key guidelines:
82-
- Always start with "You are..." to define the agent's role
83-
- Include everything the user specifically requests
84-
- If they mention specific tools (like "use Exa to search", "send emails via Gmail", "post to Slack"), explicitly include those tool usage instructions in the prompt
85-
- If they want extensive capabilities, write extensively about them
86-
- If they mention specific behaviors, tone, or constraints, include those
87-
- Write naturally - don't worry about sentence counts or rigid structure
88-
- Focus on being comprehensive when they ask for comprehensive
83+
### CORE PRINCIPLES
84+
1. **Role Definition**: Start with "You are..." to establish identity and function
85+
2. **Direct Commands**: Use action verbs like "Analyze", "Generate", "Classify"
86+
3. **Be Specific**: Include output format, quality standards, behaviors, target audience
87+
4. **Clear Boundaries**: Define focus areas and priorities
88+
5. **Examples**: Add concrete examples when helpful
8989
90-
Tool Integration: Since this is an AI agent platform, users often want agents that use specific tools. If the user mentions:
91-
- Web search → Include instructions about using search tools like Exa
92-
- Email → Include instructions about Gmail integration
93-
- Communication → Include Slack, Discord, Teams instructions
94-
- Data → Include instructions about databases, APIs, spreadsheets
95-
- Any other specific tools → Include explicit usage instructions
90+
### STRUCTURE
91+
- **Primary Role**: Clear identity statement
92+
- **Core Capabilities**: Main functions and expertise
93+
- **Behavioral Guidelines**: Task approach and interaction style
94+
- **Output Requirements**: Format, style, quality expectations
95+
- **Tool Integration**: Specific tool usage instructions
9696
97-
Examples:
98-
SIMPLE REQUEST: "Write a basic customer service agent"
99-
You are a helpful customer service representative. Assist customers with their questions about orders, returns, and products. Be polite and professional in all interactions.
97+
### TOOL INTEGRATION
98+
When users mention tools, include explicit instructions:
99+
- **Web Search**: "Use Exa to gather current information from authoritative sources"
100+
- **Communication**: "Send messages via Slack/Discord/Teams with appropriate tone"
101+
- **Email**: "Compose emails through Gmail with professional formatting"
102+
- **Data**: "Query databases, analyze spreadsheets, call APIs as needed"
100103
101-
COMPREHENSIVE REQUEST: "Create a detailed AI research assistant that can search the web and analyze information"
102-
You are an advanced AI research assistant specializing in conducting thorough research and analysis across various topics. Your primary capabilities include web searching, information synthesis, critical analysis, and presenting findings in clear, actionable formats. When conducting research, use Exa or other web search tools to gather current, relevant information from authoritative sources. Always verify information from multiple sources when possible and clearly distinguish between established facts and emerging trends or opinions. For each research query, begin by understanding the specific research objectives, target audience, and desired depth of analysis. Structure your research process systematically: start with broad topic exploration, then narrow down to specific aspects, and finally synthesize findings into coherent insights. When presenting results, include source citations, highlight key findings, note any limitations or gaps in available information, and suggest areas for further investigation. Adapt your communication style to match the user's expertise level - provide detailed technical explanations for expert audiences and clear, accessible summaries for general audiences. Always maintain objectivity and acknowledge when information is uncertain or conflicting.
104+
### EXAMPLES
103105
104-
Write naturally and comprehensively based on what the user actually asks for.`,
106+
**Simple**: "Create a customer service agent"
107+
→ You are a professional customer service representative. Respond to inquiries about orders, returns, and products with empathy and efficiency. Maintain a helpful tone while providing accurate information and clear next steps.
108+
109+
**Detailed**: "Build a research assistant for market analysis"
110+
→ You are an expert market research analyst specializing in competitive intelligence and industry trends. Conduct thorough market analysis using systematic methodologies.
111+
112+
Use Exa to gather information from industry sources, financial reports, and market research firms. Cross-reference findings across multiple credible sources.
113+
114+
For each request, follow this structure:
115+
1. Define research scope and key questions
116+
2. Identify market segments and competitors
117+
3. Gather quantitative data (market size, growth rates)
118+
4. Collect qualitative insights (trends, consumer behavior)
119+
5. Synthesize findings into actionable recommendations
120+
121+
Present findings in executive-ready formats with source citations, highlight key insights, and provide specific recommendations with rationale.
122+
123+
### FINAL INSTRUCTION
124+
Create a system prompt appropriately detailed for the request, using clear language and relevant tool instructions.`,
105125
placeholder: 'Describe the AI agent you want to create...',
106126
generationType: 'system-prompt',
107127
},

0 commit comments

Comments
 (0)