Skip to content

fix: --include-feedback has no effect on default (table) output format - #273

Open
SpiliosDmk (SpiliosDimakopoulos) wants to merge 1 commit into
langchain-ai:mainfrom
SpiliosDimakopoulos:fix/186-include-feedback-table
Open

fix: --include-feedback has no effect on default (table) output format#273
SpiliosDmk (SpiliosDimakopoulos) wants to merge 1 commit into
langchain-ai:mainfrom
SpiliosDimakopoulos:fix/186-include-feedback-table

Conversation

@SpiliosDimakopoulos

Copy link
Copy Markdown

Fixes #186

Problem

output.PrintRunsTable never accepted an includeFeedback parameter,
so none of its three call sites (run list, trace list, thread get)
could pass through the --include-feedback / --full flag that
already exists on those commands. feedback_stats was already being
fetched and placed into each run's map by extract.ExtractRun — it
just never reached the table renderer.

Fix

  • output.PrintRunsTable(w, runs, includeMetadata, includeFeedback, title)
    now adds a "Feedback" column when includeFeedback is true.
  • Added formatFeedbackStats(): renders numeric feedback as
    key=avg (n=N) and categorical feedback as key{label=count,...},
    joining multiple keys with ; in sorted order.
  • Updated the three call sites to pass the already-in-scope
    includeFeedback variable.

Tests

  • Updated TestPrintRunsTable for the new signature; added an
    assertion that no Feedback column appears when the flag is off.
  • Added TestPrintRunsTable_WithFeedback and table-driven
    TestFormatFeedbackStats (empty, numeric, categorical, multi-key
    sort order, zero-n key skipped).

Verification

My sandbox can't install Go 1.25 (this repo's go.mod requirement),
so I verified by copying the real internal/output/{output.go, output_test.go} into an isolated module pinning this repo's exact
tablewriter/treeprint versions, and ran go build + go test -v
with go1.23 — all 9 tests passed. Also independently compiled/ran the
new formatFeedbackStats logic against 6 cases, and confirmed
gofmt -l is clean on every touched file. Please still run
go build ./... / go test ./... in CI/locally before merging.

output.PrintRunsTable never accepted an includeFeedback parameter, so
none of its three call sites (run list, trace list, thread get) could
pass through the --include-feedback / --full flag that already exists
on those commands. The feedback_stats field was already being fetched
and placed into each run's map by extract.ExtractRun -- it just never
reached the table renderer, so `--include-feedback` silently had no
effect on the default "pretty" (table) format, even though it worked
correctly for JSON output.

Fixes langchain-ai#186

Changes:
- output.PrintRunsTable(w, runs, includeMetadata, includeFeedback, title)
  now takes includeFeedback and, when true, adds a "Feedback" column.
- Added formatFeedbackStats(), a small helper that renders each run's
  feedback_stats map as a compact single-line summary:
    - numeric feedback:      "key=avg (n=N)"
    - categorical feedback:  "key{label=count,...}"
    - multiple keys are joined with "; ", sorted for determinism
    - keys with zero recorded points are skipped
- Updated the three call sites (run.go, trace.go, thread.go) to pass
  the includeFeedback variable that was already in scope at each site.

Tests:
- Updated the existing TestPrintRunsTable call to the new 5-arg
  signature, and added an assertion that no "Feedback" column appears
  when includeFeedback is false.
- Added TestPrintRunsTable_WithFeedback, exercising both a run with
  numeric + categorical feedback and a run with none.
- Added TestFormatFeedbackStats with table-driven cases: empty map,
  numeric, categorical, multi-key sort order, and a key with n=0
  being skipped.

Verification note: this repo's go.mod requires go >= 1.25.0, which
isn't available in my sandbox (max installable via apt is go1.23, and
proxy.golang.org / sum.golang.org are not reachable). I verified this
change by copying internal/output/{output.go,output_test.go} verbatim
into an isolated throwaway module (pinning the exact same
tablewriter/treeprint versions declared in this repo's go.mod, with
local `replace` directives redirecting a couple of gopkg.in-hosted
transitive test-only deps to their GitHub mirrors purely to work
around my sandbox's network allowlist) and ran `go build` + `go test
-v` there with go1.23: all 9 test functions passed, including the 3
new/updated ones. I also independently compiled and ran just the new
formatFeedbackStats logic against 6 hand-written cases with go1.23,
and confirmed with `gofmt -l` that every touched file is correctly
formatted. None of these workarounds are part of this patch -- please
still run `go build ./...` and `go test ./...` in a proper go1.25
environment before merging.
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.

langsmith thread get <thread-id> --include-feedback does NOT include the feedback when using the default (table) format

1 participant