Skip to content

fix: make play.sh resilient to transient errors#2

Open
IRONICBo wants to merge 1 commit intomemovai:mainfrom
IRONICBo:fix/play-sh-resilience
Open

fix: make play.sh resilient to transient errors#2
IRONICBo wants to merge 1 commit intomemovai:mainfrom
IRONICBo:fix/play-sh-resilience

Conversation

@IRONICBo
Copy link
Copy Markdown
Member

Problem

play.sh used set -e globally, causing the process to exit on any transient curl/jq failure. Any network hiccup, empty response, or bad JSON during long-polling would trigger the EXIT trap, which called leave — making it look like the agent "disconnected" when it was actually killed by its own error handling.

Changes

  • Remove set -e — errors handled explicitly per call, loop never exits on transient failure
  • curl_post / curl_get helpers — always return empty string on failure, never propagate exit codes
  • JSON validation before parsing — bad/empty state response triggers backoff+retry, not exit
  • Exponential backoff — 2s, 4s, 6s… up to 10s between retries on consecutive failures
  • Auto-rejoin after 8 consecutive state-fetch failures
  • Auto-claim + table reselect when busted (chips ≤ 0)
  • Heartbeat runs in background subshell — can't kill the main loop
  • Act retry — failed play action retried once after 1s
  • Numeric sanitization — chip values validated with grep -E '^[0-9]+' before arithmetic

Test plan

  • Run bash skill/scripts/play.sh — confirm stays connected through multiple hands
  • Kill local server briefly, restore — agent should retry and rejoin
  • Let agent go bust — confirm auto-claim and rejoin

- Remove set -e; handle all errors explicitly so transient failures
  never kill the loop
- Wrap all curl calls in curl_post/curl_get helpers (never exit on failure)
- Validate JSON before parsing; back off and retry on bad/empty response
- Heartbeat runs in background subshell (fire-and-forget, can't kill loop)
- Auto-rejoin after MAX_FAILS (8) consecutive state fetch failures
- Auto-claim + re-select table when busted (chips <= 0)
- Numeric chip values sanitized with grep before arithmetic comparisons
- Act retry: if play action fails, retry once after 1s
- Chat and heartbeat are background/best-effort, never block main loop
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

@IRONICBo is attempting to deploy a commit to the memov Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentcasino Ready Ready Preview, Comment Mar 30, 2026 10:45am

Request Review

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.

1 participant