Skip to content

fix(core): wrong return type annotations on factuality_detection and factuality_correction #934

Closed

Description

@planetf1

Observed vs expected

Both functions in `mellea/stdlib/components/intrinsic/guardian.py` carry `-> float` return type annotations but return `str` values:

Function Annotated Actual return
`factuality_detection()` `-> float` `"yes"` or `"no"` (string label)
`factuality_correction()` `-> float` corrected response text, or `"none"`

The docstrings are also inconsistent: `factuality_detection` says "Factuality score as a 'yes/no' label" and `factuality_correction` says "Correct assistant response", but both are annotated as `float`.

Evidence

Tests confirm the actual types:

```python

test/stdlib/components/intrinsic/test_guardian.py

assert result == "yes" or result == "no" # factuality_detection
assert isinstance(result, str) # factuality_correction
```

The return value comes from `result_json["score"]` and `result_json["correction"]` respectively — both strings from the adapter JSON response.

Fix

Change both annotations to `-> str` and fix the `factuality_detection` docstring typo ("Determine is the last response" → "Determine if the last response").

Files

  • `mellea/stdlib/components/intrinsic/guardian.py` lines 162–208

Activity

  1. self-assigned this
    on Apr 24, 2026
  2. added
    bug
    on Apr 24, 2026
  3. psschwei commented on May 19, 2026

    @psschwei
    Contributor

    believe that @jakelorocco fixed this in the great intrinsics push of may 2026

  4. added
    area/adapter-functions
    area/stdlib
    on May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/adapter-functionsarea/stdlibbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions