Skip to content

agent: keep enqueue time on exported coop messages - #86

Open
hhh2210 wants to merge 2 commits into
cooperbench:mainfrom
hhh2210:fix/conversation-send-timestamps
Open

hhh2210 wants to merge 2 commits into
cooperbench:mainfrom
hhh2210:fix/conversation-send-timestamps

Conversation

@hhh2210

@hhh2210 hhh2210 commented Sep 22, 2026 •

Copy link
Copy Markdown

The bug

sent_messages stores to and content only. _extract_conversation then copies a missing timestamp. _message_timestamp_key documents ISO input, but float(ts) rejects those strings and returns 0. Missing timestamps sort first, and the stable sort groups by sender, so a reply can be written before the message it answers.

send_and_wait returns after the peer replies. A timestamp taken at that point records the reply, not the send. Redis already stores an ISO timestamp at rpush.

The fix

On a successful send, keep that enqueue timestamp on the connector and copy it onto sent_messages for both plain sends and --wait. The sort key parses ISO-8601, including a trailing Z, and rejects non-finite numeric values such as NaN and infinities in both numeric and string form. Missing, malformed, and non-finite values sort as 0; a historical record with a null timestamp stays null.

Verification

Local validation on Python 3.13.13:

  • python -m pytest tests/runner/test_coop.py tests/agents/mini_swe_agent_v2/test_sent_timestamp.py — 20 passed. Covers enqueue-time propagation, blocking sends, ISO/UTC offsets, float/string non-finite values, overflow-to-infinity strings, and stable mixed ordering. The non-finite regressions fail before the follow-up fix.
  • python -m pytest tests/ -v --tb=short — 442 passed, 84 skipped. Docker/Modal/GCP integration tests retain their default skips. For this run only, Git tag/commit signing was disabled via GIT_CONFIG_COUNT overrides so personal signing settings do not alter temporary test repositories; no Git config file was changed. LITELLM_LOCAL_MODEL_COST_MAP=true was set to avoid fetching a price map in unit tests.
  • ruff check src/cooperbench/, ruff format --check src/cooperbench/, and mypy src/cooperbench/ — all passed (76 source files).
  • Ruff check/format for both changed test files and git diff --check — passed.

The full-suite run emits two pre-existing unknown-marker warnings for slow and timeout. No remote CI result is available yet; local checks do not establish the Linux/Python matrix.

Left out

The no-git prompt that tells an agent to fetch origin/<peer> is a separate PR.

Checklist

  • Code follows project style
  • Tests pass locally
  • Documentation updated (if needed)

Made with Cursor

Conversation export sorted missing and ISO timestamps as zero, so a reply could be written before the message it answered. Record the Redis enqueue timestamp instead of the time send_and_wait returns.

Co-authored-by: Cursor <[email protected]>
Copilot AI lite review requested due to automatic review settings September 22, 2026 04:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Non-finite numeric timestamps must be rejected before sorting.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates cooperative-message exports to preserve enqueue timestamps and sort mixed timestamp formats chronologically.

Changes:

  • Records enqueue timestamps for normal and blocking sends.
  • Parses ISO-8601 timestamps, including trailing Z.
  • Adds regression tests for timestamp propagation and ordering.
File Description
tests/​runner/​test_coop.py Tests timestamp ordering behavior.
tests/​agents/​mini_swe_agent_v2/​test_sent_timestamp.py Tests timestamp propagation.
src/​cooperbench/​runner/​coop.py Normalizes message timestamps for sorting.
src/​cooperbench/​agents/​mini_swe_agent_v2/​connectors/​messaging.py Stores enqueue timestamps.
src/​cooperbench/​agents/​mini_swe_agent_v2/​agents/​default.py Copies timestamps into sent-message records.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/cooperbench/runner/coop.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Extreme numeric and ISO timestamps can still raise exceptions and abort conversation export.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment on lines +41 to +43
if isinstance(ts, (int, float)):
value = float(ts)
return value if math.isfinite(value) else 0.0

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants