Skip to content

fix(lemonade): ask the daemon once per poll while waiting for GAIA's server - #5444

Merged
kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:fix/lemonade-wait-one-ask
Oct 21, 2026
Merged

kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:fix/lemonade-wait-one-ask

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

While GAIA waits for its own model server to come back, each 2-second poll asked the daemon to start the server twice when no server was recorded. That doubled the daemon calls and cloud-key replays for up to 60 seconds. Now each poll asks once. This was the remaining open note from the #5264 review; the rest landed in #5282.

Test plan

  • python -m pytest tests/unit/test_lemonade_restart_wait.py tests/unit/test_lemonade_follows_restart.py tests/unit/test_lemonade_survives_idle_stop.py tests/unit/test_daemon_lemonade.py hub/agents/gaia/python/tests/test_stdio_lemonade_reconnect.py: 336 passed (Windows). The new test_with_nothing_recorded_each_poll_asks_the_daemon_once fails on main.
  • python util/lint.py --black --isort --flake8 --pylint --test-lanes: all pass
  • CI: Unit Tests (Linux, Windows), Code Quality

…server

With no GAIA server recorded, each poll of the reconnect wait asked the daemon
to start it twice: following an empty record already asks, and the loop asked
again when the server was still not answering. That doubled the ensure calls
and cloud-key replays for the whole wait. The loop now skips its own ask in a
poll where following just made one.

Raised in the review of amd#5264.
@github-actions github-actions Bot added llm LLM backend changes tests Test changes performance Performance-critical changes labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

While GAIA waits for its own model server to come back, each poll used to ask the daemon to start it twice when no server was on record. This PR cuts that to once per poll, which also halves the cloud-key replays during the wait. The fix is small and correct, and the new test fails on main and passes here. I found no blocking issues.

Real-world evidence

N/A. No evidence bundle was produced. This is an internal reconnect path inside the LLM client, with no new CLI, API, or UI surface, so the verdict rests on static review plus the PR's unit tests.

🔍 Technical details

Why it's correct

  • _follow_gaia_lemonade already calls _start_gaia_lemonade and _replay_cloud_key when _gaia_lemonade_state() is None. The old loop then saw _gaia_lemonade_gone() still true (the state wasn't recorded yet) and called both again in the same iteration.
  • Taking asked before following keeps the explicit start for the case that still needs it: a server is recorded but its port is dead or its key is stale, and follow returns without starting anything.
  • One harmless race: the state file can appear between the asked read and follow. Then follow re-points the client and this poll skips the explicit start, even if that recorded port isn't accepting connections yet. The next poll covers it, so the worst case is one extra poll interval and never a missed start.
  • Exceptions behave as before. A GaiaLemonadeNotAnsweringError raised inside follow is still caught by the same try.

Issues found: none.

Strengths

  • The regression test pins the behavior that matters: two daemon posts across exactly one poll interval, with a daemon that reports a URL before the state file records it. That models the real cause of the double call.
  • The diff is minimal and the one-line comment explains the non-obvious invariant without restating the code.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 21, 2026
Merged via the queue into amd:main with commit 53c6697 Oct 21, 2026
36 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/lemonade-wait-one-ask branch October 21, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm LLM backend changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants