Skip to content

fix(agent-session): πŸ› propagate reasoning_content_constrained to all provider types - #160

Merged
jorben merged 3 commits into
masterfrom
fix/reasoning-propagation
Apr 30, 2026
Merged

fix(agent-session): πŸ› propagate reasoning_content_constrained to all provider types#160
jorben merged 3 commits into
masterfrom
fix/reasoning-propagation

Conversation

@HayWolf

@HayWolf HayWolf commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix reasoning_content_constrained flag only being applied to openai-compatible providers
  • Propagate the flag to all provider types (e.g., DeepSeek V4 Pro via ZenMux)
  • Some providers require every assistant message to carry reasoning_content when thinking is enabled, otherwise API returns HTTP 400

Changes

  • src-tauri/src/core/agent_session.rs: Restructure compatibility handling so reasoning_content_constrained is applied to all provider types, not just those with an explicit OpenAICompatibleCompat

Test Plan

  • Verify reasoning_content is included in requests for constrained providers
  • Verify non-constrained providers are unaffected

πŸ€– Generated with TiyCode

jorben added 2 commits April 30, 2026 22:13
…provider types

Previously, the `reasoning_content_constrained` flag was only applied to
openai-compatible providers, causing HTTP 400 errors when using providers
like DeepSeek V4 Pro via ZenMux that require `reasoning_content` on every
assistant message when thinking is enabled.

Now the flag is applied to all provider types, ensuring compatibility
with non-openai-compatible providers that enforce this constraint.
@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown

AI Code Review Summary

PR: #160 (fix(agent-session): πŸ› propagate reasoning_content_constrained to all provider types)
Preferred language: English

Overall Assessment

Detected 3 actionable findings, prioritize CRITICAL/HIGH before merge.

Major Findings by Severity

  • MEDIUM (2)
    • src-tauri/src/core/agent_session_tests.rs:625 - Missing test for the else-if branch (compat from default_openai_compatible_compat for non-constrained roles)
    • src-tauri/src/core/agent_session_tests.rs:1468 - Test only covers provider type with no default compat; misses case where default exists
  • LOW (1)
    • src-tauri/src/core/agent_session_tests.rs:1534 - New test lacks a check that the compat struct is not applied for non-constrained non-openai-compatible roles

Actionable Suggestions

  • Add a test for the else-if branch at R625 using a provider type that does have a default compat.
  • Extend the existing test or add a parameterized version to cover multiple provider types.

Potential Risks

  • Future regression if default_openai_compatible_compat for a non-openai-compatible provider returns compat fields beyond reasoning_content_constrained β€” the constrained path silently drops them.

Test Suggestions

  • Extend reasoning_content_constrained_on_non_openai_compatible to also test a provider type where default_openai_compatible_compat returns Some(compat) and constrained=true, verifying the resulting compat only contains the constrained flag (or whatever the intended behavior is).
  • Test the else-if branch (R625) with a non-openai-compatible provider that has a default compat.
  • Verify behavior when the role has both reasoning_content_constrained=true and default_openai_compatible_compat returns some custom compat – ensure the boolean flag is set correctly.
  • Add integration test that calls the actual LLM API with reasoning_content_constrained=true for a non-openai-compatible provider to validate end-to-end compatibility.

File-Level Coverage Notes

  • src-tauri/src/core/agent_session.rs: Approved with confidence. The logic change correctly propagates reasoning_content_constrained to all providers by or-ing a default compat when the constraint is true.
  • src-tauri/src/core/agent_session_tests.rs: Good test coverage for the primary fix path. Minor gaps exist around the else-if branch and explicit compat-struct assertions. (The new test uses a custom-delegation provider type which is not in the default compat map, so the else-if branch is not tested.)

Inline Downgraded Items (processed but not inline)

  • src-tauri/src/core/agent_session_tests.rs: Missing test for the else-if branch (compat from default_openai_compatible_compat for non-constrained roles) (line_not_present_in_diff_hunks)

Coverage Status

  • Target files: 2
  • Covered files: 2
  • Uncovered files: 0
  • No-patch/binary covered as file-level: 0
  • Findings with unknown confidence (N/A): 0

Uncovered list:

  • None

No-patch covered list:

  • None

Runtime/Budget

  • Rounds used: 1/4
  • Planned batches: 1
  • Executed batches: 1
  • Sub-agent runs: 2
  • Planner calls: 1
  • Reviewer calls: 2
  • Model calls: 3/64
  • Structured-output summary-only degradation: NO

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated PR review completed.

  • Findings kept: 2
  • Findings with unknown confidence: 0
  • Inline comments attempted: 2
  • Target files: 1
  • Covered files: 1
  • Uncovered files: 0
    See the summary comment for detailed analysis and coverage details.

// reasoning_content when thinking is enabled, and the API rejects
// requests that omit it with HTTP 400.
if let Some(true) = role.reasoning_content_constrained {
let mut compat = maybe_compat.unwrap_or_default();

This comment was marked as outdated.

// reasoning_content when thinking is enabled, and the API rejects
// requests that omit it with HTTP 400.
if let Some(true) = role.reasoning_content_constrained {
let mut compat = maybe_compat.unwrap_or_default();

This comment was marked as outdated.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated PR review completed.

  • Findings kept: 3
  • Findings with unknown confidence: 0
  • Inline comments attempted: 2
  • Target files: 2
  • Covered files: 2
  • Uncovered files: 0
    See the summary comment for detailed analysis and coverage details.

let db_path = temp_dir.path().join("test.db");
let pool = init_database(&db_path).await.expect("database");

// Use a provider type that is NOT "openai-compatible" β€” this is the

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM] Test only covers provider type with no default compat; misses case where default exists

The new test only covers the case where default_openai_compatible_compat returns None. There is no test confirming behavior when maybe_compat is Some(compat) and constrained is true β€” the current code will discard those defaults, but this edge case is not verified.

Suggestion: Add a test for a provider type that triggers default_openai_compatible_compat to return Some(compat) with non-constrained settings, then set constrained=true and assert that the resulting compat retains only reasoning_content_constrained (if that is intended behavior).

Risk: Undetected future mistake if default_openai_compatible_compat changes for a non-openai-compatible provider and the constrained path loses needed defaults.

Confidence: 0.85

[From SubAgent: general]


// For Some(false) or None, no compat should be applied at all
// (unlike openai-compatible providers that always get compat).
assert!(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW] New test lacks a check that the compat struct is not applied for non-constrained non-openai-compatible roles

The test could explicitly assert that the resolved model struct has no compat object when constraints are unset or false, beyond the is_none() checks.

Suggestion: Add a direct assertion like assert_eq!(unconstrained.model.compat, None) immediately after the is_none() assertions for clarity.

Risk: Low risk – current assertions are sufficient but explicit checks would improve test clarity.

Confidence: 0.85

[From SubAgent: testing]

@jorben
jorben merged commit 8247ce2 into master Apr 30, 2026
4 checks passed
@jorben
jorben deleted the fix/reasoning-propagation branch April 30, 2026 15:06
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