Skip to content

fix: disable thinking mode for structured JSON output requests - #34

Open
back2zion wants to merge 1 commit into
nikmcfly:mainfrom
back2zion:fix/disable-thinking-for-json-output
Open

fix: disable thinking mode for structured JSON output requests#34
back2zion wants to merge 1 commit into
nikmcfly:mainfrom
back2zion:fix/disable-thinking-for-json-output

Conversation

@back2zion

Copy link
Copy Markdown

Summary

Models with reasoning/thinking capabilities (e.g. Qwen3 with --reasoning-parser) emit <think> tags before generating content. When combined with response_format=json_object and vLLM's guided decoding, this causes an infinite abort-retry loop — the thinking tokens violate the JSON schema, vLLM aborts, the client retries, and the process hangs indefinitely.

This blocks persona generation at ~50-53 out of 75 agents every time.

Fix

Automatically sets enable_thinking=false via chat_template_kwargs whenever structured JSON output is requested, in both:

  • llm_client.py (general LLM client used for ontology generation etc.)
  • oasis_profile_generator.py (agent persona generation)

Test plan

  • Verified persona generation completes all 75/75 agents without hanging
  • Confirmed JSON responses are valid without <think> tag contamination
  • Non-JSON requests (chat, report) still use thinking mode normally

Models with reasoning/thinking capabilities (e.g. Qwen3 with
--reasoning-parser) emit <think> tags before generating content.
When combined with response_format=json_object and vLLM's guided
decoding, this causes an infinite abort-retry loop because the
thinking tokens violate the JSON schema constraint.

Automatically sets enable_thinking=false via chat_template_kwargs
whenever structured JSON output is requested.
Pxls21 added a commit to Pxls21/MiroFish-Offline that referenced this pull request Jul 11, 2026
…knobs; hunks rejected where broken or regressive

TAKEN: env-tunable parallelism (GRAPH_BUILD_BATCH_SIZE, PROFILE_PARALLEL_COUNT,
PROFILE_SEARCH_WORKERS); ThreadPool chunk processing in graph_builder +
neo4j add_text_batches; parallel edge/node searches + background profile
writes in oasis_profile_generator; max_tokens=4000 on profile JSON calls
(anti vLLM-infinite-generation), merged as a union with PR nikmcfly#34 enable_thinking.

REJECTED (with reasons):
- run.py debug=True hardcode + .env DEBUG=True: author debug leftovers
- embedding_service URL hack (broken string-comment splice): PR nikmcfly#50 already
  landed the correct OpenAI-format auto-detect version
- ALL report_agent.py hunks: they REGRESS prompts to Chinese-language guidance
  (undoing upstream 313fe64 English-only), gut the ReACT loop
  (min_tool_calls 3->0), and drop inter-section context in parallel gen
- REPORT_PARALLEL_SECTIONS knob removed from config/.env: its only consumer
  was the rejected report_agent hunk; a dead knob is a lying knob
Pxls21 added a commit to Pxls21/MiroFish-Offline that referenced this pull request Jul 11, 2026
…erfactual endpoint

FOUR increments (two staged commits squashed for transfer):
1. report_agent._ensure_prompt_budget -- deterministic chars/3 token guard
   on all 4 accumulated-context LLM calls; drops middle messages oldest-
   first, never system/instruction/final-turn; LLM_CONTEXT_WINDOW env
   (default 16384); fail-loud event report.context_truncated; raises with
   exact sizes when structurally impossible (gate-7 400 root cause).
2. llm_client.chat(disable_thinking=) opt-in extra_body flag (PR nikmcfly#34 only
   covered response_format) + defensive preamble strip at report-chat
   returns with report.chat_preamble_stripped event.
3. Twitter interview 400 fix: instance-level override of oasis
   perform_interview which double-prepends role=system (camel context
   creator already returns it) -- dedup at our call site, Reddit untouched;
   root-caused by reading installed camel-oasis 0.2.5 / camel-ai 0.2.78.
4. Counterfactual branch endpoint hand-ported from nativ3ai c492630:
   POST /api/simulation/<id>/counterfactual + manager clone/inject +
   scheduled-event firing in all 3 child round loops, instrumented
   (simulation.counterfactual_create span, sim.child.scheduled_event_fired
   instant span), comments Englishized. Backend only; Vue panels not
   ported (conflict with our PR nikmcfly#51 frontend picks -- separate decision).
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.

1 participant