Protocol v2: request_id, action_ack, and time bank are now live #216
smly
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Effective: 2026-06-10 22:51 JST
We have rolled out a protocol update for RiichiLab bot connections.
This update addresses the stale-reply problem discussed in #205, where a delayed response could be interpreted as the answer to a later
request_action. The new protocol makes request/response binding explicit, adds action receipts, and replaces the fixed 3-second timeout with a grace + time-bank model.What changed
1.
request_actionnow includesrequest_idEvery
request_actionnow includes a monotonically increasingrequest_id:{ "type": "request_action", "request_id": 42, "time": {"grace_ms": 3000, "bank_ms": 15000, "deadline_ms": 18000}, "possible_actions": [...], "observation": "base64..." }For best reliability, bots are encouraged to echo the same
request_idin their response:{"type":"dahai","actor":0,"pai":"3m","tsumogiri":true,"request_id":42}This is recommended, but not required for backward compatibility. Responses without
request_idare still accepted through the legacy compatibility path. Echoingrequest_idlets the server bind the reply to the exact request, so a late reply with an oldrequest_idis discarded as stale and is never treated as an illegal action for a newer turn.2. The server now sends
action_ackAfter processing, rejecting, discarding, or substituting an action, the server sends an
action_ackevent:{"type":"action_ack","request_id":42,"status":"accepted", "elapsed_ms":850,"bank_consumed_ms":0,"bank_ms":15000}Possible statuses:
acceptedrejectedpossible_actionsunparseablestaledefaultedSimple bots may ignore
action_ack. It is primarily useful for debugging, latency measurement, and tracking remaining time bank.3. Fixed timeout is replaced by grace + per-kyoku time bank
The old effective behavior was a fixed 3-second response window.
The new default rule is:
grace_ms = 3000: each request has 3 seconds of free time.bank_ms = 15000: each player gets a 15-second time bank per kyoku.deadline_ms = grace_ms + remaining bank.With a full bank, a bot can take up to 18 seconds on one request. Time beyond the 3-second grace is deducted from the bank. Once the bank is empty, the bot is back to a 3-second deadline.
The bank resets at the start of every kyoku and does not carry over.
Timeouts are still not penalized. On timeout, the server substitutes the default action:
noneCompatibility
This is a backward-compatible extension of the current MJAI-style protocol, not a clean-break envelope rewrite.
Existing bots can continue to connect without changes if they already ignore unknown fields and unknown event types.
What legacy bots will see:
request_action.request_idrequest_action.timeaction_ackeventrequest_idFor best reliability, bot authors should update their bots to:
request_idon every response.request_action.timeinstead of hardcoding timeout assumptions.possible_actionsbefore sending.Echoing
request_idis strongly recommended and may become mandatory for ranked play after a future notice period.What is unchanged
Why this change was made
The previous protocol had no explicit identifier tying a bot response to the
request_actionit answered. That made delayed replies difficult to classify reliably.The new
request_idecho makes stale handling deterministic:request_id-> process the actionrequest_id-> discard as stale, no penaltyrequest_id-> protocol violation, chomborequest_id-> legacy compatibility pathThis should make slow-turn failures easier to debug and prevent delayed replies from being misclassified as illegal actions for later game states.
All reactions