Skip to content

ai: fix the five flow test failures (silent turn start limit, mock resume, guard word) - #3679

Merged
BaseMax merged 3 commits into
mainfrom
fix/ai-flow-flake
Nov 19, 2026
Merged

BaseMax merged 3 commits into
mainfrom
fix/ai-flow-flake

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 19, 2026

Copy link
Copy Markdown
Member

The Build like production and run the flow tests job fails every time it actually runs (the runs that looked green had that step skipped). Five checks fail, three causes:

  • The answer guard rewrites any sentence that names a pool model into the canned reply. The mock answered "via backup-one", and backup-one is a redacted pool word, so the two rate limit checks got the canned text. The mock now says "via fallback one" and the test expects that.
  • After an automatic continuation the mock overwrote the session prompt with the continuation note and forgot "always limited" and "fail midway", so those two checks saw a normal answer. The mock keeps the first prompt now.
  • While the live event stream is connected, turn.Advance polled the engine every 10 seconds, so a turn that went quiet was noticed around 40 seconds and the 30 second resume won over the start limit. It polls at once and then every 5 seconds while no live text has arrived, and the quiet timer starts the first time the engine is seen idle.

Verified against a private mariadbd, the mock and the backend built with the main compiler: the full api_flow run had 0 FAIL (173 ok, stopped at the voice section because the speech mock was not running), and a loop of restarted, rate limited, fail midway and goes quiet ran 96 checks with none bad.

While the live event stream is connected the turn loop only polled the
engine every 10 seconds, so a turn that went quiet was seen idle too late
and the 30 second resume won over the start limit. Poll every 5 seconds
(and at once) while no live text has arrived, and let the quiet timer
start the first time the engine is seen idle.
…wers do not name the model

The guard rewrites sentences that name a pool model, so the mock now says
via fallback one instead of backup-one. After an automatic continuation the
mock answered the continuation note as a fresh prompt, which hid the always
limited and fail midway cases; it now keeps the first prompt of the session
when the new one is a continuation.
@BaseMax
BaseMax requested a review from a team as a code owner November 19, 2026 15:54
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
sha=679f839b8b9fd433f43ac5174e0a9d340324098a

🤖 Salam AI review

Verdict: ✅ Good to merge

commit 679f839 · 4 files · +11 −8 · model salam

Summary

This pull request fixes five recurring flow-test failures by correcting mock behavior, test expectations, and backend turn timing. It prevents fallback answers from containing pool model names that triggered the answer guard, preserves the original session prompt across automatic continuations so scenario flags remain intact, and makes silent-turn polling detect idle/start-limit conditions before the resume path. The changes are focused and align with the described failure modes.

What changed

  • ai/backend/tests/engine_mock.mjs: fallback answers now emit via fallback <suffix> instead of the raw model name, and prompt_async retains the original prompt when handling an automatic continuation while still refreshing request-derived fields.
  • ai/backend/tests/api_flow.mjs: fallback expectations updated to match the revised mock answer text.
  • ai/backend/turn.salam: check_due now takes an interval and first-poll flag; silent live turns with no text poll immediately and then every 5 seconds instead of waiting on the 10-second cadence.
  • ai/backend/openai.salam: idle/start-limit handling runs independently of the "text grew" branch.

Review

  • ai/backend/tests/engine_mock.mjs (L53, L144): Preserving before on continuation prompts and deriving limited/project from the restored prompt correctly keeps flags like always limited and fail midway across resumes, addressing the mock-state loss described.
  • ai/backend/turn.salam (L55-67, L359): Using SILENT_CHECK_SECONDS with first=true for text.Len() == 0 ensures the engine is polled at once and more frequently while quiet, which matches the goal of enforcing the start limit before the 30-second resume path.
  • ai/backend/openai.salam (L893-899): Separating the idle/start-limit check from the growth branch means quiet handling is evaluated on every poll. If new text arrives in the same poll where the engine is reported idle/started, quiet is reset and then immediately re-armed to now; can you confirm this timing is intended versus leaving it cleared for that iteration?

Tests

  • api_flow.mjs expectations are updated consistently with the mock’s new fallback wording. The author reports a full api_flow run with 0 failures and 96 repeated checks across restarted, rate-limited, fail-midway, and quiet scenarios against a private mariadbd and mock; I did not run these tests.

Risks

  • Risk is low and localized to test harness behavior and turn idle/start-limit polling. The only behavioral nuance worth confirming is the quiet-timer re-arm on progress polls in openai.salam. No diff content was truncated.

⚠️ This review was written automatically by an AI and may contain mistakes. It is a helper for maintainers, not a replacement for a human review: check the code yourself before merging.

@BaseMax
BaseMax merged commit 8ec233d into main Nov 19, 2026
2 checks passed
@BaseMax
BaseMax deleted the fix/ai-flow-flake branch November 19, 2026 15:57
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.

1 participant