github / github/app

Rate-limit auto-switch silently stops the agent in autopilot

未关闭
#772 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Bugs
主要语言
没有语言数据
星标
2.1k
派生
153
PR 合并指标
30 天内没有已合并 PR

描述

## Summary

When the CLI hits a rate limit and auto-switches to a fallback model, the agent halts at the end of the turn and the user has to type "continue" to resume. This happens even in **autopilot**, which defeats the point of autopilot.

The UI also gives almost no indication this has happened — just a muted gray inline line ("Limit reached. Model changed to Auto.") that's easy to miss in a long scroll.

## Reproduction

1. Run a session in autopilot until you hit a rate limit on the current model.
2. Observe:
- Inline notice: "Limit reached. Model changed to Auto." then "Model changed to Opus 4.7 (1M context) (Medium)."
- Session goes idle.
- Agent does not continue. User must type "continue."

![screenshot](https://github.com/user-attachments/assets/placeholder)

## Root cause

The CLI runtime continues a turn through an auto-switch **only** when the session was started with `continueOnAutoMode` enabled. This app never sets that option, so the runtime takes the "stop and wait" branch every time a switch happens.

In autopilot we already auto-accept the `auto_mode_switch.requested` event ([`src-tauri/src/session/handler.rs:1402-1421`](https://github.com/github/github-app/blob/main/src-tauri/src/session/handler.rs)) and return `AutoModeSwitchResponse::Yes`. But **accepting the switch is not the same as continuing the turn** — the runtime applies the new model and then goes idle anyway.

The relevant SDK contract is documented in the vendored types:

- `SessionUpdateOptionsParams.continue_on_auto_mode` ([`crates/copilot-sdk/src/generated/api_types.rs:7888-7890`](https://github.com/github/github-app/blob/main/crates/copilot-sdk/src/generated/api_types.rs)): "Whether to allow auto-mode continuation across turns."
- `SessionErrorData.eligible_for_auto_switch` ([`crates/copilot-sdk/src/generated/session_events.rs:523`](https://github.com/github/github-app/blob/main/crates/copilot-sdk/src/generated/session_events.rs)): "the runtime will follow this error with an `auto_mode_switch.requested` event (**or silently switch if `continueOnAutoMode` is enabled**)".

## Proposed fix

Push `continue_on_auto_mode` to the runtime as part of mode management:

- `true` when `cached_mode == "autopilot"`
- `false` otherwise

via `session.rpc().options().update(SessionUpdateOptionsParams { continue_on_auto_mode: Some(...), .. })`, called from `Session::set_mode()` ([`src-tauri/src/session/core.rs:1528`](https://github.com/github/github-app/blob/main/src-tauri/src/session/core.rs)) and at session create. The generated SDK type already carries the field, so **no SDK or cross-repo change is needed**.

## Tradeoff

Enabling `continueOnAutoMode` makes the runtime **silently** switch — it suppresses the `auto_mode_switch.requested` event and therefore the interactive `AllowancePrompt` ([`src/components/conversation/AllowancePrompt.tsx`](https://github.com/github/github-app/blob/main/src/components/conversation/AllowancePrompt.tsx)).

- In **autopilot** that's correct: the user opted into "run autonomously, don't pause." They still get the `session.model_change` notice with `cause: "rate_limit_auto_switch"` ("Limit reached. Model changed to …").
- In **interactive / plan** we should keep the existing prompt-and-wait behavior, so the user can choose.

Recommended scope: autopilot-only.

## Out of scope (follow-up)

The inline "Limit reached. Model changed to …" notice is rendered in muted gray and is easy to miss — see `ModelChangeNotice` in [`src/components/conversation/ConversationMessageRow.tsx:198-234`](https://github.com/github/github-app/blob/main/src/components/conversation/ConversationMessageRow.tsx). Worth a separate pass on visibility (banner, accent color, or workspace badge) once the auto-continue behavior is in.

贡献指南

打开贡献指南

调研方向

Start in src-tauri/src/session/core.rs at Session::set_mode() and inspect session creation, then read the continue_on_auto_mode field in crates/copilot-sdk/src/generated/api_types.rs and the existing handler logic in src-tauri/src/session/handler.rs. The change is complete when autopilot continues after an automatic rate-limit switch while interactive and plan modes retain their prompt-and-wait behavior; use the existing session.model_change notice to verify the switch.

由索引模型根据 Issue 内容生成。

评估

技术栈
rust, tauri, typescript
领域
cli, desktop
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
68/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。