-
Notifications
You must be signed in to change notification settings - Fork 478
Fix diff preview to operate at field level for prompt changes #3601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix diff preview to operate at field level for prompt changes #3601
Conversation
|
@pavanmudumba is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @pavanmudumba it would be great if you could share a short video of how it works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| function buildPromptDiffInput(params?: Record<string, any>): DiffInput { | ||
| if (!params) return {} | ||
| return { | ||
| prompt: params.prompt, | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 buildPromptDiffInput extracts non-existent prompt property, resulting in empty diff
The buildPromptDiffInput function extracts params.prompt assuming there's a top-level prompt property, but the actual data structure has prompt names as keys with prompt as a nested property inside each.
Click to expand
Data Structure Mismatch
The params variable (line 94) is either:
derivedAgConfigfromtransformedPromptsAtomFamily(variantId)?.ag_config- which has structure like{ "promptName": { prompt: [...], llm_config: {...} } }jsonOverride- a parameters override objectvariant.parameters- which has structure like{ ag_config: { promptName: { ... } } }
The buildPromptDiffInput function at lines 23-28:
function buildPromptDiffInput(params?: Record<string, any>): DiffInput {
if (!params) return {}
return {
prompt: params.prompt, // This will be undefined!
}
}Since params.prompt is undefined (the actual prompt arrays are nested under prompt name keys), the function returns { prompt: undefined }. When JSON.stringify is called on this, the undefined value is omitted, resulting in "{}".
Impact
The diff preview in the commit modal will always show an empty or near-empty comparison (e.g., {} vs {}), making it useless for reviewing actual prompt changes before committing.
Recommendation: The function should iterate over the prompt keys in the config object and extract the nested prompt arrays. For example:
function buildPromptDiffInput(params?: Record<string, any>): DiffInput {
if (!params) return {}
const result: DiffInput = {}
for (const [key, value] of Object.entries(params)) {
if (value && typeof value === 'object' && 'prompt' in value) {
result[key] = { prompt: value.prompt }
}
}
return result
}Was this helpful? React with 👍 or 👎 to provide feedback.
| function buildPromptDiffInput(params?: Record<string, any>): DiffInput { | ||
| if (!params) return {} | ||
| return { | ||
| prompt: params.prompt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes there is a property called prompt in params. That is not always the case (for instance with custom workflows)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point — agreed.
The current version assumes a top-level prompt field, which won’t hold for custom workflows or alternative config shapes.
I’ll update the diff input builder to iterate over the config entries and extract nested prompt fields only when present, so the diff remains field-level without making assumptions about the schema.
Summary
This PR improves the diff preview shown when committing changes in the Playground.
Previously, even small edits to a prompt caused the entire prompt block to be marked as changed, making it difficult to understand what actually changed. This update makes the diff operate at a field level so that only the modified prompt fields are highlighted.
What changed
Why this matters
This makes commit previews more readable and precise, especially for small prompt edits, improving the overall developer experience when reviewing changes.
Scope & Safety
Related Issue
Fixes #3550