Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › AI agents

How to Audit What an AI Agent Did and Undo Unwanted Changes

By Freedom251 Team · · 12 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Audit an AI agent by correlating its session or trace with the actual files, repository diffs, and external-service records it changed. Preserve identifiers, timestamps, prompts where available, tool calls, approvals, outputs, diffs, and service logs before restoring anything. Then choose the narrowest recovery that fits: undo an individual edit, restore a session checkpoint, use Git for durable repository recovery, or use the affected service’s own rollback process for deployments, network actions, database writes, and other external effects. A workspace checkpoint cannot reverse those external actions.

What does auditing an AI agent actually involve?

An audit is a reconstruction, not just a glance at the agent’s final message. You match the agent’s recorded turns and tools to the resulting state, then verify that state independently. The record may include model responses, tool inputs and results, delegated-agent work, approval decisions, timestamps, and status; the changed state includes tracked files, untracked files, commits, deployments, requests, and records in external systems.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep three questions separate:

  • What did the agent attempt? Read the session timeline, trace spans, terminal or tool calls, and approval events.
  • What actually changed? Inspect diffs, repository status, generated files, logs, and the relevant external service.
  • What can be safely undone? Select an edit-level action, checkpoint, Git recovery, or service-specific rollback without erasing evidence first.

Product coverage differs. OpenAI’s Agents API documentation describes traces and observability records, while GitHub documents separate session logs and enterprise audit events. Treat each product’s documented fields and retention as its own boundary rather than assuming every agent records the same information.

OpenAI’s tracing documentation explains how model responses and tool calls are grouped into traces and spans. Its observability documentation describes sessions, turns, tools, subagents, saved history, and recorded usage.

What should I preserve before undoing anything?

Freeze the evidence before changing the workspace or stopping a run. Restoration can remove the very context needed to determine what happened.

  1. Record identity and time. Save the agent, session, request or turn identifier, user identity, workspace or repository, and the start and end times in a common time zone.
  2. Export the available record. Preserve the timeline, trace or audit export, tool names, inputs, outputs, approval decisions, delegated-agent activity, and status. Keep the original export read-only and note when it was collected.
  3. Capture the workspace. Save repository status, staged and unstaged diffs, untracked files, file hashes where practical, and the active branch or worktree. Include files created by scripts or terminal commands.
  4. Capture external state. Save deployment identifiers, request IDs, database migration records, cloud or SaaS audit entries, and relevant before-and-after values. An agent’s completion message is not proof that an external operation succeeded or failed.
  5. Write a short incident timeline. Order approvals, tool calls, commits, deployments, and observed changes. Mark facts that are confirmed separately from effects that still need verification.

Command output can be abbreviated or absent in a trace. OpenAI notes that a turn can identify a subagent while command-output truncation is not reported; therefore, an omitted or shortened output is not evidence that the command never ran. Preserve the trace and verify the target state independently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I inspect an OpenAI Agents API trace?

For an Agents API deployment, use the documented trace and session views to connect each tool call to a result.

  1. Open Logs → Agents and locate the session using its identifier and time range.
  2. Open the session timeline and expand the relevant turn.
  3. Inspect the root-agent and subagent spans. A span can show the call, inputs, outputs when available, duration, and status.
  4. Record which tools ran, which approvals were granted or denied, and what resources each tool touched.
  5. Compare those events with repository diffs, service logs, and deployment or database records captured outside the agent interface.

Traces are built after a turn ends; live events are available for progress while a session is active. A live stream is useful for stopping additional work, but it is not a substitute for the completed trace and independent state checks. Use the exact event and span identifiers in your incident notes so another reviewer can reproduce the sequence.

How do I audit a GitHub Copilot cloud-agent session?

GitHub’s cloud agent provides a session log showing progress and tools used, and commits can link back to the originating session logs. Open the session, review the sequence of actions, and inspect every linked commit and pull-request change rather than trusting the final summary.

Stopping a session ends its Actions run, but commits already pushed remain. Stop therefore limits additional work; it is not an undo operation. After stopping, preserve the session URL or identifier, then inspect the branch and repository history before deciding whether to revert, reset, or make a corrective commit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

GitHub’s enterprise audit log is a separate source. It records agent activity on GitHub’s website but does not include client session data such as prompts sent to Copilot locally. The documented history window is 180 days. Enterprise owners or users with the Read enterprise audit logs custom role can access it when Copilot Business or Enterprise is in use. GitHub recommends streaming events to a SIEM for longer retention and anomaly alerts; custom hooks can send Copilot CLI events to a logging service.

See GitHub’s session-management documentation for session behavior and its enterprise audit-log documentation for scope, access, and retention.

How do I find every file change, including changes the agent view misses?

