Disabled extensions' stale state persists in session extension_data and gets injected into model context
- Lenguaje dominante
- Rust
- Estrellas
- 54.2k
- Forks
- 6.2k
- Merge medio
- 3 d 4 h
- PR fusionados (30 d)
- 240
Descripción
## Summary
When an extension (e.g. `todo`) is enabled, used in a session, then later disabled in config, its state persists in the session's `extension_data` JSON field. On every subsequent session load, the stale state is read back via `EnabledExtensionsState::from_extension_data` and injected into the model's context, causing the model to auto-resume old tasks for previous requests from the user instead of responding to the user's actual current message.
## Root cause
In `crates/goose/src/agents/agent.rs`, the session's `extension_data` is loaded unconditionally at lines ~1208-1215 and ~1264:
```rust
let extensions_state = EnabledExtensionsState::from_extension_data(&session.extension_data);
```
There is no check to skip `extension_data` entries for extensions that are currently disabled in the user's config. The `todo.v0` key persists in `extension_data` even after the `todo` extension is set to `enabled: false` in `config.yaml`.
## Reproduction
1. Enable the `todo` extension in `config.yaml`
2. Start a session and have the model generate a TODO list with unchecked items
3. Disable the `todo` extension in `config.yaml` (`enabled: false`)
4. Restart Goose and resume the session
5. Send a trivial message like "Hello, respond only with Hello"
6. The model will begin executing unchecked TODO items instead of responding to the greeting
## Evidence
- 5 sessions on the reporting machine have non-empty TODO lists with unchecked items in `extension_data` despite the `todo` extension being disabled in config
- In the primary affected session, sending "Hello, respond only with Hello" caused the model to start reading and editing a grievance document, an unchecked TODO item, instead of responding to the greeting
- Clearing `todo.v0` from `extension_data` resolves the behavior immediately
## Proposed fix
In `agent.rs`, filter out `extension_data` entries for extensions that are currently disabled before passing them to `EnabledExtensionsState::from_extension_data`. This prevents stale state from disabled extensions from being injected into the model's context.
Guía de contribución
Línea de trabajo
The issue is in crates/goose/src/agents/agent.rs around lines 1208-1215 and 1264, where session.extension_data is loaded. Start by examining the EnabledExtensionsState::from_extension_data function and the session data structure. The fix involves filtering extension_data keys based on the current enabled extensions from the user's config. Check how extensions are configured and loaded to understand the filtering logic. A test should verify that disabled extension data is not injected into the model context.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Área
- ai-infra-agents, backend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 65/100