Skip to content

Reject invalid mode-run records before persistence and preserve finalization diagnostics #348

Description

@adrianwebb

Objective

Prevent malformed provider mode-run payloads from becoming persisted corrupt records; report actionable contract errors instead of generic HTTP500. Platform501/Agent113 live evidence.

Reproduction

Agent54 sent status completed to providers.assignments.mode.run. API persistAgentModeRun writes first, then readAgentModeRun uses SDK assert validation (only queued/running/succeeded/failed/cancelled). Assignment assignment_rLBQQPoyero3eDJyK_P7HIbVOeXtYgSL had verified review/readback/Kata teardown, but finalization failed and was retried with an exhausted productive window. Agent115 corrects the caller to succeeded with compile-time and actual SDK-validator coverage.

Contract / acceptance

Validate fully assembled mode run through the shared SDK before INSERT/UPDATE, reject invalid fields with structured 4xx, retain ownership conflict protection, and prove no row written on invalid input with real PostgreSQL tests. Inventory any affected records through authorized operations; preserve immutable artifacts/history and do not silently mark a failed assignment successful. Explicit repair plan if corrupt historical records exist. Test closeout/finalization recovery separately: do not schedule new model execution after productive work has already completed; retain original artifact and usage diagnostics.

Rollback / dependencies

No permissive alias for completed; use canonical succeeded. Agent55 is the immediate caller fix. API ownership of input validation; Agent ownership of durable finalization retry/outbox. Restore coordinated application/database checkpoint for any explicit data repair.

Evidence

Gate Evidence
Live reproduction Above assignment; semantic receipt70a902eaa80a333a72e8797c8e0afd82d12f263b8014a3dbedc5f67f106e984b
Implementation Pending

Successful caller repair and remaining diagnostic evidence

Agent55 / generation260 completed assignment_dlt1Sduw4bCJSPgbuueW34fkIBiEeI07 in one attempt. Ledger1bde0eb4-e453-4eec-9e3f-417a2aad3e82 records36 seconds/144 released; provider usage records35.881356828 seconds and144463 input/125440 cached/1173 output tokens. But lifecycleOutput.performance.actual and budget active/elapsed/token fields are zero, generatedBy api-recovery. Reconcile terminal performance with settled usage without overwriting canonical ledger or inventing costs. Add actual provider usage shape (snake-case token fields) to regression fixtures. Existing invalid historical mode-run input and safe closeout recovery remain in scope; do not relabel failed historical assignments successful.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions