Skip to content

refactor(core): promote ModelOutputThunk.thinking and deprecate _thin…#1315

Open
exequeryphil wants to merge 2 commits into
generative-computing:mainfrom
exequeryphil:1217-_thinking
Open

refactor(core): promote ModelOutputThunk.thinking and deprecate _thin…#1315
exequeryphil wants to merge 2 commits into
generative-computing:mainfrom
exequeryphil:1217-_thinking

Conversation

@exequeryphil

Copy link
Copy Markdown

Pull Request

Issue

Fixes #1217

Description

  • Promoted ModelOutputThunk.thinking to the public reasoning-trace field in mellea/core/base.py, with a temporary deprecated _thinking alias that emits DeprecationWarning.
  • Updated reasoning capture across backends (openai, litellm, ollama, watsonx) to write into mot.thinking.
  • Updated safety/guardian requirement logic to read mot.thinking.
  • Updated docs to reference result.thinking instead of result._thinking.
  • Updated backend unit tests to assert mot.thinking, and added core tests for the new public field plus deprecated alias behavior.
  • Resolved merge conflict in test/core/test_base.py by keeping both your new thinking-related tests and upstream base tests.

Testing

  • [X ] Tests added to the respective file if code was changed
  • [X ] New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

Adding a new component, requirement, sampling strategy, or tool?

If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.

…king alias

Signed-off-by: Phil Williams <phil.williams@ibm.com>
@exequeryphil exequeryphil requested review from a team, jakelorocco and nrfulton as code owners June 22, 2026 18:07
@github-actions github-actions Bot added the enhancement New feature or request label Jun 22, 2026
@akihikokuroda

akihikokuroda commented Jun 22, 2026

Copy link
Copy Markdown
Member

Looks good. A minor issue is reported.

Missing: Test for deprecated setter with warning

The tests verify reading _thinking generates a deprecation warning, but there's no test verifying the setter also warns. The implementation includes both getter and setter (which is correct), but the test only covers the getter path:

Current tests cover:
✅ Reading: mot._thinking (should warn)
❌ Not tested: mot._thinking = "value" (should warn)

Recommendation: Add one small test (no need for separate test, can extend existing):
def test_mot__thinking_deprecated_alias_warns_on_read_and_write():
mot = ModelOutputThunk(value="x")
with pytest.warns(DeprecationWarning):
mot._thinking = "reasoning trace" # Setter should also warn
with pytest.warns(DeprecationWarning):
value = mot._thinking # Getter warns
assert value == "reasoning trace"

Signed-off-by: Phil Williams <phil.williams@ibm.com>
@akihikokuroda

Copy link
Copy Markdown
Member

@exequeryphil Please run:

uv run ruff format
uv run ruff check --fix

Thanks!

@ajbozarth ajbozarth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking solid, but I'm actually circling back on a design decision before we merge this. @planetf1 @jakelorocco I'm no longer sure it's worth including a deprecation shim for a private var like _thinking. I haven't be including deprecation shims for private vars in #1191 or my planned implementation for #1215 that I'm in the middle of.

If we do decide to keep the deprecation shim there are a few nits I'd raise, which I'll include a comments below

Comment thread test/core/test_base.py
assert mot.thinking == "reasoning trace"


def test_mot__thinking_deprecated_alias_warns_on_read():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
def test_mot__thinking_deprecated_alias_warns_on_read():
def test_mot_thinking_deprecated_alias_warns_on_read():

no need to double underscore here, it just makes it less readable

Comment thread test/core/test_base.py
assert mot._thinking == "reasoning trace"


def test_mot__thinking_deprecated_alias_write_sets_public_field():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
def test_mot__thinking_deprecated_alias_write_sets_public_field():
def test_mot_thinking_deprecated_alias_write_sets_public_field():

same here

Comment thread mellea/core/base.py

@property
def _thinking(self) -> str | None:
"""Deprecated alias for :attr:`thinking`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIRC I don't think this is the correct docstring format for the project (Google style)

Comment thread mellea/core/base.py
return self.thinking

@_thinking.setter
def _thinking(self, value: str | None) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should have the same warn as read

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(core): promote mot._thinking to public mot.thinking

3 participants