Skip to content

bug(agent): the #1083 result callback envelope carries no finish time, so a late-delivered terminal records the delivery time as completed_at #3628

Open

Description

@pavshulin

Summary

Follow-up of #3589. The backend now accepts completed_at on the result-callback contract (ExecutionResultEnvelope.completed_at) and both terminal writers measure duration_ms to it. The agent never sends it: result_callback._success_envelope / _envelope_from_http_exception / _cancelled_override (docker/base-image/agent_server/services/result_callback.py) carry no finish timestamp, and the callback POST is retried with capped backoff up to the slot-lease deadline and re-sent by the startup sweep after a crash. On every such late delivery the row's completed_at is the delivery time and duration_ms includes the whole retry window — the same fabricated-duration shape #3589 fixed on the watchdog claim path.

Expected

The agent stamps completed_at (ISO, UTC) into every callback envelope at the moment the turn ends (next to terminal_reason), so a terminal that reaches the backend hours later still records the turn's own duration. Backend side is already in place (#3589): unknown/absent → the writer stamps now, so an older image keeps today's behaviour.

Where

  • docker/base-image/agent_server/services/result_callback.py — envelope constructors
  • docker/base-image/agent_server/services/retained_results.py — the retained record already carries retained_at; the callback envelope should carry the same instant
  • Backend contract: src/backend/models.py::ExecutionResultEnvelope.completed_at, mapper services/execution_envelope.py::terminal_from_callback_payload

Acceptance

  • every envelope result_callback POSTs carries completed_at
  • a unit test on the agent server pins the key on the success, failure and cancelled envelopes
  • base image rebuilt; a late callback (backend down during the POST) records duration_ms ≈ the turn

Activity

  1. added
    priority-p3
    type-bug
    theme-reliability
    on Oct 12, 2026
  2. added
    status-ready
    complexity-medium
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p3status-readytheme-reliabilitytype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions