Skip to content

feat: disable reasoning mode for AI threat generation#33

Merged
ellipse2v merged 1 commit into
ellipse2v:mainfrom
zhangtianqi-james:feat/disable-thinking
Jun 14, 2026
Merged

feat: disable reasoning mode for AI threat generation#33
ellipse2v merged 1 commit into
ellipse2v:mainfrom
zhangtianqi-james:feat/disable-thinking

Conversation

@zhangtianqi-james

Copy link
Copy Markdown
Contributor

Reasoning tokens consume the same max_tokens budget as content tokens, not a separate quota. When reasoning is enabled, most of the budget is allocated to internal reasoning, leaving severely limited headroom for actual output. Under this constraint, batch threat generation responses are truncated mid-JSON and cannot be parsed.

Set enable_thinking=False so the full token budget is available for content generation, resolving the truncation.

Some modern LLMs spend a significant portion of max_tokens on internal reasoning, leaving insufficient budget for structured JSON output. This causes batch threat generation responses to truncate, producing invalid JSON that cannot be parsed.

Pass enable_thinking=False to LiteLLM acompletion() calls so that 100% of the token budget goes to content generation.
@ellipse2v

Copy link
Copy Markdown
Owner

Thanks for the fix — the root cause analysis is correct, reasoning tokens competing with the output budget is exactly the kind of issue that causes silent JSON truncation in batch generation.

I'll merge this as-is. As a follow-up I'll make enable_thinking configurable via ai_config.yaml at the provider level so it can be re-enabled for use cases with a dedicated token budget.

@ellipse2v
ellipse2v merged commit bb82848 into ellipse2v:main Jun 14, 2026
1 check passed
ellipse2v added a commit that referenced this pull request Jun 14, 2026
 enable_thinking was hardcoded to False in litellm_client.py (PR #33). This moves it to a per-provider config field so Anthropic extended thinking can be enabled when a sufficient
  max_tokens budget is available.

  threat_analysis/ai_engine/providers/litellm_client.py
  - generate_content(): replace hardcoded False with bool(self.provider_config.get("enable_thinking", False)) — reads from ai_config.yaml, defaults to False
  - check_connection(): remove enable_thinking=False — the health ping uses max_tokens=1 and never benefits from reasoning mode

  config/ai_config.yaml
  - Add enable_thinking as a commented-out field under the mistral provider block, with a note that it should only be set to true alongside a large max_tokens budget

  tests/test_litellm_provider.py
  - test_enable_thinking_defaults_to_false: asserts acompletion receives enable_thinking=False when the field is absent from provider config
  - test_enable_thinking_true_from_provider_config: asserts enable_thinking=True is forwarded to acompletion when explicitly set in provider config
  - test_check_connection_does_not_pass_enable_thinking: asserts enable_thinking is absent from the health check call regardless of provider config
@zhangtianqi-james
zhangtianqi-james deleted the feat/disable-thinking branch June 18, 2026 10:11
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