Skip to content

fix(reflect): cap structured output retry budget - #2433

Merged
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
koriyoshi2041:rios/cap-reflect-structured-retries
Jun 29, 2026
Merged

fix(reflect): cap structured output retry budget#2433
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
koriyoshi2041:rios/cap-reflect-structured-retries

Conversation

@koriyoshi2041

Copy link
Copy Markdown
Contributor

Summary

  • cap the second-pass reflect_structured extraction retry budget so provider-specific empty structured-output responses do not consume the full reflect timeout
  • keep the existing graceful degradation behavior: the natural-language reflect answer still returns when structured extraction fails
  • add a focused regression test for the short retry budget

Context

This is motivated by #2431, where plain reflect can succeed while response_schema triggers repeated empty provider responses with finish_reason=length.

Tests

  • uv run pytest tests/test_reflect_agent.py::TestReflectStructuredOutput::test_structured_output_uses_short_retry_budget -q
  • uv run ruff check hindsight_api/engine/reflect/agent.py tests/test_reflect_agent.py
  • uv run ruff format --check hindsight_api/engine/reflect/agent.py tests/test_reflect_agent.py
  • git diff --check

Note: full uv run pytest tests/test_reflect_agent.py -q reached 50 passing tests, then hit local environment setup errors unrelated to this patch: missing HINDSIGHT_API_LLM_API_KEY for real-LLM tests and a local SOCKS proxy requiring socksio during Hugging Face model initialization.

@koriyoshi2041
koriyoshi2041 force-pushed the rios/cap-reflect-structured-retries branch from ccef070 to 689633f Compare June 27, 2026 07:23
@nicoloboschi
nicoloboschi merged commit 85599f3 into vectorize-io:main Jun 29, 2026
87 checks passed
r266-tech added a commit to r266-tech/hindsight that referenced this pull request Jul 1, 2026
…raction

vectorize-io#2433 capped the structured retry budget but the structured second pass never
received an output-token budget, so on reasoning/preamble models the provider
default is exhausted before JSON is emitted (finish_reason=length, empty
content) and structured reflect degrades to None. Thread the reflect max_tokens
through _generate_structured_output (and _process_done_tool) as
max_completion_tokens, mirroring the plain reflect calls. Fixes vectorize-io#2431.
nicoloboschi pushed a commit that referenced this pull request Jul 20, 2026
… extraction call (#2431) (#2486)

* fix(reflect): thread max_completion_tokens into structured-output extraction

#2433 capped the structured retry budget but the structured second pass never
received an output-token budget, so on reasoning/preamble models the provider
default is exhausted before JSON is emitted (finish_reason=length, empty
content) and structured reflect degrades to None. Thread the reflect max_tokens
through _generate_structured_output (and _process_done_tool) as
max_completion_tokens, mirroring the plain reflect calls. Fixes #2431.

* test(reflect): cover structured-output max_completion_tokens threading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants