Skip to content

fix(runtime/engine): preserve OTel baggage in saveHistoryBestEffort (#193)

ericli requested to merge v0.45-github-sync into main
  • fix(runtime/engine): preserve OTel baggage in saveHistoryBestEffort (closes #178)

When a task is paused or cancelled, the caller's ctx is already errored and the old code fell back to context.Background(). That dropped every OTel baggage value (tenant.id / agent.id / task.id / request.id), so the SaveHistory span became an orphan and its logs lost every correlation field — exactly when pause/cancel triage needs them most.

Use context.WithoutCancel to keep baggage + span context while detaching from the cancellation chain, and bound the detached save with a 5s timeout so a hung backend can't keep the goroutine alive forever.

Regression tests in react_save_history_test.go capture the ctx handed to SaveHistory and assert baggage + deadline presence, covering both the cancelled-parent and live-parent paths.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

  • fix(runtime/engine): reorder snapshotEntry return values to satisfy ST1008

staticcheck requires error to be the last return value. Swap the ordering in captureHistoryStore.snapshotEntry and update the three call sites.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com


Co-authored-by: Aquaird aquaird@MacBook-Pro.local Co-authored-by: Claude Opus 4.6 (1M context) noreply@anthropic.com

Merge request reports