cd /news/developer-tools/pi-git-ai-trace-code-commits-back-to… · home topics developer-tools article
[ARTICLE · art-122088] src=perrotta.dev ↗ pub= topic=developer-tools verified=true sentiment=· neutral

pi: git-ai: trace code commits back to agent sessions

Git AI version 1.7.2 records AI agent checkpoints in Git notes, enabling developers to trace code commits back to specific agent sessions without altering commit messages or repository files. The tool, integrated with Pi via an extension, captures session IDs, model names, and touched files, as demonstrated by Thiago Perrotta, who shows `git ai blame` output attributing a line to a Pi session with model gpt-5.6-sol.

read2 min views1 publishedSep 7, 2026

Git AI records agent checkpoints in Git notes<sup>1</sup>, without changing commit messages or repository files.

In order to integrate it with Pi we use an extension, because Git AI must observe file and Bash tool calls:

const GIT_AI_BIN = join(homedir(), '.git-ai', 'bin', 'git-ai');

const child = spawn(GIT_AI_BIN, ['checkpoint', 'pi', '--hook-input', 'stdin'], {
  stdio: ['pipe', 'ignore', 'ignore'],
});

The extension listens before and after each mutating call. It sends Pi session ID, model, tool, working directory, and touched files to git-ai checkpoint.

In a shell script in my dotfiles, I configured git-ai:

if command -v git-ai >/dev/null 2>&1; then
  export GIT_TRACE2_EVENT="af_unix:stream:${GIT_AI_DAEMON_TRACE_SOCKET:-$HOME/.git-ai/internal/daemon/trace2.sock}"
  export GIT_TRACE2_EVENT_NESTING=0
fi

After restarting Pi, code attribution starts to appear alongside normal git blame calls<sup>2</sup>:

% git ai blame src/main.rs
442dfde2 (pi 2026-09-05 14:29:59 +0200 1) fn main() { println!("pi"); }

The commit note contains the useful attribution / provenance snippet:

"sessions": {
  "s_82565459b433c5": {
    "agent_id": {
      "tool": "pi",
      "id": "pi-extension-test",
      "model": "gpt-5.6-sol"
    }
  }
}

Now a suspicious line can lead from Git history to the exact Pi session. The session ID can then subsequently be searched with fr or resumed in Pi.

Other useful commands with real examples:

% git ai show HEAD
STYLE.md
  s_f2908643b7ce0d::t_739223c8b9befd 12,29,48
---
{
  "schema_version": "authorship/3.0.0",
  "git_ai_version": "1.7.2",
  "base_commit_sha": "d225f5e635bbf5494574591580af8abf93da9480",
  "prompts": {},
  "sessions": {
    "s_f2908643b7ce0d": {
      "agent_id": {
        "tool": "pi",
        "id": "01a07acd-e9c7-759f-84b4-107f9ebc2556",
        "model": "gpt-5.6-sol"
      },
      "human_author": "Thiago Perrotta <{redacted_email}>"
    }
  }
}
% git log --show-notes=ai
commit d225f5e635bbf5494574591580af8abf93da9480 (HEAD -> master)
Author: Thiago Perrotta <{redacted_email}>
Date:   Mon Sep 7 09:40:01 2026 +0200

    docs: require problem statement questions

Notes (ai):
    STYLE.md
      s_f2908643b7ce0d::t_739223c8b9befd 12,29,48
    ---
    {
      "schema_version": "authorship/3.0.0",
      "git_ai_version": "1.7.2",
      "base_commit_sha": "d225f5e635bbf5494574591580af8abf93da9480",
      "prompts": {},
      "sessions": {
        "s_f2908643b7ce0d": {
          "agent_id": {
            "tool": "pi",
            "id": "01a07acd-e9c7-759f-84b4-107f9ebc2556",
            "model": "gpt-5.6-sol"
          },
          "human_author": "Thiago Perrotta <{redacted_email}>"
        }
      }
    }

— § —

Reply via email

── more in #developer-tools 4 stories · sorted by recency
── more on @git ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/pi-git-ai-trace-code…] indexed:0 read:2min 2026-09-07 ·