runner/coop: coerce message timestamps to float before sorting#49
Merged
Conversation
execute_coop crashes mid-rollout with
``TypeError: '<' not supported between instances of 'int' and 'str'``
when one agent adapter reports numeric timestamps (mini_swe_agent uses
time.time() floats) and another reports ISO strings (OpenHands SDK).
The sort fires before agent{fid}_traj.json is written, so callers that
rely on the structured trajectory output get nothing — even though the
underlying rollout ran to completion.
Extract the timestamp key as a module-level
``_message_timestamp_key`` helper that best-effort coerces to float
(None / non-numeric → 0.0), then have execute_coop's sort call it.
Adds tests/runner/test_coop.py with regression coverage:
- mixed int / float / ISO-string / None / missing timestamps all sort
without raising
- received messages stay filtered out before the sort
All 31 runner tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
execute_coopcrashes mid-rollout withTypeError: '<' not supported between instances of 'int' and 'str'when one agent adapter reports numeric timestamps and another reports ISO strings:
mini_swe_agentemitstime.time()floats.The sort fires before
agent{fid}_traj.jsonis written, so callers that rely on the structured trajectory output get nothing — even though the underlying rollout ran to completion. I hit this from CooperTrain's plan-first eval (cooperbench/CooperTrain#30): both held-out rollouts ran the full 100 steps and producedreadable_*.jsonbut noagent1_traj.json/agent2_traj.json, so the eval saw "missing assistant turns" everywhere.Fix
Extract the timestamp key as a module-level
_message_timestamp_keyhelper that best-effort coerces tofloat(None / non-numeric → 0.0), then haveexecute_coop's sort call it. Behavior preserved when all timestamps are numeric (and matches the prioror 0intent for missing ones); previously-crashing mixed-type runs now sort cleanly with non-numeric entries grouped at the front.Tests
New
tests/runner/test_coop.py(4 tests):_extract_conversationhappy-path (sent + received).All 31 runner tests pass (
pytest tests/runner/).Risk
Local — touches one sort key and adds a pure helper. The semantics of the sort are unchanged for any input that previously succeeded (numeric-only timestamps); only previously-crashing inputs change behavior, and they now sort instead of raising.
🤖 Generated with Claude Code