Start with the repository and filesystem, not only a tool-specific change list. VS Code warns that edits made through terminal commands or scripts may not appear in its agent change tracking.

  1. Run git status --short to list modified, staged, deleted, and untracked paths.
  2. Review unstaged content with git diff and staged content with git diff --cached.
  3. List untracked files explicitly with git ls-files --others --exclude-standard; open generated files and inspect their contents.
  4. Check ignored outputs and build directories when the agent could have written there. Use the project’s normal build or test logs to identify generated artifacts.
  5. Compare file timestamps and hashes with the preserved pre-incident snapshot when available.
  6. Search terminal, CI, deployment, and service logs for commands or requests that do not appear in the agent panel.

Do not discard a file merely because the agent’s change list omits it. A script can modify many files in one call, and an untracked file can contain credentials, migration code, or generated configuration that matters to recovery.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which rollback should I choose?

Choose the smallest action that removes the unwanted effect while preserving legitimate work and evidence.

Recovery method Best scope What it changes Important boundary
Per-edit Undo One reviewed local edit Reverts the selected change in a supported local harness Availability depends on the harness and session target
Checkpoint restore A broader agent request or workspace state Restores affected files and rolls back subsequent conversation turns Temporary; does not reverse terminal commands, network requests, deployments, or external-service changes
Git recovery Tracked repository content and collaboration history Restores or records repository changes using durable version history Must be coordinated with staged work, shared branches, and untracked files
External-service recovery Deployments, data, accounts, network effects, and other outside state Uses that service’s rollback, restore, revoke, or compensating operation Requires verification in the affected service; workspace recovery alone is insufficient

VS Code describes per-change Keep and Undo controls, checkpoint restoration, and Source Control discard actions. It also states that checkpoints are temporary and do not replace Git version control. Confirm the session type and review what will be removed before selecting a control.

How do I undo one unwanted local edit?

Use edit-level undo when one change is clearly wrong and neighboring work must remain intact.

  1. Open the agent’s review or changes view and identify the exact file and hunk.
  2. Read the diff in context, including nearby lines and any dependent files.
  3. Select Undo for that change, or use the equivalent per-change control in the harness.
  4. Reopen the diff and run the affected formatter, test, or static check.
  5. Inspect repository status to ensure no generated or untracked companion files remain.

If the change was made by a script or terminal command and is absent from the review view, do not rely on the per-edit control. Restore or edit the affected files through Git or the filesystem after preserving the command record and a diff.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When should I restore a checkpoint?

Restore a checkpoint when an entire request produced a bad workspace state and you want to remove the request’s file changes together with later conversation turns. Checkpoints are useful for local experimentation, not as a substitute for a repository history or an external rollback.

  1. Read the checkpoint’s affected-file list and compare it with your preserved status and diff.
  2. Identify terminal commands, network calls, deployments, and service writes that occurred after the checkpoint.
  3. Save any legitimate edits made after the checkpoint to a separate branch, patch, or copy.
  4. Restore the checkpoint through the harness.
  5. Recheck tracked, staged, and untracked files, then verify external systems independently.

A checkpoint can leave a deployment live, a database row changed, or a remote request completed even after local files look clean. Treat those as separate incidents with their own recovery controls.

How do I use Git to recover a repository safely?

Git is the durable recovery layer for tracked source. Prefer a reversible commit or branch when others may have pulled the work; destructive resets are appropriate only when you have confirmed the branch is private and the evidence is preserved.

Discard selected unstaged hunks

Review git diff, then use an interactive restore such as git restore -p path/to/file to choose only unwanted hunks. Re-run tests and inspect git diff afterward.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restore a whole tracked file

When the complete file change is unwanted and the current file is not needed, review the path and run git restore --source=HEAD -- path/to/file. This removes uncommitted changes to that tracked file; it does not remove untracked files.

Undo an unwanted commit on a shared branch

Use git revert <commit> to create a new inverse commit that collaborators can review. Push it through the normal review path and record the original commit, the revert commit, and any conflicts.

Recover a private branch

For unpublished work, a reset such as git reset --hard <known-good-commit> moves the branch and discards tracked working-tree changes. Preserve a patch or temporary branch first; this command cannot recover discarded content from the working tree by itself.

Git operations do not undo deployments, requests, secrets already exposed, or data written outside the repository. Pair the repository recovery with service-specific actions and a post-recovery verification.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I undo deployments, network calls, or database writes?

Treat every external effect as a separate recovery plan. A local checkpoint or Git revert changes source files, not the already-executed operation.

Deployments

Identify the deployment ID, environment, commit, and rollout state. Use the platform’s documented rollback or redeploy process, then check health, configuration, traffic, and logs. If the agent changed infrastructure, review the infrastructure tool’s plan and state before applying a corrective change.

Network and API requests

Use request IDs and provider logs to determine whether a request was accepted, retried, or partially completed. If the API supports cancellation or deletion, perform that operation with the least privilege needed; otherwise create a documented compensating action and verify the resulting state.

Database changes

Identify the migration, transaction, or write operation and its affected records. Use a tested down-migration, point-in-time restore, or carefully reviewed compensating update according to the database’s recovery procedures. Take a fresh backup or snapshot when the platform supports it, and validate constraints, dependent services, and audit records afterward.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Credentials and sensitive data

