Repository navigation
fix: keep receiving while a turn runs; /new, /model and /think act on the conversation - #156
Conversation
… the conversation Responsiveness - The Chat SDK's Telegram polling awaits the message handler, and the handler awaited the whole agent turn. While a turn ran, nothing was received: /cancel could not interrupt it and later messages were not delivered until it ended. Handlers now start the work and return. Ordinary messages are chained per chat in arrival order; commands skip the chain. A test drives the adapter's real polling loop. - Since a message now counts as delivered before its turn ends, a turn cut off by a restart is neither redelivered nor repeated. A marker file survives only an interrupted turn, and the next gateway tells the owner which request was cut off. Commands - /new only disposed the session; the next prompt reopened the newest transcript, which was the one just closed. It now leaves a marker so the next session starts empty, also across a gateway restart, and marks memory for re-injection. - /model only wrote pi's default, and pi restores a session's model from its transcript. It now also switches the conversation it is sent in (after the running turn, if any) and reports when it cannot. - /think shows or sets the thinking level. - /status shows session cost, token and cache use and thinking level, and uses a cached update check instead of waiting for `npm view`. Other - With pi, image attachments go to the model as images (up to five), sniffed from the file rather than trusted from the chat's type. - No "Agent returned no response" after a cancel; no typing indicator after an answer on Telegram, where the "clear" call is another typing action.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9937235cc1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
From the independent review of this branch; each was reproduced by a probe against the real Chat SDK, Telegram adapter and pi SDK. Interrupted requests - A message waiting at Telegram when the gateway started got a false "I was restarted" notice while its turn was running: the markers were read after polling had begun, so the gateway found its own. They are now read before chat.initialize(). - A message accepted but still waiting its turn was lost on restart without a word: the marker was written only when its turn started. It is now written when the message is accepted, and stop() stops polling first. One notice per chat lists every request that was cut off or never started. A notice that could not be posted is tried again at the next start. Order - "Starts with /" was the wrong test for skipping the queue. A command the gateway does not know is a prompt for the agent and overtook earlier messages; /new moved a message queued before it into the new conversation. Only pre-turn commands, descriptors marked `immediate` and pairing's /start skip the line now. - Button handlers are detached too: a /model press waiting on the agent blocked polling like the message handlers used to. /new - A restart in the middle of the first turn after /new started a third, empty session, and "continue" reached a model with no history. The marker now names the fresh session's file, and an existing file is resumed. /model, /think - A deferred switch reported success and then failed silently, with the default already written. What can be checked is checked before answering, a deferred failure is posted to the chat, and a model that is unknown or has no credentials is not written as the default. - "Busy" is the adapter queue, not only a running prompt, so a switch during a compaction is deferred instead of blocking. - The conversation keeps its thinking level across a model switch. - /think answers during a turn and applies after it. Its replies go through the transport, so the markup renders. - The /model menu marks the conversation's model as current. /cancel - It aborted the session the chat currently points at, which after /topic is not the one whose turn is running, and it could not stop a turn that had not reached the model yet. The turn's abort signal now exists from acceptance and is found by chat. With nothing running it says so instead of "Cancelled." Tests - Three test files get their own roundhouse directory; the /model test no longer writes pi's real settings.
Independent review and what was done about itA separate reviewer probed the branch against the real Chat SDK, Telegram adapter and pi SDK (stubbed network). Each finding was checked before acting on it. Fixes are in 692b858.
Still not verified by anyone: these paths against real Telegram and a real model; Slack; the Kiro backend. State at 692b858: 787 tests, typecheck clean. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 692b858beb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -502,9 +558,19 @@ export class Gateway { | |||
| } | |||
| const result = await handler({ value: event.value, thread: event.thread }); | |||
There was a problem hiding this comment.
Queue topic button actions behind earlier messages
When a message is queued behind a running turn, clicking a topic-selection button still invokes handleTopicAction immediately instead of joining the chat’s intake queue. It changes the active topic before the queued message computes applyTopicOverride, so that earlier message is sent to the newly selected conversation rather than the one active when it arrived. Queue topic-selection actions with the chat’s messages.
Useful? React with 👍 / 👎.
| ? `⚠️ I was restarted before I finished your request:\n${list}\nI have not run it again. Anything already done is in the conversation; say "continue" to pick it up, or send it again.` | ||
| : `⚠️ I was restarted before I finished these requests:\n${list}\nI have not run them again. Anything already done is in the conversation; say "continue", or send again what you still want.`; | ||
| try { | ||
| await this.chat.thread(threadId).post(text); |
There was a problem hiding this comment.
Chunk interrupted-request notices before posting
If many requests with full-length previews from one chat are interrupted, this combined notice can exceed the platform’s message limit. The direct thread.post(text) bypasses the message-splitting path; when posting fails, the markers are retained and the oversized notice is retried on each startup until the markers expire, so the owner may never be notified. Split or cap the notice before posting.
Useful? React with 👍 / 👎.
Why
A read-only survey of the Telegram experience, and the review of #155, found three defects that mattered more than any missing feature. Each was confirmed against the Chat SDK or pi source, and the first by an experiment with the real adapter.
/cancelcould not interrupt anything, and messages sent meanwhile were not delivered until the turn ended. This came in with the Chat SDK bump in fix(security): allowlist bypass, fail-closed gateway; move to pi 1.6 #153./newreopened the conversation it had just closed.restart()disposed the session, and the next prompt calledSessionManager.continueRecent, which opens the newest transcript./modelnever reached an existing conversation. It wrote pi's default, and pi restores a session's model from its transcript.What changes
Responsiveness
/is handled at once.~/.roundhouse/in-flight/survives only an interrupted turn, and the next gateway tells the owner which request was cut off. This also closes finding 1 of the feat: compaction that follows the model, one-time standing context, reliable restart #155 review (a restart mid-turn re-ran the request).Commands
/newleaves a marker so the next session starts empty, also if the gateway restarts before the next message, and marks memory for re-injection./modelswitches the conversation it is sent in, after the running turn if there is one, and says why when it cannot (unknown model, no credentials, a window the conversation has outgrown)./think [level]shows or sets the thinking level./statusshows session cost, token and cache use and the thinking level, and uses a cached update check instead of waiting up to 10 s fornpm view.Other
/cancel.Behaviour changes to know
/cancel,/statusand other commands now take effect during a turn./modelchanges the current conversation's model, which makes the next reply re-read the conversation without the prompt cache.Verification
npm test: 777 passing.npm run typecheck: clean.test/telegram-slash-integration.test.tsruns the adapter's real polling loop against a stubbed Bot API: a turn is blocked, polling continues,/cancelarrives and aborts it. It fails when a handler awaits the turn again.test/pi-adapter-session.test.ts:/newacross a simulated restart;/modelapplied, refused and deferred;/think; images.test/gateway-experience.test.ts: order per chat, commands skipping the line, the interrupted-turn notice, typing.