Skip to content

fix(types): handle reasoning.encrypted content block type from Grok models#1732

Draft
potb wants to merge 7 commits intocode-yeongyu:devfrom
potb:fix/1588-reasoning-encrypted
Draft

fix(types): handle reasoning.encrypted content block type from Grok models#1732
potb wants to merge 7 commits intocode-yeongyu:devfrom
potb:fix/1588-reasoning-encrypted

Conversation

@potb
Copy link
Contributor

@potb potb commented Feb 10, 2026

Closes #1588

Grok models return reasoning.encrypted content blocks. We only check for "reasoning" and "thinking", so these blocks get silently dropped during validation, extraction, and formatting.

Added reasoning.encrypted to the ThinkingPartType union and THINKING_TYPES set, then updated all downstream checks. Content extraction guards on && part.text so encrypted blocks without text are safely skipped.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 14 files

Confidence score: 4/5

  • This PR looks generally safe to merge, but there is a user-facing risk: reasoning.encrypted parts are filtered out before formatting in src/tools/background-task/full-session-format.ts and src/tools/background-task/modules/formatters.ts, so the new handling is unreachable and content gets dropped even when includeThinking is true.
  • The test in src/hooks/thinking-block-validator/reasoning-encrypted.test.ts is tautological and doesn’t exercise production logic, so it won’t catch regressions in the validator.
  • Pay close attention to src/tools/background-task/full-session-format.ts, src/tools/background-task/modules/formatters.ts, src/hooks/thinking-block-validator/reasoning-encrypted.test.ts - reasoning.encrypted handling is dropped and test coverage is ineffective.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/hooks/thinking-block-validator/reasoning-encrypted.test.ts">

<violation number="1" location="src/hooks/thinking-block-validator/reasoning-encrypted.test.ts:5">
P2: Test is tautological: it only checks a locally defined helper instead of exercising production logic, so it provides no real coverage of the thinking-block validator.</violation>
</file>

<file name="src/tools/background-task/full-session-format.ts">

<violation number="1" location="src/tools/background-task/full-session-format.ts:138">
P2: `reasoning.encrypted` parts are filtered out before formatting, so the newly added handling is unreachable and the content is discarded.</violation>
</file>

<file name="src/tools/background-task/modules/formatters.ts">

<violation number="1" location="src/tools/background-task/modules/formatters.ts:305">
P2: `reasoning.encrypted` parts are filtered out before formatting, so the newly added handling is unreachable and these parts are dropped even when `includeThinking` is true.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@potb potb marked this pull request as draft February 10, 2026 18:08
@potb potb force-pushed the fix/1588-reasoning-encrypted branch from 4aec122 to d45b87f Compare February 10, 2026 18:16
@potb potb force-pushed the fix/1588-reasoning-encrypted branch from d45b87f to f634150 Compare February 10, 2026 18:23
The filter that normalizes message parts before formatting only checked
for 'thinking' and 'reasoning', so reasoning.encrypted parts were
silently dropped even when includeThinking was true.
@potb
Copy link
Contributor Author

potb commented Feb 10, 2026

@cubic-dev-ai recheck

@cubic-dev-ai
Copy link

cubic-dev-ai bot commented Feb 10, 2026

@cubic-dev-ai recheck

@potb I have started the AI code review. It will take a few minutes to complete.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 13 files

Confidence score: 5/5

  • Low-severity test quality concern only; no concrete user-facing regression is indicated, so this looks safe to merge.
  • src/hooks/thinking-block-validator/reasoning-encrypted.test.ts validates a local helper instead of production logic, so the test could pass even if the real thinking-family check is wrong.
  • Pay close attention to src/hooks/thinking-block-validator/reasoning-encrypted.test.ts - test may not exercise actual production behavior.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/hooks/thinking-block-validator/reasoning-encrypted.test.ts">

<violation number="1" location="src/hooks/thinking-block-validator/reasoning-encrypted.test.ts:5">
P3: This test defines and validates a local helper instead of exercising production logic, so it will pass even if the real thinking-family check is incorrect (e.g., `startsWithThinkingBlock` still ignores `reasoning.encrypted`). It doesn’t provide regression protection for the intended change.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…thThinkingBlock and findPreviousThinkingContent

Address review feedback (identified by cubic): the thinking-block-validator
hook was missing reasoning.encrypted in two internal functions, and the test
was tautological (testing a local helper instead of production logic).

- Add reasoning.encrypted to startsWithThinkingBlock so messages starting
  with encrypted reasoning are recognized as having a thinking block
- Add reasoning.encrypted to findPreviousThinkingContent so encrypted
  reasoning from prior turns can be recovered
- Rewrite test to exercise createThinkingBlockValidatorHook directly with
  message fixtures instead of a locally defined helper
@potb potb changed the title fix(types): handle reasoning.encrypted content block type from Grok models (#1588) fix(types): handle reasoning.encrypted content block type from Grok models Feb 10, 2026
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.

[Bug]: Grok 4.1 Fast 'reasoning.encrypted' data format causing Provider returned error in v3.2.4

1 participant