Skip to content

feat(gooddata-eval): capture agent reasoning steps in ChatResult - #1708

Open
Tomkess wants to merge 2 commits into
masterfrom
feat/chat-client-reasoning-steps
Open

feat(gooddata-eval): capture agent reasoning steps in ChatResult#1708
Tomkess wants to merge 2 commits into
masterfrom
feat/chat-client-reasoning-steps

Conversation

@Tomkess

@Tomkess Tomkess commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

gooddata-eval's SSE chat client already reads the assistant's reasoning events (content.type == "reasoning", content.summary per step) to compute reasoningStepCount — but discarded the step text itself. This PR keeps it.

  • ChatResult gains reasoning_steps: list[str] (alias reasoningSteps), alongside the existing reasoning_step_count.
  • ItemReport (runner.py) carries reasoning_steps from each run's ChatResult, same pattern as conversation_id/response_id (last non-empty value wins across pass_at_k runs).
  • The JSON report's per-item dict gains a "reasoning" key, so it flows through gd-eval run --json unchanged.

No new cost: the SSE stream already carries this data for every reasoning-capable request: this only stops throwing away.

Test plan

  • New/updated unit tests in test_sse_client.py (reasoning text retained, empty when no reasoning events)
  • New unit tests in test_runner.py (reasoning_steps carried onto ItemReport, empty when absent)
  • Updated test_reporting.py ("reasoning" key present/empty in build_json_report output)
  • Full suite: pytest -q → 254 passed, no regressions
  • ruff check clean on all changed files

Summary by CodeRabbit

  • New Features

    • Chat results now include summarized reasoning steps when available.
    • JSON evaluation reports include reasoning details for each item, defaulting to an empty list when unavailable.
  • Bug Fixes

    • Reasoning information is now consistently preserved from chat responses through item reports and serialized output.
  • Tests

    • Added coverage for reasoning-step collection, propagation, serialization, and empty-result handling.

The SSE reasoning events were already being read to produce
reasoning_step_count, but the step text itself was discarded. Keep it
as reasoning_steps on ChatResult/ItemReport and surface it in the JSON
report so eval consumers can inspect the agent's actual reasoning
trace, not just how many steps it took.
@Tomkess
Tomkess requested review from hkad98, lupko and pcerny as code owners August 4, 2026 12:02
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Tomkess, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ef8e5d5-2c53-4f68-90d4-9940b1f77e68

📥 Commits

Reviewing files that changed from the base of the PR and between 6001d2f and 73a9add.

📒 Files selected for processing (1)
  • packages/gooddata-eval/tests/test_runner.py
📝 Walkthrough

Walkthrough

The change carries reasoning step summaries from SSE responses through ChatResult and ItemReport into JSON reports. Empty reasoning lists remain the default when no reasoning events or values exist.

Changes

Reasoning Step Reporting

Layer / File(s) Summary
Capture reasoning steps
packages/gooddata-eval/src/gooddata_eval/core/chat/sse_client.py, packages/gooddata-eval/src/gooddata_eval/core/models.py
ChatResult now exposes reasoning steps and receives collected SSE reasoning summaries through the reasoningSteps alias.
Propagate report reasoning
packages/gooddata-eval/src/gooddata_eval/core/runner.py, packages/gooddata-eval/src/gooddata_eval/core/reporting/json_report.py
ItemReport stores reasoning steps, and JSON output serializes them under reasoning.
Validate reasoning reporting
packages/gooddata-eval/tests/test_sse_client.py, packages/gooddata-eval/tests/test_runner.py, packages/gooddata-eval/tests/test_reporting.py
Tests cover ordered reasoning summaries, propagation, serialization, and empty-list defaults.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SSEClient
  participant ChatResult
  participant Runner
  participant JSONReport
  SSEClient->>ChatResult: Collect reasoning steps
  ChatResult->>Runner: Return reasoning_steps
  Runner->>JSONReport: Provide item reasoning_steps
  JSONReport-->>Runner: Serialize reasoning
Loading

Suggested reviewers: hkad98, lupko, pcerny

Poem

A rabbit hops through thoughts in line,
SSE steps are gathered fine.
Reports carry each bright clue,
JSON keeps the reasoning too.
Empty baskets stay empty—
Hoppy code, precise and plenty!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes capturing agent reasoning steps in ChatResult, which is the main change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
packages/gooddata-eval/tests/test_runner.py (1)

261-279: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for multi-run reasoning retention.

Line 120 in packages/gooddata-eval/src/gooddata_eval/core/runner.py preserves the previous list when a later run returns []. Add a test with two runs: the first returns reasoning steps and the second returns an empty list. Assert that the report keeps the first run's steps.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/gooddata-eval/tests/test_runner.py` around lines 261 - 279, Add a
multi-run test near the existing reasoning_steps tests, using a backend that
returns reasoning steps on the first call and an empty list on the second.
Invoke run_items with runs=2 and assert the item report retains the first run’s
reasoning steps after the later empty result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/gooddata-eval/tests/test_runner.py`:
- Around line 261-279: Add a multi-run test near the existing reasoning_steps
tests, using a backend that returns reasoning steps on the first call and an
empty list on the second. Invoke run_items with runs=2 and assert the item
report retains the first run’s reasoning steps after the later empty result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fa87fd52-43ed-41b4-8aa1-6d92546bc59a

📥 Commits

Reviewing files that changed from the base of the PR and between acfcc1a and 6001d2f.

📒 Files selected for processing (7)
  • packages/gooddata-eval/src/gooddata_eval/core/chat/sse_client.py
  • packages/gooddata-eval/src/gooddata_eval/core/models.py
  • packages/gooddata-eval/src/gooddata_eval/core/reporting/json_report.py
  • packages/gooddata-eval/src/gooddata_eval/core/runner.py
  • packages/gooddata-eval/tests/test_reporting.py
  • packages/gooddata-eval/tests/test_runner.py
  • packages/gooddata-eval/tests/test_sse_client.py

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.30%. Comparing base (acfcc1a) to head (73a9add).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1708   +/-   ##
=======================================
  Coverage   78.30%   78.30%           
=======================================
  Files         271      271           
  Lines       18689    18692    +3     
=======================================
+ Hits        14634    14637    +3     
  Misses       4055     4055           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Addresses CodeRabbit nitpick on PR #1708: a later run returning no
reasoning events must not clobber an earlier run's captured steps
(runner.py:120's `or` pattern, same as conversation_id/response_id).
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