If an agent exposed or copied a secret, revoke or rotate it even if the file is later restored. Search logs, caches, pull requests, and external destinations for copies, and document the rotation and verification.

What do enterprise audit logs contain, and how long do they last?

Retention and coverage are product-specific. The following published periods apply only to the documented services and conditions.

System Documented coverage Retention or cost condition
GitHub Enterprise Cloud Copilot audit log Agent activity on GitHub’s website; local client prompts are excluded Events from the last 180 days; stream to a SIEM for longer history
Microsoft Purview audit for non-Microsoft AI applications User interactions, when and where they occurred, and references to resources accessed 180-day retention when enabled with pay-as-you-go billing; billing is based on records ingested
OpenAI Codex telemetry export Documented event types include prompts, tool approval decisions, tool execution results, MCP-server use, and network allow or deny decisions OpenTelemetry export can centralize events in SIEM or compliance systems; retention depends on your logging destination

Microsoft’s details are in its Purview audit documentation. OpenAI describes the Codex telemetry approach in Running Codex safely. Do not infer that an unlisted product records the same fields or keeps them for the same period.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How can I design a repeatable audit-and-recovery process?

Make the workflow routine before an incident. A small amount of structure prevents a missing prompt, untracked file, or expired audit event from becoming an unanswerable question.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Assign a run identifier. Store the agent session ID, repository commit or worktree, environment, and responsible user together.
  2. Require review gates. Gate destructive tools, production deployments, data writes, and secret access behind explicit approvals.
  3. Export centrally. Send trace, session, approval, and tool-result events to an access-controlled log store or SIEM when the product supports export.
  4. Keep independent state evidence. Retain Git history, CI logs, deployment records, database audit trails, and provider request IDs.
  5. Set retention intentionally. A 180-day product window may be insufficient for your compliance or incident-response needs; archive events before expiry.
  6. Test recovery. Periodically restore a checkpoint, revert a test commit, and exercise an external rollback in a non-production environment.
  7. Verify after every undo. Re-run tests, inspect repository status, check service health and data, and record who approved closure.

OpenTelemetry export can centralize Codex events, and GitHub recommends SIEM streaming for longer audit history and anomaly alerts. Centralization improves search and retention but does not fill gaps that the originating product never recorded.

What are the common audit and rollback failures?

Assuming the final answer is a complete log

Agent summaries can omit subagent work, truncated command output, retries, or failed external calls. Read the underlying timeline and verify state independently.

Undoing files before preserving evidence

Restoring a checkpoint or resetting Git can erase the clearest diff. Export logs, copy patches, and capture external identifiers first.

Checking only tracked files

Generated or untracked files may contain the actual harmful change. Include untracked and script-created paths in the review.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Stopping a run and assuming it rolled back

Stopping prevents additional execution but does not remove commits already pushed or reverse completed requests. Follow with repository and service recovery.

Overlooking audit boundaries

GitHub’s enterprise log excludes locally sent prompts, and product retention can expire. Pair vendor logs with client hooks, SIEM ingestion, or local records where policy requires a complete trail.

Using a destructive Git command on shared work

A hard reset can discard collaborators’ history. Prefer a revert commit on shared branches and document the review.

What should the final recovery record contain?

Close the incident with a concise, reproducible record:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Original session, trace, turn, commit, deployment, and request identifiers.
  • Timeline of approvals, tools, outputs, commits, and observed effects.
  • Files and external resources affected, including untracked artifacts.
  • Recovery action, exact scope, operator, approval, and timestamp.
  • Post-recovery test results and independent service-state checks.
  • Evidence retained, retention deadline, and any unresolved uncertainty.

This record lets a reviewer distinguish an attempted action from a completed one and shows exactly which state was restored.

Frequently Asked Questions

Can an AI agent’s session log prove that a command changed nothing?

No. A log may show a call and an abbreviated or missing output without proving the command’s effect. Check the filesystem, repository diff, and relevant service logs before concluding that nothing changed.

What is safer on a shared branch: reset or revert?

A revert creates a new inverse commit and preserves the branch’s shared history, so it is generally safer after others may have pulled the agent’s commit. A hard reset rewrites the branch pointer and is better limited to private, unpublished work with a preserved backup.

How can I audit prompts sent from a developer’s local client?

Do not assume an enterprise website audit log contains them; GitHub explicitly excludes locally sent client prompts from its Copilot audit log. Capture client-side events with approved hooks or telemetry and send them to an access-controlled central log before the retention window closes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does restoring a checkpoint remove a bad production deployment?

No. A checkpoint restores workspace files and conversation state, while the deployment has already changed an external environment. Use the deployment platform’s rollback or redeploy procedure, then verify traffic, health, configuration, and logs.

How long should AI-agent audit data be retained?

There is no universal period. The documented GitHub Enterprise Copilot window and Microsoft’s enabled pay-as-you-go non-Microsoft AI audit logs are each 180 days, while other records depend on the product and your logging destination; set retention to your legal, security, and incident-response requirements.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

AI agentsaudit logsDeveloper ToolsGitincident responserollback

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.