anthropics / anthropics/claude-agent-sdk-typescript

Lower-priority mode is unreachable from non-interactive and SDK sessions

Offen
#456 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Shell
Sterne
1.8k
Forks
226
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### What we are trying to do

We build [T3 Code](https://github.com/t3-oss/t3code), a GUI that drives Claude Code through
`@anthropic-ai/claude-agent-sdk`. Users run threads from a browser, a desktop app and a phone,
often against a server on another machine.

When a session usage limit is reached, the terminal CLI offers "Continue now at lower priority".
We would like a thread that hits the limit to take that offer and keep working, ideally without
the user having to answer anything. Today it cannot, because the offer only exists in the
interactive terminal.

### What blocks it

Three things, checked against CLI 2.1.263.

1. `/low-priority` is declared with `supportsNonInteractive: false` and `isHidden: true`, so an
SDK session can neither see it nor run it. For contrast, `/compact` is
`supportsNonInteractive: true`, and we do drive that one through the SDK today.
2. The other way in is the "usage limit reached" terminal dialog that lists lower priority next
to extra usage and auto-resume. That dialog is terminal UI. It does not arrive as a
`request_user_dialog`, whose only kind today is `refusal_fallback_prompt`.
3. Nothing else arms it. There is no setting, environment variable or control request, unlike
auto-resume, which has `autoContinueAtUsageLimit`.

Reproduction, on an account where the mode is available in the terminal:

```
claude --print --verbose --output-format stream-json "hi"
```

The `init` message lists the session's slash commands. `low-priority` is not among them, and
sending `/low-priority` as a prompt does nothing.

### What does reach us

`rate_limit_event` forwards the whole `rate_limit_info` object, so fields the SDK types do not
declare still arrive, `lowPriorityOffer` among them. We can therefore tell that an account has
been offered lower priority. We just cannot act on it.

### What we would like

Any one of these unblocks us, in the order we would prefer them:

1. A setting that opts a session into lower priority automatically when the limit is reached,
alongside `autoContinueAtUsageLimit`. This is the one that fits a remote client, where there
is often nobody at a terminal to answer a prompt.
2. `supportsNonInteractive: true` on `/low-priority`, so an SDK consumer can send it as a
command when it sees the offer.
3. The usage-limit dialog emitted as a `request_user_dialog` kind, so a client that declares it
can render the same choice its own way and answer it.

Whichever route, please also declare `lowPriorityOffer` and its companions on
`SDKRateLimitInfo`, so detecting the offer does not depend on an undeclared field.

Filing here because the SDK is the interface we build against, but the change looks CLI-side:
the command flag, a settings key and the dialog kind all live in the binary the SDK spawns.
Happy to move this to `anthropics/claude-code` if that routes better.

### Environment

- Claude Code 2.1.263. On Linux we pass the user's own install as
`pathToClaudeCodeExecutable`, so this is the binary the SDK session runs.
- `@anthropic-ai/claude-agent-sdk` 0.3.260
- Linux, subscription auth

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.