Skip to content

feat(feedback): store bash command in feedback ledger metadata#133

Closed
leshchenko1979 wants to merge 2 commits into
adolfousier:mainfrom
leshchenko1979:fix/bash-command-in-feedback-metadata
Closed

feat(feedback): store bash command in feedback ledger metadata#133
leshchenko1979 wants to merge 2 commits into
adolfousier:mainfrom
leshchenko1979:fix/bash-command-in-feedback-metadata

Conversation

@leshchenko1979
Copy link
Copy Markdown
Contributor

Problem

When bash commands fail, the feedback ledger records the error output but not the actual command that was run. RSI currently sees Command exited with code 1 but can't tell whether it was a git operation, python script, docker command, or something else — all bash failures are lumped into one bucket.

Change

In tool_loop.rs, both record_tool_feedback call sites now prepend the command text to the error snippet for bash failures:

  • Before: Command exited with code 1
  • After: [command: git pull origin main] Command exited with code 1 (+ stdout/stderr)

The command is truncated to 300 chars (metadata is limited to 500). Non-bash tools and successful calls are unchanged.

Why

RSI analyzes per-tool failure rates. With the command in metadata, it can now group bash failures by command type (git, python, pip, docker, ssh) and surface targeted improvement opportunities for the actual failing subsystem — not just generic "bash has >20% failure rate" noise.

@leshchenko1979 leshchenko1979 force-pushed the fix/bash-command-in-feedback-metadata branch from 5b7d015 to 126b6fa Compare May 29, 2026 23:16
The new feedback snippet code references tool_input.get("command") after
tool_input is moved into execute(). Adding .clone() at both execute()
call sites resolves the borrow checker error.
@adolfousier
Copy link
Copy Markdown
Owner

Thanks for the PR! I already shipped this fix in 2b4d7c86 on main while you were drafting this. Closing in favor of that commit.

The approach is the same idea — append the bash command to the feedback ledger meta so RSI / SQL can group failures by subsystem — with a few extras:

  • Covers all 5 record_tool_feedback call sites (your PR covers 2). The user-denied-approval path and both direct-execution error branches now carry cmd= too.
  • Centralized in a new enrich_metadata helper in feedback.rs, so adding python/docker subsystem parsing later is one edit instead of touching every call site.
  • Format is suffixed: Command exited with code 1 | cmd=git rebase main. Query with meta LIKE '%cmd=git%'.
  • 14 unit tests in src/tests/bash_feedback_enrichment_test.rs covering the cases you described (git rebase, python ModuleNotFoundError, cargo timeout) plus edges (empty command, missing field, very long command, unicode).

Same outcome for RSI either way. Really appreciate you taking the time to write this up.

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