Skip to content

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

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

feat(gooddata-eval): capture agent reasoning steps in ChatResult#1708
Tomkess wants to merge 3 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 and JSON evaluation reports now include summarized reasoning steps when available.
    • Agentic evaluations expose reasoning steps for successful runs and failed assertions.
  • Bug Fixes

    • Reasoning information is consistently preserved across chat responses, evaluations, item reports, errors, and serialized output.
    • Missing reasoning data now safely defaults to an empty list.
  • Tests

    • Added coverage for collection, propagation, serialization, failure handling, and empty-result scenarios.

@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: 34 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: b48b8092-9c2e-4612-ba56-76d93771823f

📥 Commits

Reviewing files that changed from the base of the PR and between 17bcb5c and 8010bd4.

📒 Files selected for processing (15)
  • packages/gooddata-eval/src/gooddata_eval/cli/agentic_runner.py
  • packages/gooddata-eval/src/gooddata_eval/core/agentic/alert_skill.py
  • packages/gooddata-eval/src/gooddata_eval/core/agentic/conversation.py
  • packages/gooddata-eval/src/gooddata_eval/core/agentic/metric_skill.py
  • 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_agentic_alert_skill.py
  • packages/gooddata-eval/tests/test_agentic_conversation.py
  • packages/gooddata-eval/tests/test_agentic_metric_skill.py
  • packages/gooddata-eval/tests/test_agentic_runner.py
  • packages/gooddata-eval/tests/test_reporting.py
  • packages/gooddata-eval/tests/test_runner.py
  • packages/gooddata-eval/tests/test_sse_client.py
📝 Walkthrough

Walkthrough

The change carries reasoning step summaries from SSE responses through ChatResult, agentic evaluators, and ItemReport into JSON reports. Successful evaluations return reasoning steps, and assertion failures retain them.

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, packages/gooddata-eval/tests/test_sse_client.py
ChatResult exposes collected reasoning steps through the reasoningSteps alias. Tests cover ordered summaries and empty results.
Accumulate agentic reasoning
packages/gooddata-eval/src/gooddata_eval/core/agentic/*
Alert, conversation, and metric evaluations accumulate reasoning steps, return them on success, and attach them to assertion failures.
Forward reasoning to reports
packages/gooddata-eval/src/gooddata_eval/cli/agentic_runner.py, packages/gooddata-eval/src/gooddata_eval/core/runner.py, packages/gooddata-eval/src/gooddata_eval/core/reporting/json_report.py
Agentic evaluator results and assertion-attached steps populate ItemReport. Standard item execution preserves existing steps when later results are empty. JSON output emits them under reasoning.
Validate end-to-end behavior
packages/gooddata-eval/tests/test_agentic_*.py, packages/gooddata-eval/tests/test_runner.py, packages/gooddata-eval/tests/test_reporting.py
Tests cover accumulation, successful returns, failure exceptions, defaults, report preservation, and JSON serialization.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SSEClient
  participant ChatResult
  participant AgenticEvaluator
  participant AgenticRunner
  participant ItemReport
  participant JSONReport
  SSEClient->>ChatResult: Provide reasoning_steps
  ChatResult->>AgenticEvaluator: Supply reasoning_steps
  AgenticEvaluator-->>AgenticRunner: Return steps or attach them to an assertion
  AgenticRunner->>ItemReport: Store reasoning_steps
  ItemReport->>JSONReport: Serialize reasoning
Loading

Possibly related PRs

Suggested reviewers: lupko, pcerny, hkad98

Poem

A rabbit tracks each thinking thread,
From streamed chat to reports read.
Agentic turns collect the trail,
Success returns it; failures prevail.
Empty steps stay safely clear.

🚥 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 the primary change: capturing agent reasoning steps in ChatResult.
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 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch feat/chat-client-reasoning-steps

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

❌ Patch coverage is 87.50000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.85%. Comparing base (17bcb5c) to head (8010bd4).

Files with missing lines Patch % Lines
...ddata-eval/src/gooddata_eval/cli/agentic_runner.py 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1708      +/-   ##
==========================================
+ Coverage   78.40%   78.85%   +0.45%     
==========================================
  Files         271      271              
  Lines       18741    18767      +26     
==========================================
+ Hits        14693    14798     +105     
+ Misses       4048     3969      -79     

☔ 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.

Tomkess added a commit that referenced this pull request Aug 4, 2026
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).
Tomkess added 2 commits August 5, 2026 09:50
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.
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).
@Tomkess
Tomkess force-pushed the feat/chat-client-reasoning-steps branch from 413d756 to 02ef5c1 Compare August 5, 2026 07:53
…path

6001d2f wired ChatResult.reasoning_steps through runner.py's generic
single-turn path only. The agentic-CLI path (cli/agentic_runner.py ->
evaluate_agentic_*) builds its own ItemReport and never touched it, so
agentic_alert_skill/agentic_metric_skill/agentic_conversation items could
never produce a reasoning trace, no matter what the platform emitted.

Accumulates reasoning_steps across every send_message call in each of the
three evaluators' run loops, attaches it to the run/turn result, and
surfaces it from evaluate_agentic_* either as the return value (pass) or
as an attribute on the raised exception (fail) -- mirroring the existing
conversation_id-on-exception idiom in ChatClient.ask(). run_agentic_items
picks it up from either path onto ItemReport.reasoning_steps, which
json_report.py already serializes unconditionally.

general_question/guardrail/search_tool/visualization are left untouched --
their evaluate_agentic_* functions still return None, unchanged.
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