[codex] normalize forwarded Codex commands#110
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d27d3ecd4
ℹ️ 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".
|
|
||
|
|
||
| _FORWARDED_COMMAND_RE = re.compile( | ||
| r"^/(?P<name>[A-Za-z0-9_]+)(?:@[A-Za-z0-9_]+)?(?P<rest>.*)$" |
There was a problem hiding this comment.
Match forwarded commands across newlines
When a forwarded command has a multi-line argument, such as /goal.继续\n补充说明 or /goal@CodexBot first\nsecond, this regex does not match because Python's .* stops at the first newline. _normalize_forward_command_text then returns the original text, so the newly added dot normalization and bot-mention stripping are skipped for exactly the kind of long goal/prompt text users can send from Telegram.
Useful? React with 👍 / 👎.
Summary
/goal.继续...becomes/goal 继续...before reaching Codex@...text in command arguments/goalarguments and bot mention handlingRoot cause
The VPS log showed
Failed to send keyswas emitted after the bot pasted text and pressed Enter, then detected the Codex input row still looked pending. In the reported screenshot the first command used/goal.继续完成验证; Codex expects a space after/goal, so the malformed forwarded slash command could remain pending and surface as a low-level send failure.Validation
uv run ruff check src/ tests/uv run ruff format --check src/ tests/uv run pyright src/telegram_codex_bot/uv run pytest --tb=short -q(579 passed)