-
Notifications
You must be signed in to change notification settings - Fork 14
Add session file support to generate command for progress persistence and resumption #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add session file support to generate command for progress persistence and resumption #78
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
cmd/generate/session.go
Outdated
Created time.Time `json:"created"` | ||
LastModified time.Time `json:"lastModified"` | ||
PromptFile string `json:"promptFile"` | ||
PromptHash string `json:"promptHash"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- move PromptHash into the PromptPexContext type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Moved PromptHash
from the SessionFile
struct into the PromptPexContext
type. This change simplifies the session file structure and provides better logical organization since the prompt hash is closely tied to the prompt data that's already in the context. All tests have been updated and are passing. (d8aedd6)
cmd/generate/generate.go
Outdated
@@ -107,6 +113,9 @@ func AddCommandLineFlags(cmd *cobra.Command) { | |||
flags.Float64("temperature", 0.0, "Temperature for model inference") | |||
flags.Bool("verbose", false, "Enable verbose output including LLM payloads") | |||
flags.String("http-log", "", "File path to log HTTP requests to (.http, optional)") | |||
|
|||
// Mark session-file as required | |||
cmd.MarkFlagRequired("session-file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! Removed the cmd.MarkFlagRequired("session-file")
line to make the session file optional. The command now works both with and without a session file, gracefully handling the case when no session file is provided by skipping session persistence. (db40b38)
cmd/generate/pipeline.go
Outdated
h.cfg.WriteToOut(fmt.Sprintf("Generating tests for '%s'\n", context.Prompt.Name)) | ||
|
||
// Calculate prompt hash for session saving |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already computed and stored in the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the redundant "Step 1: Generate Intent" comment since the runStepWithSession
function already handles step identification and completion checking automatically. (db40b38)
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Overview
This PR implements session file functionality for the
gh models generate
command, enabling robust progress tracking, interruption recovery, and consistent execution across runs.Problem
The generate command previously ran entirely in memory without any persistence mechanism. This meant:
Solution
Added comprehensive session file support with the following features:
🔧 Core Changes
Required Session File Parameter
# Session file is now required gh models generate --session-file session.json prompt.yml
Progress Persistence
PromptPexContext
with all intermediate resultsConsistency Validation
Smart Step Skipping
📁 Session File Structure
🔄 Workflow Examples
Initial run:
Resuming after interruption:
Error handling:
Testing
Breaking Changes
--session-file
flag is now required for the generate command. Existing scripts will need to be updated to include this parameter.Migration:
Files Changed
cmd/generate/generate.go
- Added session file flag and integrationcmd/generate/pipeline.go
- Added session persistence to pipeline stepscmd/generate/session.go
- New session management functionalitycmd/generate/session_test.go
- Comprehensive test coveragecmd/generate/generate_test.go
- Updated existing testsCloses #[issue-number]
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.