Skip to content

feat(kernel): expose reasoning trace on blocking InferenceResponse - #17

Open
amos-aios wants to merge 1 commit into
mofa-org:mainfrom
amos-aios:feat/blocking-reasoning-field
Open

feat(kernel): expose reasoning trace on blocking InferenceResponse#17
amos-aios wants to merge 1 commit into
mofa-org:mainfrom
amos-aios:feat/blocking-reasoning-field

Conversation

@amos-aios

Copy link
Copy Markdown

Summary

InferenceResponse (the blocking-path result) had no field for a model's
deep-reasoning trace, even though the streaming path surfaces one via
StreamChunk::Reasoning. Reasoning-capable models (DeepSeek-R1 style) lose
that trace entirely for non-streaming callers.

This adds an optional, serde-defaulted reasoning: Option<String> to
InferenceResponse, mirroring the streaming representation:

/// Deep-reasoning trace surfaced by reasoning-capable models on the
/// blocking path (`None` otherwise). Mirrors what the streaming path
/// delivers as `StreamChunk::Reasoning` increments.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reasoning: Option<String>,
  • #[serde(default)] + existing ..Default::default() update syntax means
    zero changes are required at any backend construction site.
  • Wire-compatible in both directions: absent on ordinary completions,
    skipped on serialize when None.

Motivation

Found while embedding the engine as an in-process library
(mofa-studio): the OpenAI-compatible gateway there forwards the blocking
reasoning_content field for R1-style traces and round-trips engine
responses through typed structs, so the missing field silently dropped the
trace. This restores parity between streaming and blocking paths.

Testing

  • cargo test -p mofa-kernel — 13 passed.
  • Full workspace cargo check/test green with the field added; no call-site
    churn anywhere.

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