bugger.
RL environments/Pythonhardrl-retry-after-commit-v1
IMPLEMENTATION LAB

Recover a tool call after a lost response

Make a retried return submission commit exactly once.

RL Environments

Your task

Simulate sequential deliveries of write requests. Each input request contains session, key, order, and optional lost. The order string is the entire request payload. On the first occurrence of (session, key), record one write and remember its payload. On a repeat with the same payload return committed without writing again. The same key in another session is independent. Reuse of the same (session, key) with another payload returns conflict and does not write. For a committed response, lost: true changes the visible response to timeout, leaving the commit intact. A conflict always returns conflict. Return responses in request order and writes as [session, order] pairs in commit order.

Expected behavior

A client can retry after an ambiguous timeout using the same key. The original commit still counts and the retry adds no side effect.

Examples

01 Retry after a lost response
{"requests":[{"key":"k","order":"A","session":"one","lost":true},{"key":"k","order":"A","session":"one"}]}
{"responses":["timeout","committed"],"writes":[["one","A"]]}
02 Use the same key in independent sessions
{"requests":[{"key":"k","order":"A","session":"one"},{"key":"k","order":"A","session":"two"}]}
{"responses":["committed","committed"],"writes":[["one","A"],["two","A"]]}
03 No deliveries
{"requests":[]}
{"responses":[],"writes":[]}

Before you begin

  • Python functions, lists, and dictionaries

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    Run the examples, then submit to check the full contract.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.