Skip to content

feat: auto-reply for recoverable agent interruptions (429/503)#342

Open
ijry wants to merge 7 commits into
xintaofei:mainfrom
ijry:feat/auto-reply
Open

feat: auto-reply for recoverable agent interruptions (429/503)#342
ijry wants to merge 7 commits into
xintaofei:mainfrom
ijry:feat/auto-reply

Conversation

@ijry

@ijry ijry commented Jul 15, 2026

Copy link
Copy Markdown

中文

摘要

为 Codeg 增加前端 自动回复(Auto Reply) 能力,在无人值守场景下自动处理可恢复中断(默认覆盖 HTTP 429 / HTTP 503),按配置延迟发送「继续」等回复,提升长任务执行成功率。

动机

智能体任务可能因限流、临时服务不可用等意外中断。若这些可恢复错误能被自动处理,可显著减少人工值守成本。

行为

  • 按会话开启:在输入框 + 菜单中手动开启/关闭,仅作用于当前会话
  • 规则配置:设置页 /settings/auto-reply 管理规则;内置 429、503 → 回复 继续(可编辑,不可删除)
  • 匹配来源:仅匹配错误/状态信号(如 Claude API retry 的 HTTP status / error),不扫描助手正文
  • 延迟发送:每条规则可配置 delayMs,发送前在输入框上方展示倒计时横幅
  • 可取消:横幅「取消」、用户手动发送/入队都会取消并抑制同一 burst
  • 防循环:规则级冷却时间 + 同一 burst 最大次数上限
  • 安全门控:仅在 connected 且无权限/提问对话框时发送;prompting 时不发

测试计划

  • pnpm exec vitest run src/lib/auto-reply src/hooks/use-auto-reply-engine.test.ts src/i18n/messages.test.ts(30 passed)
  • 手动:开启 Auto Reply → 模拟 429/503 信号 → 确认横幅倒计时后发送「继续」
  • 手动:倒计时中点取消 / 手动发送 → 不再自动发送
  • 手动:设置页编辑延迟/冷却/次数并保存后生效

English

Summary

Add a frontend Auto Reply feature that recovers unattended agent tasks from recoverable interruptions (built-in HTTP 429 / HTTP 503) by auto-sending a configured reply (default 继续) after a visible delay.

Motivation

Agent runs can stall on rate limits or temporary service failures. Automatically handling those recoverable cases improves unattended success rate.

Behavior

  • Per-conversation enable via the composer + menu
  • Settings-managed rules at /settings/auto-reply; builtins 429/503 → 继续 (editable, not deletable)
  • Match error/status signals only (not assistant body text)
  • Per-rule delay with a clear pre-send countdown banner above the input
  • Cancel paths: banner cancel and manual send/enqueue suppress the same burst
  • Loop protection: cooldown + max-per-burst
  • Safety gates: send only when connected and no permission/question dialogs; never while prompting

Test plan

  • pnpm exec vitest run src/lib/auto-reply src/hooks/use-auto-reply-engine.test.ts src/i18n/messages.test.ts (30 passed)
  • Manual: enable Auto Reply → simulate 429/503 → banner countdown then send 继续
  • Manual: cancel during countdown / manual send → no auto-send
  • Manual: edit delay/cooldown/max in settings and verify persistence

jry added 7 commits July 15, 2026 08:47
Document the frontend-only auto-reply feature for recoverable
interruptions (429/503), including per-conversation enable,
settings-managed rules, countdown banner, and loop protection.
Break the frontend-only auto-reply feature into TDD tasks for match
helpers, storage, engine lifecycle, i18n, banner/+ menu, settings, and PR.
Introduce pure rule matching for 429/503, localStorage settings/enable
maps, and a conversation-scoped engine with cancel, cooldown, and
max-per-burst protection.
Add Auto Reply copy across all locales for the + menu toggle,
countdown banner, and settings page. EN and zh-CN use real copy;
other locales keep key parity with EN.
Host the auto-reply engine in the conversation shell, show a pre-send
countdown banner above the composer, cancel pending replies on manual
send/enqueue, and expose a per-conversation enable switch in the + menu.
Add an Auto Reply settings route and nav entry to manage match rules,
delays, cooldowns, and max-per-burst limits. Builtin 429/503 rules stay
editable but not deletable.
Format auto-reply modules for prettier, update onSend via effect
instead of during render, and allow intentional setState in the
signal-sync effect used by the countdown engine.
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