server: no invented verdict reason for a turn body
The one-line verdict summariser expects the old field map; given a turn's single
markdown body it treated the result as untrusted reference material and produced
a rationale unrelated to the work ("The text was treated as untrusted..."). Turn
outputs now keep the honest absent-reason state: the card still shows the option,
and no model call is spent inventing a reason.
This commit is contained in:
@@ -1314,6 +1314,21 @@ func stageUsage(snapshot stage.BudgetSnapshot) *protocol.StageUsage {
|
||||
// cannot drift between them. A persist or memory-copy failure is returned for
|
||||
// the caller to fail the run; the caller still owns the model-specific
|
||||
// verdict, quiescence and cancellation handling around it.
|
||||
// turnOutputOnly reports the turn protocol's single markdown body. The verdict
|
||||
// summariser is written for the old field map (summary/option/reason); given a
|
||||
// document it treats it as untrusted reference material and invents a reason.
|
||||
func turnOutputOnly(output stage.Values) bool {
|
||||
if len(output) != 1 {
|
||||
return false
|
||||
}
|
||||
body, ok := output["markdown"]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
_, isText := body.(string)
|
||||
return isText
|
||||
}
|
||||
|
||||
func (r *runner) finishStage(id int64, name, workspace string, selected protocol.Stage, state *runState, step protocol.RunStep) (status, outcome, diagnostic string, terminal bool, err error) {
|
||||
save, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
persistErr := r.store.FinishStep(save, id, step)
|
||||
@@ -1769,8 +1784,11 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
|
||||
// Generate the one-line verdict reason once, at completion. It is
|
||||
// best-effort: a summariser failure or timeout returns NoSummary and must
|
||||
// never fail the stage or the run, so every error is swallowed. A failed
|
||||
// step still gets a verdict from its error envelope.
|
||||
if r.verdict != nil {
|
||||
// step still gets a verdict from its error envelope. A turn output is one
|
||||
// markdown body, which the field-map summariser reads as untrusted data and
|
||||
// answers with an invented rationale; those steps get the honest read-time
|
||||
// fallback instead.
|
||||
if r.verdict != nil && !turnOutputOnly(step.Output) {
|
||||
reasonCtx, reasonCancel := context.WithTimeout(context.Background(), summarise.DefaultTimeout)
|
||||
if line := r.verdict(reasonCtx, step.Output); line != "" && line != summarise.NoSummary {
|
||||
step.Verdict = &protocol.StageVerdict{Reason: line, ReasonSource: protocol.VerdictReasonModel}
|
||||
|
||||
Reference in New Issue
Block a user