Skip to content

fix(s13, s15): tolerate a corrupt line in an agent mailbox - #673

Open
shuhuNB515 wants to merge 1 commit into
shareAI-lab:mainfrom
shuhuNB515:fix/mailbox-corrupt-line
Open

shuhuNB515 wants to merge 1 commit into
shareAI-lab:mainfrom
shuhuNB515:fix/mailbox-corrupt-line

Conversation

@shuhuNB515

@shuhuNB515 shuhuNB515 commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes #672

Problem

MessageBus.read_inbox() in s13_agent_teams/code.py and s15_integrated_harness/code.py parsed the mailbox with a list comprehension over json.loads(line). One truncated or malformed line raised JSONDecodeError before inbox.unlink(), so the file was never consumed and every later read failed on the same line. That agent's inbox was permanently stuck and messages after the bad line were never delivered.

Change

  • Parse the inbox line by line; skip lines that fail to decode, and skip payloads that are not JSON objects, printing a short [bus] skipped ... warning.
  • Consume the file as before once the readable messages are collected.
  • Keep s13/s15 in step: the embedded snapshots in web/src/data/generated/versions.json are regenerated so tests/test_web_scenarios.py stays byte-identical.

No README code block shows this implementation (the READMEs only reference BUS.read_inbox("lead")), so docs.json is unchanged.

Verification

Reproduced with a mailbox holding one valid line, one truncated line, and one more valid line:

before after
read_inbox("worker") JSONDecodeError: Unterminated string returns the 2 valid messages
second call raises again (file still there) returns [] (file consumed)

Full suite on this branch: 500 passed, 118 subtests passed, 3 failed — 503 tests total. The three failures (test_s_full_background.py ×2, one test_subprocess_output_encoding.py GBK case) reproduce identically on unmodified origin/main in this environment (a sandbox mkdir EEXIST and a subprocess decoding case) and are unrelated to this change.

Disclosed AI assistance: found during an AI-assisted review; the patch and verification were done with AI assistance.

read_inbox builds its list with a comprehension over json.loads(line),
so a single truncated or malformed line raises JSONDecodeError. The file is
only unlinked after the parse, so the bad line stays in place and every
later read fails the same way: that agent's inbox is permanently stuck and
no message after the corrupt line is ever delivered. Skip lines that do not
parse (and non-object payloads) with a warning, then consume the file as
usual, matching how the other store loaders treat corrupt entries. Sync the
embedded s13/s15 snapshots in versions.json.

Disclosed AI assistance: found during an AI-assisted review.

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.

s13/s15: one corrupt line in a mailbox makes read_inbox fail forever and blocks delivery

1 participant