Skip to content

feat: introduce session restoration and resume functionality for agent sessions#760

Merged
michaeljguarino merged 5 commits into
mainfrom
sebastian/prod-4882-add-plural-agents-resume-run-id-command
Jul 8, 2026
Merged

feat: introduce session restoration and resume functionality for agent sessions#760
michaeljguarino merged 5 commits into
mainfrom
sebastian/prod-4882-add-plural-agents-resume-run-id-command

Conversation

@floreks

@floreks floreks commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

This pull request introduces a new agents command group to the CLI, enabling users to list and resume Plural agent runs, including restoring local sessions from uploaded data. The implementation includes a new command structure, supporting services, and comprehensive tests for the resume functionality. Additionally, several dependencies are updated in go.mod.

New agents command and resume functionality:

  • Added new agents command group with a resume subcommand to list and restore/resume Plural agent runs locally, including interactive selection of runs and pull requests. (cmd/command/agents/agents.go, cmd/command/agents/resume.go) [1] [2]
  • Implemented a supporting Service type that handles session restoration, user interaction, and display formatting for agent runs and prompts. (cmd/command/agents/resume.go)
  • Registered the new agents command in the main CLI application. (cmd/command/plural/plural.go) [1] [2]

Dependency updates:

  • Updated several dependencies in go.mod, including github.com/pluralsh/console/go/client, github.com/pluralsh/console/go/controller, github.com/fatih/color, google.golang.org/grpc, k8s.io/api, k8s.io/client-go, and others, to newer versions. (go.mod) [1] [2] [3] [4] [5] [6] [7]

Labels

Test Plan

Locally w/ plrl-dev-aws agent runs for codex/gemini/claude/opencode

Checklist

  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • I have added relevant labels to this PR to help with categorization for release notes.

…t sessions

- Implement `CodexRestorer` for restoring and resuming Codex sessions
- Add `OpencodeRestorer` for handling Opencode session states
- Create `GeminiRestorer` for managing Gemini session restoration
- Develop `ClaudeRestorer` for Claude CLI session management
- Define `HTTPArchiveStore` for downloading and handling archives
- Establish a `Command` interface for executing commands
- Provide `RestoreOptions` and `PreparedSession` structures
- Integrate new command into CLI for resuming agent runs
@floreks floreks self-assigned this Jun 8, 2026
@linear

linear Bot commented Jun 8, 2026

Copy link
Copy Markdown

PROD-4882

@floreks floreks added the enhancement New feature or request label Jun 8, 2026
@socket-security

socket-security Bot commented Jun 8, 2026

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

floreks added 3 commits June 8, 2026 16:45
- Upgrade `golang` version in `gen-client-mocks.sh` to 1.26.4
- Update mockery version in generated mock files to v2.53.6
- Refactor `ConsoleClient` mock functions to handle `AgentRunMinimalFragment`
- Change `foundManifest` to `foundManifestError` in `archive.go` error handling logic
- Disable `goconst` linter due to issues with newer version
- Add a TODO note for fixing and re-enabling the rule later
- Add `ValidateRepository` method in `Repository` interface
- Implement logic to skip branch checkout prompt if already checked out
- Refactor `promptRepoPath` to verify current repository before prompting
- Add comprehensive test coverage for repository path prompting and validation logic.
Comment thread pkg/agents/archive.go
@@ -0,0 +1,221 @@
package agents

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason we don't use the polly tar functions here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ye, current polly untar is basically just a simple untar everything into destination directory. The archive contains a specific directory structure and manifest.json with information about agent run. Here the logic can extract only a part of the archive subtree into specific directory directly to the local agent directory. It can also just read manifest information without extracting it. Also O_TRUNC file mode is useful when unpacking and overriding existing session. Polly implementation does not use it.

Comment thread pkg/agents/manifest.go
if provider != "" && !provider.IsValid() {
return fmt.Errorf("%s is not a valid AgentRuntimeType", decoded.Provider)
}
*m = SessionManifest{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this idiomatic? Seems super weird to just reinitialize against the pointer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ye, this is the normal way of overriding the whole structure after unmarshalling in a pointer receiver func. Doing m = &SessionManifest{} wouldn't work here since that would be reassigning the local pointer instead of the values inside the struct this pointer points to. Usually, we just override a single field with m.Version = newVersion and this is just an alias for (*m).Version = newVersion.

@michaeljguarino michaeljguarino merged commit 4f9a5ab into main Jul 8, 2026
14 checks passed
@michaeljguarino michaeljguarino deleted the sebastian/prod-4882-add-plural-agents-resume-run-id-command branch July 8, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants