Skip to content

feat(agents): snapshot, list snapshots and fork an agent - #61

Merged
rmanjunath18 merged 1 commit into
mainfrom
feat/agent-fork
Nov 2, 2026
Merged

rmanjunath18 merged 1 commit into
mainfrom
feat/agent-fork

Conversation

@rmanjunath18

Copy link
Copy Markdown
Collaborator

Python part of AIPLATFORM-1564.

What changes

  • Agent snapshots: client.agents.create_snapshot(id, params=None) and list_snapshots(id, page=None, limit=None), plus agent.snapshot(..., wait_until_ready=False) and agent.snapshots() on the handles. Same params and Snapshot shape as the sandbox calls.
  • Agent fork: client.agents.fork(id, name) and agent.fork(name) return the new agent, which is Provisioning until wait_until_ready(). The source agent keeps running.
  • Errors: HTTP 425 now raises TooEarlyError instead of a plain APIError. A 409 still raises ConflictError.
  • Sync and async are the same throughout. Agent rollback already existed and is unchanged.

Spec regeneration (first commit)

The updated specs/aiagent.yaml changes some response shapes. After regenerating, 32 tests failed on old test data, and they now pass:

  • Snapshots: trigger is now required. The SDK keeps it optional so older servers still work. snapshot_type (full / filesystem) can be set on create.
  • Audit trail: it now also records programs (Process Activity) and connections (Network Activity). Those events have no api, so the audit examples check for it first.
  • Audit fields: every event carries device and cloud.org. actor.user.type is now User / API Key / System / Unknown, and the API key moved to programmatic_credentials. The actor_type filter still takes user / api_key / system.

Differs from the ticket

The ticket says fork returns a new sandbox. The API returns a new agent, and this PR follows the API.

Testing

  • uv run pytest: 692 passed. The new tests/test_agent_snapshots.py covers each method, sync and async, plus the 409/425 errors.
  • ruff is clean. mypy shows the same 5 errors as main (optional packages not installed).
  • examples/agent_snapshot_fork_rollback.py was run against the dev server: snapshot became Ready, fork had the agent's files, rollback restored them with the same ID and name, and cleanup succeeded.
  • Note: deleting an agent appears to delete its snapshots too (a later delete of the snapshot returned 404). The spec doesn't say so.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9e15a5db-72ed-4bf5-8e1f-b2c1c9ec1c44
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mayur-tolexo mayur-tolexo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rmanjunath18
rmanjunath18 force-pushed the feat/agent-fork branch 2 times, most recently from 07f392b to d4afa70 Compare November 2, 2026 16:23
Agents and AsyncAgents gain create_snapshot, list_snapshots and fork, and the agent handles gain snapshot, snapshots and fork. Fork returns the new agent, Provisioning until ready. HTTP 425 now raises TooEarlyError. Adds docs, a changeset and an end-to-end example.

Regenerates the aiagent types from the updated spec: snapshots now carry a required trigger and can be filesystem-only; audit events add program and network records, device and cloud.org, and new actor type captions. Keep trigger optional for older servers, accept snapshot_type on create, update test data to the new shapes, and stop the audit examples reading api on events that have none.

AIPLATFORM-1564
@rmanjunath18
rmanjunath18 merged commit 9f42af6 into main Nov 2, 2026
5 checks passed
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