Description
The /inbox command is intended to let users view the lead's inbox contents. However, it calls BUS.read_inbox("lead") which drains/clears the inbox after reading.
File: s09_agent_teams.py, lines 393-395
if query.strip() == "/inbox":
print(json.dumps(BUS.read_inbox("lead"), indent=2))
continue
Why This Happens
read_inbox() is designed to read and drain the inbox (like a queue). Looking at MessageBus.read_inbox() (lines 100-109):
def read_inbox(self, name: str) -> list:
inbox_path = self.dir / f"{name}.jsonl"
if not inbox_path.exists():
return []
messages = []
for line in inbox_path.read_text().strip().splitlines():
if line:
messages.append(json.loads(line))
inbox_path.write_text("") # <-- This clears the file!
return messages
The last line inbox_path.write_text("") clears the inbox after reading. This is correct behavior for the agent loop (to avoid reprocessing messages), but wrong for a user "view only" command.
Impact
Users viewing their inbox with /inbox will lose all pending messages without the lead agent ever seeing them.
Suggested Fix
Read the inbox file directly without draining it:
if query.strip() == "/inbox":
inbox_path = INBOX_DIR / "lead.jsonl"
if inbox_path.exists():
msgs = [json.loads(line) for line in inbox_path.read_text().strip().splitlines() if line]
print(json.dumps(msgs, indent=2))
else:
print("[]")
continue
This reads the file content without calling BUS.read_inbox(), preserving the messages for the lead agent to process.
Description
The
/inboxcommand is intended to let users view the lead's inbox contents. However, it callsBUS.read_inbox("lead")which drains/clears the inbox after reading.File:
s09_agent_teams.py, lines 393-395Why This Happens
read_inbox()is designed to read and drain the inbox (like a queue). Looking atMessageBus.read_inbox()(lines 100-109):The last line
inbox_path.write_text("")clears the inbox after reading. This is correct behavior for the agent loop (to avoid reprocessing messages), but wrong for a user "view only" command.Impact
Users viewing their inbox with
/inboxwill lose all pending messages without the lead agent ever seeing them.Suggested Fix
Read the inbox file directly without draining it:
This reads the file content without calling
BUS.read_inbox(), preserving the messages for the lead agent to process.