Repository: truera/trulens
Issue: [BUG]Groundedness with answerability metric not generating
Root cause: Resource Mishandling

**Bug Description**
I have created a trulens application , in which i am fetching some of my RAG agent conversation history from dynamodb. It includes user query, answer and context(list of strings). I have created a session using TruSession using sqlite and using TruBasic app for generating metrices. Currently I am able to get metrices for answer relevance and context relevance and i can see that on trulens dashboard, but issue is with groundedness metrice, it sometimes appears for few records and then dissapear once i refresh data from dashboard and most of the times it didnt even appear for any of the record. I have tried bothbedrock and openai provider and also different models, but the issue persists. FYI: I am using provider.groundedness_with_cot_reasons_consider_answerability function. I am not able to provide code as it is client's content andi cannot share it on any public platform. 

**To Reproduce**
this is what metrice looks like, i am passing context list just like i am passing it into context relevance:
provider = OpenAI(model_engine="gpt-5-nano")

# Define a groundedness feedback function
f_groundedness = (
    Feedback(
        provider.groundedness_measure_with_cot_reasons_consider_answerability,
        name="Groundedness",
    )
    .on_context(collect_list=True)
    .on_output()
    .on_input()

**Expected Behavior**
It should generate groundedness metrice too correctly just like other metrices.

**Relevant Logs/Tracebacks**
I am seeing some groundedness related errors in dashboard logs in terminal, saying "feedback_name=Groundedness, record-"some record id", span_group=None had an error during computation:cannot schedule new futures after interpreter shutdown"

**Environment:**

- OS:  Windows
- Python Version: 3.12.6
- TruLens version: 2.5.1




<!-- Answer -->
The groundedness metric not appearing reliably is a known issue, especially with Python 3.12+ and certain feedback function setups. The error "cannot schedule new futures after interpreter shutdown" means the feedback computation is trying to start new background tasks after Python has begun shutting down, often because feedback evaluation hasn't finished before you access the dashboard or shut down the app. This is more likely to affect groundedness because it's slower and more resource-intensive than other metrics [citation](https://github.com/truera/trulens/issues/1717).

Here are the most effective steps to resolve this:

- Always call `virtual_recorder.wait_for_feedback_results()` after adding records and before accessing the dashboard or leaderboard. This ensures all feedback (including groundedness) is computed and stored [citation](https://github.com/truera/trulens/issues/2292).
- Avoid passing `app_id` filters to `get_leaderboard()` or `get_records_and_feedback()`—these can filter out feedback results [citation](https://github.com/truera/trulens/issues/1884).
- Double-check your feedback function: for groundedness, instantiate a `Groundedness` object with your provider, then use its methods in `Feedback`, not the provider method directly [citation](https://github.com/truera/trulens/issues/1739).
- Make sure your context input is a list of meaningful strings (not just arbitrary text splits), as groundedness is sensitive to input format [citation](https://github.com/truera/trulens/issues/2292).
- There was a bug with feedback functions (including groundedness) in Python 3.12/3.13 that caused blank values. If possible, try running with Python 3.9–3.11 to see if the issue resolves [citation](https://github.com/truera/trulens/issues/2292).
- Upgrading to the latest TruLens version is recommended, as several bugs affecting groundedness feedback were fixed after 2.3.0 [citation](https://github.com/truera/trulens/issues/2174).
- If you use selectors like `.on(context)`, the dashboard may show the metric as `Groundedness_calls`—this is expected [citation](https://github.com/truera/trulens/issues/2292).

If you still see missing metrics, try running a minimal example with a single, simple context string to isolate the issue. If the problem persists, consider using server-side feedback computation or switching providers/models to rule out provider-specific issues [citation](https://github.com/truera/trulens/issues/1717).


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2369470e-f216-4e87-a76e-17b05263db91?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2369470e-f216-4e87-a76e-17b05263db91?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2369470e-f216-4e87-a76e-17b05263db91?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2369470e-f216-4e87-a76e-17b05263db91?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2369470e-f216-4e87-a76e-17b05263db91?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2369470e-f216-4e87-a76e-17b05263db91?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2369470e-f216-4e87-a76e-17b05263db91?feedback_type=other)</sup>

[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/e16d1378-a540-46b6-bd0e-816c493d2aee/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20groundedness%20metric%20not%20appearing%20reliably%20is%20a%20known%20issue%2C%20especially%20with%20Python%203.12%2B%20and%20certain%20feedback%20function%20setups.%20The%20error%20%22cannot%20schedule%20new%20futures%20after%20interpreter%20shutdown%22%20means%20the%20feedback%20computation%20is%20trying%20to%20start%20new%20background%20tasks%20after%20Python%20has%20begun%20shutting%20down%2C%20often%20because%20feedback%20evaluation%20hasn%27t%20finished%20before%20you%20access%20the%20dashboard%20or%20shut%20down%20the%20app.%20This%20is%20more%20likely%20to%20affect%20groundedness%20because%20it%27s%20slower%20and%20more%20resource-intensive%20than%20other%20metrics%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/1717%29.%0A%0AHere%20are%20the%20most%20effective%20steps%20to%20resolve%20this%3A%0A%0A-%20Always%20call%20%60virtual_recorder.wait_for_feedback_results%28%29%60%20after%20adding%20records%20and%20before%20accessing%20the%20dashboard%20or%20leaderboard.%20This%20ensures%20all%20feedback%20%28including%20groundedness%29%20is%20computed%20and%20stored%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/2292%29.%0A-%20Avoid%20passing%20%60app_id%60%20filters%20to%20%60get_leaderboard%28%29%60%20or%20%60get_records_and_feedback%28%29%60%E2%80%94these%20can%20filter%20out%20feedback%20results%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/1884%29.%0A-%20Double-check%20your%20feedback%20function%3A%20for%20groundedness%2C%20instantiate%20a%20%60Groundedness%60%20object%20with%20your%20provider%2C%20then%20use%20its%20methods%20in%20%60Feedback%60%2C%20not%20the%20provider%20method%20directly%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/1739%29.%0A-%20Make%20sure%20your%20context%20input%20is%20a%20list%20of%20meaningful%20strings%20%28not%20just%20arbitrary%20text%20splits%29%2C%20as%20groundedness%20is%20sensitive%20to%20input%20format%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/2292%29.%0A-%20There%20was%20a%20bug%20with%20feedback%20functions%20%28including%20groundedness%29%20in%20Python%203.12/3.13%20that%20caused%20blank%20values.%20If%20possible%2C%20try%20running%20with%20Python%203.9%E2%80%933.11%20to%20see%20if%20the%20issue%20resolves%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/2292%29.%0A-%20Upgrading%20to%20the%20latest%20TruLens%20version%20is%20recommended%2C%20as%20several%20bugs%20affecting%20groundedness%20feedback%20were%20fixed%20after%202.3.0%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/2174%29.%0A-%20If%20you%20use%20selectors%20like%20%60.on%28context%29%60%2C%20the%20dashboard%20may%20show%20the%20metric%20as%20%60Groundedness_calls%60%E2%80%94this%20is%20expected%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/2292%29.%0A%0AIf%20you%20still%20see%20missing%20metrics%2C%20try%20running%20a%20minimal%20example%20with%20a%20single%2C%20simple%20context%20string%20to%20isolate%20the%20issue.%20If%20the%20problem%20persists%2C%20consider%20using%20server-side%20feedback%20computation%20or%20switching%20providers/models%20to%20rule%20out%20provider-specific%20issues%C2%A0%5Bcitation%5D%28https%3A//github.com/truera/trulens/issues/1717%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/truera/trulens/issues/2306)

Hi @sadaf0714 - I think your model choice is likely the culprit here. Can you try changing the LLM judge to mini instead of nano?

`provider = OpenAI(model_engine="gpt-5-mini")`

Rest of your code looks good and confirmed it works on my side.

As I said, I have tried it with various models, currently i am able to genearte metrice as I added recorder.retrieve_feedback_results() and waited till all mterices are calculated. But now the issue i am facing is it is giving Rating must be [0,1]. I passed min and max_score_value to 0 and 1 in Feedback functions, but the issue persists and due to that i think , I am not able to see explanations for metrices ( for groundednes ). it is throwing some dataframe error too. When i check explanation on dashboard the error says out of index.

Are you able to share some code that reproduces the error without sharing your client's code? Otherwise I cannot see what could be going wrong.