Skip to content

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

Merged
Tomkess merged 6 commits into
masterfrom
feat/chat-client-reasoning-steps
Aug 20, 2026
Merged

feat(gooddata-eval): capture agent reasoning steps in ChatResult#1708
Tomkess merged 6 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: 48 seconds

Limit details: You’ve used the included review currently available.

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?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e96937e4-82ae-4db7-9b84-007067aa3317

📥 Commits

Reviewing files that changed from the base of the PR and between 142bcf0 and 7ad177b.

📒 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 98.63014% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.14%. Comparing base (142bcf0) to head (7ad177b).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
...eval/src/gooddata_eval/core/agentic/alert_skill.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1708      +/-   ##
==========================================
+ Coverage   79.69%   80.14%   +0.45%     
==========================================
  Files         272      272              
  Lines       19024    19101      +77     
==========================================
+ Hits        15161    15309     +148     
+ Misses       3863     3792      -71     

☔ 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 a commit that referenced this pull request Aug 5, 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
Tomkess force-pushed the feat/chat-client-reasoning-steps branch 2 times, most recently from 02ef5c1 to 8010bd4 Compare August 5, 2026 08:01
Tomkess added a commit that referenced this pull request Aug 19, 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
Tomkess force-pushed the feat/chat-client-reasoning-steps branch 2 times, most recently from 9b9d619 to 018a619 Compare August 19, 2026 14:29
hkad98
hkad98 previously approved these changes Aug 20, 2026
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).
…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.
@Tomkess
Tomkess force-pushed the feat/chat-client-reasoning-steps branch from 018a619 to 7d4496f Compare August 20, 2026 12:02
Tomkess and others added 3 commits August 20, 2026 14:03
…agentic-CLI path

8010bd4 wired reasoning_steps through cli/agentic_runner.py -> evaluate_agentic_*,
but conversation_id/response_id stayed unset on ItemReport for every agentic kind
(agentic_alert_skill/agentic_metric_skill/agentic_conversation) -- each ChatResult
already carries both, and conversation_id was already threaded up to the
Alert/Metric/ConversationRunResult layer, but neither ever reached the top-level
evaluate_agentic_* return value or its failure exception, so run_agentic_items had
nothing to read.

Mirrors the reasoning_steps idiom exactly: widens each evaluate_agentic_*'s return
from list[str] to (reasoning_steps, conversation_id, response_id), attaches all
three to the raised exception on failure, and has run_agentic_items unpack either
form (tuple or the untouched kinds' bare list/None) onto ItemReport.conversation_id
/response_id. response_id is new at the RunResult layer for all three kinds --
captured as the last non-null value across a run's turns, same pattern already
used for reasoning_steps accumulation.

general_question/guardrail/search_tool/visualization untouched (already populated
via the single-turn runner.py path, not this one).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… dataclass

evaluate_agentic_alert_skill/metric_skill/conversation returned a bare
tuple[list[str], str, str | None], and _dispatch_agentic's return type
was a tuple | list[str] | None union unpacked via isinstance(outcome,
tuple). Introduced AgenticEvalOutcome (reasoning_steps, conversation_id,
response_id) in core/models.py and used it as the return type instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…onse-ids

feat(gooddata-eval): capture conversation_id/response_id through the agentic-CLI path
@Tomkess
Tomkess merged commit 588b985 into master Aug 20, 2026
14 checks passed
@Tomkess
Tomkess deleted the feat/chat-client-reasoning-steps branch August 20, 2026 12:34
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.

2 participants