Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🤝 fix: Normalize Empty Handoff Fields to Restore Default Fallback (#12707)

Luna8f39f31c8728
diff --git a/client/src/components/SidePanel/Agents/Advanced/AgentHandoffs.tsx b/client/src/components/SidePanel/Agents/Advanced/AgentHandoffs.tsx
index 0ff7ba7682..d19fee0af9 100644
--- a/client/src/components/SidePanel/Agents/Advanced/AgentHandoffs.tsx
+++ b/client/src/components/SidePanel/Agents/Advanced/AgentHandoffs.tsx
@@ -206,7 +206,9 @@ const AgentHandoffs: React.FC<AgentHandoffsProps> = ({ field, currentAgentId })
placeholder={localize('com_ui_agent_handoff_description_placeholder')}
value={edge.description || ''}
onChange={(e) =>
- updateHandoffDetailsAt(idx, { description: e.target.value })
+ updateHandoffDetailsAt(idx, {
+ description: e.target.value === '' ? undefined : e.target.value,
+ })
}
className="mt-1 h-8 text-sm"
/>
@@ -223,7 +225,11 @@ const AgentHandoffs: React.FC<AgentHandoffsProps> = ({ field, currentAgentId })
id={`handoff-prompt-${idx}`}
placeholder={localize('com_ui_agent_handoff_prompt_placeholder')}
value={typeof edge.prompt === 'string' ? edge.prompt : ''}
- onChange={(e) => updateHandoffDetailsAt(idx, { prompt: e.target.value })}
+ onChange={(e) =>
+ updateHandoffDetailsAt(idx, {
+ prompt: e.target.value === '' ? undefined : e.target.value,
+ })
+ }
className="mt-1 h-20 resize-none text-sm"
/>
</div>
@@ -241,7 +247,9 @@ const AgentHandoffs: React.FC<AgentHandoffsProps> = ({ field, currentAgentId })
placeholder={localize('com_ui_agent_handoff_prompt_key_placeholder')}
value={edge.promptKey || ''}
onChange={(e) =>
- updateHandoffDetailsAt(idx, { promptKey: e.target.value })
+ updateHandoffDetailsAt(idx, {
+ promptKey: e.target.value === '' ? undefined : e.target.value,
+ })
}
className="mt-1 h-8 text-sm"
/>
diff --git a/packages/api/src/agents/validation.ts b/packages/api/src/agents/validation.ts
index 8119c97204..ee37c26f44 100644
--- a/packages/api/src/agents/validation.ts
+++ b/packages/api/src/agents/validation.ts
@@ -44,11 +44,11 @@ export const agentSupportContactSchema = z
export const graphEdgeSchema = z.object({
from: z.union([z.string(), z.array(z.string())]),
to: z.union([z.string(), z.array(z.string())]),
- description: z.string().optional(),
+ description: z.string().optional().transform((v) => (v === '' ? undefined : v)),
edgeType: z.enum(['handoff', 'direct']).optional(),
- prompt: z.union([z.string(), z.function()]).optional(),
+ prompt: z.union([z.string(), z.function()]).optional().transform((v) => (v === '' ? undefined : v)),
excludeResults: z.boolean().optional(),
- promptKey: z.string().optional(),
+ promptKey: z.string().optional().transform((v) => (v === '' ? undefined : v)),
});
/** Per-tool options schema (defer_loading, allowed_callers) */