fix(agents): preserve YAML frontmatter fields when saving agent settings via UI (#2004)
Co-authored-by: bashrusakh <bashrusakh@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
bashrusakh
parent
420582984e
commit
76c3bb5fd9
@@ -624,7 +624,7 @@ export const AgentsPage: React.FC = () => {
|
|||||||
const permissionConfig = buildPermissionConfigWithGlobal(globalPermission, permissionRules);
|
const permissionConfig = buildPermissionConfigWithGlobal(globalPermission, permissionRules);
|
||||||
const config: AgentConfig = {
|
const config: AgentConfig = {
|
||||||
name: agentName,
|
name: agentName,
|
||||||
description: description.trim() || undefined,
|
...(description.trim() ? { description: description.trim() } : {}),
|
||||||
mode,
|
mode,
|
||||||
model: trimmedModel === '' ? null : trimmedModel,
|
model: trimmedModel === '' ? null : trimmedModel,
|
||||||
variant: trimmedVariant === '' ? null : trimmedVariant || undefined,
|
variant: trimmedVariant === '' ? null : trimmedVariant || undefined,
|
||||||
@@ -632,7 +632,7 @@ export const AgentsPage: React.FC = () => {
|
|||||||
top_p: topP ?? null,
|
top_p: topP ?? null,
|
||||||
prompt: trimmedPrompt || (isNewAgent ? undefined : null),
|
prompt: trimmedPrompt || (isNewAgent ? undefined : null),
|
||||||
permission: permissionConfig,
|
permission: permissionConfig,
|
||||||
scope: isNewAgent ? draftScope : undefined,
|
...(isNewAgent && draftScope ? { scope: draftScope } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
let result: AgentMutationResult;
|
let result: AgentMutationResult;
|
||||||
|
|||||||
@@ -1666,6 +1666,9 @@ export const updateAgent = (agentName: string, updates: Record<string, unknown>,
|
|||||||
const creatingNewMd = isBuiltinOverride;
|
const creatingNewMd = isBuiltinOverride;
|
||||||
|
|
||||||
for (const [field, value] of Object.entries(updates || {})) {
|
for (const [field, value] of Object.entries(updates || {})) {
|
||||||
|
// Skip undefined values — they would overwrite existing frontmatter fields with nothing
|
||||||
|
if (value === undefined) continue;
|
||||||
|
|
||||||
if (field === 'prompt') {
|
if (field === 'prompt') {
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
if (mdExists || creatingNewMd) {
|
if (mdExists || creatingNewMd) {
|
||||||
|
|||||||
@@ -451,6 +451,9 @@ function updateAgent(agentName, updates, workingDirectory) {
|
|||||||
const creatingNewMd = isBuiltinOverride;
|
const creatingNewMd = isBuiltinOverride;
|
||||||
|
|
||||||
for (const [field, value] of Object.entries(updates)) {
|
for (const [field, value] of Object.entries(updates)) {
|
||||||
|
// Skip undefined values — they would overwrite existing frontmatter fields with nothing
|
||||||
|
if (value === undefined) continue;
|
||||||
|
|
||||||
if (field === 'prompt') {
|
if (field === 'prompt') {
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
if (mdExists || creatingNewMd) {
|
if (mdExists || creatingNewMd) {
|
||||||
|
|||||||
Reference in New Issue
Block a user