fix: abort button works while prompt is running + CODEX_PATH_OVERRIDE support#7
Open
roy3003 wants to merge 2 commits into
Open
fix: abort button works while prompt is running + CODEX_PATH_OVERRIDE support#7roy3003 wants to merge 2 commits into
roy3003 wants to merge 2 commits into
Conversation
Allows pointing the SDK at an externally-installed codex binary instead of the one bundled with the npm package, useful when the local CLI version differs from the SDK's bundled copy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Root cause: grammY processes updates sequentially, so the Abort button's
callback query was queued behind the running prompt handler and expired
(>30 s) before being processed.
Two changes:
1. All prompt call sites (text/retry/voice/photo/document) now use
startPromptTask(), a fire-and-forget wrapper that returns immediately
so the grammY update queue is unblocked and Abort callbacks are
processed concurrently.
2. codex_abort callback handler now calls session.abort() first, then
answers the callback query with .catch(() => {}) so an already-expired
query ID never prevents the abort from executing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two bugs found while running TeleCodex in production:
1. Abort button does nothing during a long prompt
Root cause: grammY processes Telegram updates sequentially (one at a time). While a prompt handler is running (which can take minutes), the Abort button's callback query sits in the queue and expires after 30 seconds before it ever gets processed. The log showed:
A secondary issue: the handler called
await ctx.answerCallbackQuery()beforesession.abort(), so if the query was already expired, the await would throw and abort would never execute.2. CODEX_PATH_OVERRIDE env var was wired up in config but never passed to the Codex SDK constructor
The env var was read and stored on
TeleCodexConfigbutresetCodexClient()didn't passcodexPathOverridetonew Codex({...}), so the override had no effect.Fix
Abort fix (bot.ts):
startPromptTask()fire-and-forget wrapper. The handler returns immediately, freeing the grammY update queue so Abort callbacks are processed concurrently with the running prompt.codex_abortcallback handler now callssession.abort()first, then answers the callback query with.catch(() => {})so an already-expired query ID never blocks the abort.CODEX_PATH_OVERRIDE fix (codex-session.ts):
codexPathOverrideto theCodexconstructor inresetCodexClient().Test plan
CODEX_PATH_OVERRIDE=/usr/local/bin/codex— SDK uses the specified binary🤖 Generated with Claude Code