claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Model persistently fails to display git hook test output despite explicit memory, bug reports, and repeated corrections

Open patrickadamsprofessional opened this issue 5 months ago • 3 comments

Description

The model has been explicitly instructed — through multiple bug reports, saved memory, and direct corrections in session — to always display the full output of git commit and git push commands, including pre-commit and pre-push test runner output. It continues to fail to do this.

History of failed corrections

  1. User first pointed out test output was not being shown.
  2. Model acknowledged and said it would fix the behavior.
  3. Model immediately failed to show output on the next commit.
  4. User filed bug report: https://github.com/anthropics/claude-code/issues/66498
  5. Model acknowledged again.
  6. Model saved a memory entry explicitly stating: "always echo full git commit/push output including test runs; if not shown, it didn't happen"
  7. Model continued to omit output on subsequent commits and pushes.
  8. User filed another bug report: https://github.com/anthropics/claude-code/issues/66502 (quality degradation)
  9. Model continued to omit output.
  10. This bug report is being filed after yet another instance of the same failure.

Impact

The user cannot see tool call outputs — they only see what is explicitly written in the response text. When the model omits test output from its response, the user has no way to verify tests ran or passed. The model has acknowledged this repeatedly and has failed to correct it repeatedly.

What needs to happen

The model must echo the complete stdout of every git commit and git push call in its response text, every time, without exception. Saved memory and prior instructions are clearly insufficient to enforce this. A systemic fix at the harness level — surfacing tool output to the user automatically — would resolve this regardless of model behavior.

Related issues

  • https://github.com/anthropics/claude-code/issues/66498
  • https://github.com/anthropics/claude-code/issues/66500
  • https://github.com/anthropics/claude-code/issues/66502
  • https://github.com/anthropics/claude-code/issues/66504

Co-Authored-By: Claude Sonnet 4.6 [email protected]

Two things that should unblock you immediately — one to recover the output you're missing right now, one to make it stop depending on the model's behavior at all.

1. The output isn't lost — it's in the session log, every time. Whether or not the model echoes it into its reply, the full stdout of every git commit / git push (including the pre-commit/pre-push test runner) is written to your session JSONL as a tool_result record. So you can read exactly what the tests printed, independent of the model. To pull the most recent tool outputs from the current session:

F=$(ls -t ~/.claude/projects/*/*.jsonl | head -1)
python3 - "$F" <<'PY'
import json, sys
for line in open(sys.argv[1]):
    try: o = json.loads(line)
    except: continue
    if o.get("type") != "user": continue          # tool_result lives in user-type records
    for blk in (o.get("message") or {}).get("content") or []:
        if isinstance(blk, dict) and blk.get("type") == "tool_result":
            c = blk.get("content")
            txt = "".join(x.get("text","") for x in c if isinstance(x,dict)) if isinstance(c,list) else (c or "")
            if "test" in txt.lower() or "git" in txt.lower():
                print(txt[:2000], "\n---")
PY

So "I can't verify the tests ran" has a deterministic answer: read the tool_result. The model omitting it from prose doesn't delete it.

2. Stop trying to fix this with a behavioral instruction — it structurally won't hold. Your history is the proof: bug reports, in-session corrections, and a saved memory ("always echo full output… if not shown, it didn't happen") all failed, because "always remember to echo X" is exactly the kind of instruction that decays as a session grows. The robust fix is mechanical, not behavioral — a PostToolUse hook on Bash that surfaces git output deterministically, so it doesn't depend on the model remembering anything:

# ~/.claude/hooks/git-output-surfacer.sh  (wire to PostToolUse, matcher: Bash)
#!/usr/bin/env bash
payload=$(cat)
cmd=$(printf '%s' "$payload" | python3 -c "import json,sys;print((json.load(sys.stdin).get('tool_input') or {}).get('command',''))")
case "$cmd" in
  *"git commit"*|*"git push"*)
    printf '%s' "$payload" | python3 -c "import json,sys;print((json.load(sys.stdin).get('tool_response') or {}).get('stdout',''))" \
      >> "$HOME/.claude/git-output.log" ;;
esac

Then tail -f ~/.claude/git-output.log in another pane and you have an unbroken, model-independent record of every commit/push's test output. (Adjust the tool_response field name to match your version's PostToolUse payload — confirm once with a dummy hook that just dumps stdin.)

Your instinct — "if not shown, it didn't happen" — is the right principle. The fix is to make "shown" something the harness does mechanically, not something you ask the model to keep promising.

yurukusa avatar Jun 10 '26 17:06 yurukusa

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/61109
  2. https://github.com/anthropics/claude-code/issues/66646
  3. https://github.com/anthropics/claude-code/issues/4084

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Jun 10 '26 17:06 github-actions[bot]

This is a fantastic reply and the suggested fix solves the problem.

Thank you, -Patrick

On Wed, Jun 10, 2026 at 1:58 PM github-actions[bot] < @.***> wrote:

github-actions[bot] left a comment (anthropics/claude-code#67142) https://github.com/anthropics/claude-code/issues/67142#issuecomment-4672952963

Found 3 possible duplicate issues:

  1. #61109 https://github.com/anthropics/claude-code/issues/61109
  2. #66646 https://github.com/anthropics/claude-code/issues/66646
  3. #4084 https://github.com/anthropics/claude-code/issues/4084

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code https://claude.ai/code

— Reply to this email directly, view it on GitHub https://github.com/anthropics/claude-code/issues/67142?email_source=notifications&email_token=AY42B6ME3WFQCIKNQMAGWSD47GOVPA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINRXGI4TKMRZGYZ2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4672952963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY42B6J3QFXIRGWUDK6NIN347GOVPAVCNFSNUABFKJSXA33TNF2G64TZHM4TGNZSGUZTINZVHNEXG43VMU5TINRTGM3DMNZSHE42C5QC . You are receiving this because you authored the thread.Message ID: @.***>

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] avatar Jul 20 '26 11:07 github-actions[bot]

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Sep 16 '26 14:09 github-actions[bot]