Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Structured response not consistently returned

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

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
api

Línea de trabajo

Empieza con el script de Python reproducido y el punto de entrada model.respond(..., response_format=BookSchema), y sigue cómo se establecen result.parsed y result.structured cuando el razonamiento precede al JSON. Se considera terminado cuando ejecuciones consecutivas marcan de forma consistente la respuesta como estructurada y conservan los datos de BookSchema analizados.

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

Descripción

Environment:

  • Python 3.14.2 on Windows
  • lmstudio-py version 1.5.0
  • LM Studio Bionic 1.0.7 (build 2)

Using the following script, which is essentially the example from the documentation, the returned response is not always structured.

import lmstudio
from lmstudio import BaseModel

# A class based schema for a book
class BookSchema(BaseModel):
    title: str
    author: str
    year: int

model = lmstudio.llm("qwen/qwen3-4b-2507")
result = model.respond("Tell me about The Hobbit", response_format=BookSchema)
book = result.parsed
print(book)

assert result.structured
assert isinstance(book, dict)

Here's the output from two consecutive runs, with the script unchanged. One works, one fails the result.structured assertion, even though it seems the response contains the correct structured JSON, preceded by its reasoning and __LM_STUDIO_INTERNAL_LSEP_SYNTHETIC_REASONING_END_:

(.venv) PS C:\Users> python .\test_structured.py     
{'author': 'J.R.R. Tolkien', 'title': 'The Hobbit', 'year': 1937}
(.venv) PS C:\Users> python .\test_structured.py
Okay, the user asked "Tell me about The Hobbit." Let me start by recalling the basics. The Hobbit is a fantasy novel by J.R.R. Tolkien, written in the early 20th century. It's a key work in the Middle-earth series, which also includes The Lord of the Rings.

First, I should cover the main plot: Bilbo Baggins, a hobbit, is taken on a journey from the Shire to the land of the dwarves, where he helps them reclaim their homeland from a dragon. The story is framed as a quest that starts with a simple adventure but evolves into a deeper exploration of courage, friendship, and personal growth.

I need to mention the setting—Middle-earth, the Shire, the Misty Mountains, the Lonely Mountain, and the dragon Smaug. Highlighting key characters like Bilbo, Gandalf, the dwarves (like Thorin Oakenshield), and others like Gollum or the trolls adds depth.

Themes are important too—like the hero's journey, the contrast between hobbits and other races, and how the story introduces elements of magic and myth. Also, note that The Hobbit is a children's book but has mature themes.

I should also mention its significance in literature and popular culture—how it influenced fantasy genres and inspired films by Peter Jackson. Maybe touch on the tone: whimsical at first, then darker as it progresses.

Avoid getting too detailed or going off track. Keep it structured but conversational. Make sure to clarify that The Hobbit is a standalone story but part of a larger universe. Also, note that it was published in 1937 and is one of the foundational works of modern fantasy.

Check if the user might be looking for a summary, themes, characters, or cultural impact. Since they just said "tell me about," a balanced overview should work. No need to go into deep analysis unless asked.

Finally, end with a note on its legacy—how it's beloved and influential, even though it's not as complex as The Lord of the Rings.
__LM_STUDIO_INTERNAL_LSEP_SYNTHETIC_REASONING_END_f4e9a8d2c6b14d0c9e5f3a7b8c1d2e6a__{
  "author": "J.R.R. Tolkien",
  "title": "The Hobbit",
  "year": 1937
}
Traceback (most recent call last):
  File "C:\Users\test_structured.py", line 15, in <module>
    assert result.structured
           ^^^^^^^^^^^^^^^^^
AssertionError
Lenguaje dominante
Python
Estrellas
881
Forks
166
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

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 lmstudio-ai/lmstudio-python

Todos los issues de lmstudio-ai/lmstudio-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.