microskills: a proposer reply with `"extractors": null` (or another wrongly typed field) aborts the fold, and the next session start pays for the proposer again

Abierto
#173 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
ai, backend

Línea de trabajo

Start with parse_payload and _rx in tokeneconomizer/microskills/distiller.py, then read the existing coverage in tests/test_generic_microskills.py. Reproduce the malformed proposer replies described in the issue and check how Distiller.update and fold_locked handle them. Done means wrongly typed entries are safely ignored, invalid patterns do not abort folding, and tests cover these cases.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What happens

parse_payload (tokeneconomizer/microskills/distiller.py) checks that the proposer's reply is JSON, but not the types inside it:

  • {"extractors": null, "facts": []} raises TypeError: 'NoneType' object is not iterable.
  • An extractor whose pattern is a list raises TypeError: unhashable type: 'list' in _rx, which only catches re.error.
  • A fact whose detector is a string raises AttributeError in _ground.

The guard added for #131 only covers the runner call. These errors come later, out of Distiller.update, so they abort fold_locked before folded.json or the ledger is written. The session stays pending, so the next session start folds it again and calls the proposer again.

Repro

Offline: six sessions through hook.main, with TE_MICROSKILLS=on, the default k = 3, and the proposer stubbed to answer {"extractors": null, "facts": []}.

paid proposer calls: 9        (2 expected)
folded.json: ['s0']
ledger records: 1
errors.log tail: TypeError: 'NoneType' object is not iterable

Why it matters

  • A model that writes null for "no extractors" makes every later session start call the proposer again. Each of those calls is billed, and none of them reach the ledger.
  • The envfacts layer, which makes no model calls, stops learning too.

A side note, not part of the fix

PROPOSER_SYSTEM asks for "ONLY a JSON list of <=4 such objects", and a few lines later for "a JSON OBJECT {extractors, facts}". A reply that follows the first instruction is dropped without any notice. The prompt is pinned by a hash in tests/test_generic_microskills.py, so I've left it alone.

I have a fix with tests ready: parse_payload keeps only entries with the expected types, and _rx returns None for a non-string pattern. Happy to open a PR if that approach works for you.

Lenguaje dominante
Python
Estrellas
5.6k
Forks
344
Merge medio
14 h 41 min
PR fusionados (30 d)
54

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/TokenEconomizer

Todos los issues de microsoft/TokenEconomizer

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.