aaif-goose / aaif-goose/goose

Support Anthropic preserved-thinking requirements

Abierto
#11,800 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
54.2k
Forks
6.2k
Merge medio
3 d 2 h
PR fusionados (30 d)
262

Descripción

Claude Fable 5.1 binds preserved thinking to the model and the exact `system`, `tools`, and messages that preceded it.
Changing that prefix can cause a `400 invalid_request_error`. [Anthropic preserved-thinking migration guide](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking)

[#11022](https://github.com/aaif-goose/goose/pull/11022) established the foundation by making normal Goose message assembly append-only for prompt caching.
It stopped moving turn context between requests and added prefix-stability tests.

The remaining gaps are history rewriting, system prompt changes, tool changes, model switching, and mismatch handling.

### Tracked work

#### 1. Remove ongoing tool-pair summarization ([#11764](https://github.com/aaif-goose/goose/issues/11764))

- [ ] Complete [#11764](https://github.com/aaif-goose/goose/issues/11764), which removes a background rewrite of earlier tool messages.
https://github.com/aaif-goose/goose/pull/11817

#### 2. Keep the system prompt stable

- [ ] Deliver subdirectory hints discovered mid-session as an agent-only message instead of rewriting `system` (#11284, #10330).

Hints are the only mid-session `system` rewrite left. Mode changes and the timestamp never reach the shipped template. Extension toggles are tracked under 3.

#### 3. Make tool changes append-only

- [ ] Keep `system` and `tools` prefix-stable when an extension is enabled or disabled mid-session (#11905).

Confirmed under enforcement: enabling an extension mid-round grows `tools` in place and drops the block.

#### 4. Add Fable 5.1 enforcement and recovery

- [x] Add Fable 5.1 model support (#11836)
- [x] Test prefix mismatch behavior (verified live on Fable 5.1 with `block_binding`)
- [x] Define recovery for prefix mismatches: `drop_block` by default, one retry with thinking history stripped on a signature 400 (#11836)

#### 5. Keep the assistant turn in model order

- [x] Stop relocating streamed thinking onto the tool-call message in both loops (#11837)

#### 6. Smaller prefix rewrites to close after the above

- [ ] `enrich_unclaimed_tool_errors` rewrites earlier tool results per request (unrolled loop).
- [ ] Unanswered tool requests are stripped from an earlier assistant message after a cancelled tool round.
- [ ] Compaction must land between turns, never with a tool_use awaiting its result.
- [ ] Unknown response block types are dropped from the replay.
- [ ] Default effort sends `thinking: disabled` to Opus 5, so binding is never attached by default.

#### Findings from the first implementation pass

- The most common failure had nothing to do with prefix edits: Opus 4.7+ returns thinking blocks with empty text plus a signature, and goose dropped them on parse, so every tool round replayed the turn without its reasoning. Fixed in #11836.
- Fable 5.1 also binds each signature to the earlier blocks in the same assistant message. Both agent loops reordered `[thinking, text, tool_use]` to `[text, thinking, tool_use]`, which drops the block on every tool round. Fixed in #11837.
- Enforcement is opt-in for accounts created before 2026-08-31. Goose now opts in with `drop_block` so breaks are visible in `input_transformations` rather than silent.
- Mid-conversation `role: "system"` is accepted by Opus 5, Sonnet 5, Opus 4.8, and Fable; 4.7 and older return 400.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.