Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion carwatch/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def car_identity() -> dict:
car.update({k: v for k, v in (cfg.get("car") or {}).items() if v})
return car
STATE_PATH = os.path.expanduser("~/.carwatch/agent-state.json")
POLL_SECONDS = 20
# Room poll cadence. Every tick is one GroupMind request, which is billed per
# invocation, and the car agent answers when spoken to, not on a stopwatch:
# 60 s keeps it responsive and cuts the box from 4,320 to 1,440 reads a day.
# Override with CARWATCH_POLL_SECONDS (minimum 5).
POLL_SECONDS = max(5, int(os.environ.get("CARWATCH_POLL_SECONDS", "60") or 60))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent the longer poll from dropping busy-room messages

When an idle room receives more than 20 messages during this new 60-second interval, the agent silently misses the older messages—including any question addressed to the car—because _fetch_messages() still requests only 20 entries, and RoomClient.fetch() documents that the server returns newest-first (carwatch/room.py:59-66). The loop then advances last_seen through those newest entries, so omitted messages are never recovered. The previous cadence could keep up with roughly three times the sustained traffic; increase the fetch capacity or paginate from last_seen before lengthening the interval.

Useful? React with 👍 / 👎.

MAX_TOKENS = 400


Expand Down
Loading