glab minder audit sync

Sync agent session data to GitLab. (EXPERIMENTAL)

Synopsis

Read new entries from the local agent transcript since the last sync and POST them to GitLab as audit events.

The audit events contain the prompts you type, each tool call with its arguments (such as commands, file paths, and edits, replaced with a marker when over 8 KB), each tool call’s outcome, duration, and error message, and the model and token usage of each response. Tool output and the text of responses are not sent.

Before anything is sent, glab replaces common secret formats with a marker such as [REDACTED:gitlab_token]: GitLab, GitHub, Slack, npm and PyPI tokens, AWS, Google, Stripe, OpenAI and Anthropic API keys, JWTs, private keys, credentials in Authorization and token headers or under credential-like keys, and passwords in URLs. This is best effort: other secrets in prompts, commands, or file contents are sent as they are.

When glab creates a session on GitLab, it also sends the glab version and the agent’s version. A session that has never synced and has had no activity in the last 89 days is not uploaded, because GitLab does not accept events that old. Activity from before an agent was set up with glab minder setup is not uploaded either, unless setup was run with --include-history.

Some agents record less:

  • OpenCode: prompts and responses are not sent, and a tool call’s outcome is sent only if the call had finished when it was first synced.
  • Codex: a tool call’s outcome is “completed”, because Codex does not record whether it succeeded.
  • Cursor: only prompts and tool calls are sent, timed by the transcript’s last modification, because Cursor records no results, token usage, timestamps, or version. For a Cursor session that started before Cursor was set up, only what was added after setup is uploaded. A Cursor session is not synced if the files its tool calls read or write are outside the workspace glab finds, or if several directories match the workspace’s name and those files don’t show which, so that it is not uploaded to the wrong project.

If a GitLab instance does not accept an agent’s sessions yet, they are not uploaded, then or after the instance is upgraded. Sessions from after the upgrade are.

Called by the Claude Code Stop hook after every agent turn. Also used by its SessionEnd hook (with --complete) to mark the session as complete. The hooks also record the session’s project, host, folder, and transcript location so that --all can sync it later.

With --hook codex or --hook cursor, reads the session from the JSON that a Codex Stop hook, or a Cursor stop or sessionEnd hook, gets on stdin, and syncs it with a glab started in the background, so the agent does not wait for the upload. It prints nothing, because the agent reads a hook’s output as a reason to continue. The project is resolved from the session’s directory, or for Cursor from the workspace folder that the transcript belongs to.

In a Cursor workspace with several folders, glab uses the folder the workspace is named after, unless the session’s tool calls point elsewhere, or otherwise the one folder the tool calls used. Until a turn shows which, the session is not synced. Cursor’s sessionEnd hook does not mark a session as complete. A Cursor session is completed once it has been inactive for 24 hours.

A session that works in several GitLab projects becomes one GitLab session in each of them, and each holds only the activity from its project. glab sends each prompt, tool call, and response to the project of the folder the agent was working in when it recorded it:

  • Claude Code records the folder of every entry, and follows a cd. Codex records it for every turn and shell call. OpenCode and Cursor record one folder for a session, so their sessions go to one project.
  • The folder is where the agent’s shell was, not always the project it acted on. A command such as cd ../other && git push, git -C, an absolute path, or an API call counts towards the project of the folder the shell was in.
  • A folder the hooks ran in, and its subfolders in the same Git repository, go to the project the hooks resolved for it. Another folder goes to the project of its origin remote. Activity that records no folder goes to the project of the folder the hooks last ran in, or of -R/--repo.
  • Activity goes only to projects on the same GitLab host and in the same top-level group as the first project the session was recorded with, which does not change. Activity in other projects is not uploaded, so a session does not upload to another organization’s project because the agent worked in a clone of it, even if its hooks ran there.
  • Activity in a folder without a GitLab project, such as your home folder, is not uploaded, then or later.
  • If a project does not accept the session, for example because AI governance is off there, while another project does, the activity in that project is not uploaded, then or later. If no project accepts the session, it is retried, so it uploads once governance is turned on.

With --all, syncs every session the hooks have recorded, each to the projects of the folders it worked in. Sessions inactive for 24 hours are marked completed. Sessions from agents that use hooks are skipped while the glab hooks are missing, so removing the hooks pauses them, including an agent session that was already open and still runs them. The fallback periodic sync installed by glab minder setup runs this, and glab minder doctor shows the result of its last run.

Supports Claude Code, OpenCode, Codex, and Cursor sessions. OpenCode sessions are read with opencode session export, or opencode export before OpenCode 2. With --all, it also finds and syncs the sessions of Codex and Cursor, when they are enabled with glab minder setup --agents, by scanning their transcripts, for repositories on GitLab hosts glab is logged in to.

This feature is an experiment and is not ready for production use. It might be unstable or removed at any time. For more information, see https://docs.gitlab.com/policy/development_stages_support/.

glab minder audit sync [flags]

Examples

console
# Sync the current agent session to GitLab
$ glab minder audit sync

# Sync and mark the session as completed
$ glab minder audit sync --complete

# Sync against a specific project
$ glab minder audit sync -R my-group/my-project

# Sync every recorded session that has unsynced activity
$ glab minder audit sync --all

Options

      --all           Sync all sessions recorded by the hooks. Used by the fallback periodic sync.
      --complete      Mark the session as completed. Used by the SessionEnd hook.
      --hook string   Read the session from the stdin of this agent's hook, and sync it in the background: codex, cursor. Used by the Codex and Cursor hooks.
  -R, --repo string   Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted.
      --silent        Suppress all output. Used when invoked from hooks.

Options inherited from parent commands

  -h, --help   Show help for this command.