fix: stabilize agent file change previews

This commit is contained in:
Hamza Ayed
2026-10-07 21:10:36 +03:00
parent fc36f54f15
commit 95c9bc231b
9 changed files with 823 additions and 224 deletions
@@ -75,11 +75,22 @@ try {
-ContentType 'application/json' `
-Body $previewRequest `
-TimeoutSec 240
$previewDiff = [string]$previewResult.proposal.diff
$unchanged = [IO.File]::ReadAllText($readmePath).Contains('The greet function returns')
if ($previewResult.tool -ne 'propose_file_change' -or
$previewResult.proposal.path -ne 'README.md' -or
-not $unchanged) {
throw 'The live agent did not return a README.md diff preview while preserving the file.'
if ($previewResult.tool -ne 'propose_file_change') {
throw "The live model selected '$($previewResult.tool)' instead of propose_file_change."
}
if ($previewResult.proposal.path -ne 'README.md') {
throw 'The live proposal targeted a different file than README.md.'
}
if ([string]::IsNullOrWhiteSpace($previewDiff)) {
throw 'The live proposal did not include diff text.'
}
if ($previewDiff -notmatch '(?m)^\+[^+]') {
throw 'The live proposal diff did not contain an added line.'
}
if (-not $unchanged) {
throw 'The smoke test changed README.md before explicit approval.'
}
[pscustomobject]@{
@@ -91,6 +102,7 @@ try {
preview_tool = $previewResult.tool
preview_path = $previewResult.proposal.path
preview_operation = $previewResult.proposal.operation
preview_diff_lines = @($previewDiff -split "`n").Count
file_unchanged_without_user_approval = $unchanged
} | ConvertTo-Json -Depth 5
}