Skip to content

test: catch reverts of the scheduler lease, restart notice and tool limit - #5456

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/reliability-q-revert-guards
Oct 21, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/reliability-q-revert-guards

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes on main could be reverted with every test still passing. That covers a scheduled email marked failed while it is still sending (#5380), the Slack/Telegram notice after an agent restart telling users to "continue" a conversation the agent forgot (#5382), and nothing proving a hung tool under the messaging bridge ever ends. Each new test fails on the user-visible symptom when its fix is undone.

  • Scheduler lease, both stores. Two claims with the same timestamp are told apart only by claim_id. Without that half of the recovery guard, a stale read fails a live send or re-queues a running job.
  • Restart notice. The existing check only caught a quoted "continue". An unquoted "Send continue" that also dropped "no longer remembers this conversation" passed everything.
  • Hung tool under the bridge. A running tool keeps the bridge's idle clock fresh, so only the agent's own tool limit (GAIA_AGENT_TOOL_TIMEOUT, 180 s) ends it. This drives the real gaia-agent turn loop behind a real AgentChannel and checks the user still gets an answer. It needs the flagship wheel, so it runs in the gaia-agent lane.
🔍 Technical details

Reverts run locally, each against the new test:

Revert Result
Drop claim_id = :claim from recover_claim (daemon + email store) 4 fail: status failed/pending != firing
Restart notice → restarted. Send continue to pick up where it left off. new test fails; all existing messaging tests pass
Restart notice → ... Send "continue" to pick up where it left off. new test fails (existing test also catches this one)
_call_tool_bounded timeout → inf fails: "the hung tool was never ended", user stuck at the tool_call
Bridge idle refresh ignores tool_running fails: error != final

The email schedule tests skip from the repo root unless gaia_agent_email is installed, because the root conftest only redirects hub packages that are already installed. CI does run them: test_email_agent_unit.yml installs the wheel and gates wholesale skips. Main push run 39538913521 shows all 13 stale-firing tests and 16 test_email_schedule.py tests PASSED.

Test plan

  • python -m pytest tests/unit/test_daemon_scheduler_stale_firing.py tests/unit/messaging/ -q: passes locally and in Unit Tests run 39541345649. That run executed the new daemon and restart tests and skipped test_bridge_hung_tool.py as allowlisted.
  • python -m pytest hub/agents/email/python/tests/test_email_schedule_stale_firing.py -q with gaia_agent_email installed: passes locally, and both new cases (scheduled_send, snooze) passed in Email Agent Unit Tests run 39541345667.
  • python util/check_test_lane_coverage.py passes (run locally).
  • CI: Gaia Agent Tests run 39541345605 executed test_bridge_hung_tool.py and it passed (not skipped).

…imit

Three fixes on main could be undone with every test still green. A
scheduler recovery could take over a job that a second driver is firing
right now if the two claims carry the same timestamp. A scheduled email
would then be marked failed mid-send, or a recurring job queued to run
twice. The bridge's notice after replacing a wedged agent could go back to
telling the user to send "continue" to an agent that has forgotten the
question. And nothing showed that a hung tool under Slack or Telegram ends
at all: the bridge never stops a turn while a tool runs, so only the
agent's own tool limit can end it.

Each new test fails when its fix is reverted:

- Scheduler, both stores: dropping the claim_id half of the recovery guard
  leaves the live claim 'failed' or 'pending' instead of 'firing'.
- Bridge restart: a notice that says "Send continue" without quotes, and no
  longer says the conversation was lost, passed every existing test.
- Hung tool: the real gaia-agent turn loop behind a real AgentChannel. With
  no tool limit the user never gets an answer; with a bridge that ignores a
  running tool the turn is stopped instead of answered.

The hung-tool test needs the flagship wheel, so it runs in the gaia-agent
lane and is allowlisted as a module skip in the unit lane.
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes agent::email Email agent changes labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

This PR adds tests only. They pin three fixes already on main: the scheduler lease guard, which stops a scheduled job from being failed or re-queued while it is still running; the "resend, don't continue" notice after an agent restart; and a hung tool under Slack/Telegram still ending with an answer. I found no blocking issues. The test setups fit the code they exercise, and the new bridge test is wired into the CI lane that has the flagship package, so it won't be skipped.

Real-world evidence

N/A: this PR changes only tests and CI wiring, with no user-facing surface. I couldn't run the tests in this review environment because pytest isn't installed, so the verdict rests on static review plus the revert table in the PR description.

🔍 Technical details

Issues found

🟢 Possible flake under a slow runner (tests/unit/messaging/test_bridge_hung_tool.py:232-236). The "no tool_result yet" check runs on wall-clock time against a 3 s tool limit. If the runner stalls more than about 3 s between tool_call and that assert, the test fails with a misleading message. The odds are low. If it ever flakes, raising TOOL_LIMIT to 5–10 s costs little, because the final wait already scales with 10 * TOOL_LIMIT.

Checked

  • stdio.run_turn(agent, query, out, state=...), stdio.parse_query and stdio.PermissionState all exist with the signatures the in-process child double uses.
  • In both stores, recover_claim matches on claim_id and claimed_at (src/gaia/daemon/scheduler/store.py:358-362, and the same in the email schedule_store.py). So the same-timestamp, second-claim case is exactly the half of the guard a revert would remove.
  • The fixture restores _TOOL_REGISTRY and sets release in finally, so the abandoned worker thread doesn't outlive the test by the full 30 s.
  • The new module is added to both test_gaia_agent.yml and the module_skips allowlist, so importorskip can't silently skip it in the lane that should run it.

Strengths

  • Each test asserts the symptom the user would see (a job failed mid-send, "continue" in the notice, no final answer), so a revert fails loudly instead of only breaking an internal detail.
  • The hung-tool test drives the real turn loop behind a real AgentChannel rather than stubbing it. It also checks that the bridge sent no control line and spawned no second child, which pins who ended the tool.

A stall over the 3 s tool limit between the tool call and the first
assert would fail the test for the wrong reason.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Took the flake note: the hung-tool test's tool limit is now 6 s instead of 3 s, so a runner stall between the tool call and the first check can't end the tool early. It costs about 3 s of test time.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 21, 2026
Merged via the queue into amd:main with commit 7e49b16 Oct 21, 2026
28 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/reliability-q-revert-guards 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

agent::email Email agent changes devops DevOps/infrastructure changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants