Skip to content

ai tests: telegram flow accepts cloud chat answers and waits for the full guest answer - #3695

Merged
BaseMax merged 3 commits into
mainfrom
fix/ai-telegram-flow
Nov 20, 2026
Merged

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

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 19, 2026

Copy link
Copy Markdown
Member

The last failing suite of the AI job, telegram_flow (76 passed, 3 failed on main):

  • "the transcript is then answered like a typed message" and "typed messages keep working while voice is off": the job sets AI_SANDBOX_URL, so Telegram chats of linked accounts are cloud chats, and the engine mock answers a cloud session with "Tool said (salam-agent): ..." instead of "Echo: ...". These waits only accepted Echo; they now accept either, like the later checks of the same suite already did (also three other waits and the empty transcript check).
  • "guest limit stops the chat": the guest's first answer already ends with "Guest messages left: 1", so waiting for /Guest messages/ matched at once and the next two messages could arrive while an answer was pending, which the handler refuses, so the limit text never came. The test now waits for the full first answer and then for "Guest messages are used up".

Locally with the pinned compiler, private mariadb and the speech, Telegram and engine mocks: before, the two cloud chat checks failed on an idle machine; after, 3 of 4 full runs gave 79 passed, 0 failed (the fourth failed an unrelated check about cutting a long Persian title that CI does not fail).

…st check waits for each footer

Linked accounts get cloud chats when the sandbox is configured, and the
engine mock answers those with 'Tool said' instead of 'Echo'. The guest
limit check matched the first answer's footer instead of waiting for the
second one, so the third message could arrive while the second was
still pending.
@BaseMax
BaseMax requested a review from a team as a code owner November 19, 2026 23:57
@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=26d5bda2526c7fab8262d1325346c5dc4d9a79d3

🤖 Salam AI review

Verdict: 🛠️ Changes needed before merging

commit 26d5bda · 1 files · +8 −8 · model salam

Summary

This pull request updates ai/backend/tests/telegram_flow.mjs to accept either Echo: or Tool said assistant replies in several Telegram flow waits and to tighten the guest-limit sequence so it waits for the full first answer before sending follow-up messages. The prefix changes align most waits with the described cloud-chat response format, and the guest-limit sequencing addresses the race where an early footer match allowed messages to be sent while a reply was pending. The changes are mostly correct, but the first guest-answer wait in main() still requires an Echo: prefix and may not handle cloud-chat replies consistently with the other updated waits.

What changed

  • Broadened several waits in ai/backend/tests/telegram_flow.mjs to accept assistant replies matching either Echo: or Tool said, including transcript follow-up replies, post-media answer waits, the empty-transcript assertion, typed messages while voice is off, and a Persian guest voice follow-up.
  • In main(), changed the first guest answer wait to /Echo:[\s\S]*Guest messages left/ and the later limit check to /Guest messages are used up/ so the test waits for the complete first response before sending additional guest messages and no longer matches the intermediate footer too early.

Review

  • ai/backend/tests/telegram_flow.mjs, main() (guest first-answer wait): the updated pattern requires an Echo: prefix while also requiring the Guest messages left footer, but unlike the other waits modified in this diff it does not accept the Tool said prefix described for cloud-chat answers. If this guest conversation can receive cloud-chat responses in the environment where AI_SANDBOX_URL is set, this wait will not match and the suite can still fail. Can you confirm whether chat 1001 is always a non-cloud/echo chat here; if not, the pattern should allow the Tool said form as well while preserving the requirement for the full footer?

Tests

  • This change only adjusts assertions and waits in ai/backend/tests/telegram_flow.mjs. The PR description reports local runs with the pinned compiler and the relevant mocks where the targeted failures were addressed in most runs. I did not run a build, test, or command.

Risks

  • Correctness depends on lastText/sent matching against the complete answer text that includes the guest footer; if these helpers observe only a partial or latest fragment, the stricter wait could behave differently than intended. Can you confirm their matching behavior covers the full response text in this flow?

⚠️ 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 85e1a1b into main Nov 20, 2026
12 checks passed
@BaseMax
BaseMax deleted the fix/ai-telegram-flow branch November 20, 2026 00:01
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