Skip to content

Commit 0d760e7

Browse files
authored
add snapshot flags for oz worker (#56)
1 parent d860b2e commit 0d760e7

3 files changed

Lines changed: 44 additions & 12 deletions

File tree

internal/common/task_utils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ func AugmentArgsForTask(task *types.Task, args []string, opts TaskAugmentOptions
8686
args = append(args, "--share", fmt.Sprintf("public:%s", level))
8787
}
8888
}
89+
90+
if task.AgentConfigSnapshot.SnapshotDisabled != nil && *task.AgentConfigSnapshot.SnapshotDisabled {
91+
args = append(args, "--no-snapshot")
92+
}
93+
if task.AgentConfigSnapshot.SnapshotUploadTimeoutSecs != nil && *task.AgentConfigSnapshot.SnapshotUploadTimeoutSecs > 0 {
94+
args = append(args, "--snapshot-upload-timeout", fmt.Sprintf("%ds", *task.AgentConfigSnapshot.SnapshotUploadTimeoutSecs))
95+
}
96+
if task.AgentConfigSnapshot.SnapshotScriptTimeoutSecs != nil && *task.AgentConfigSnapshot.SnapshotScriptTimeoutSecs > 0 {
97+
args = append(args, "--snapshot-script-timeout", fmt.Sprintf("%ds", *task.AgentConfigSnapshot.SnapshotScriptTimeoutSecs))
98+
}
8999
}
90100

91101
if task.AgentConfigSnapshot != nil && task.AgentConfigSnapshot.EnvironmentID != nil {

internal/common/task_utils_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
func strPtr(v string) *string { return &v }
1111
func intPtr(v int) *int { return &v }
12+
func boolPtr(v bool) *bool { return &v }
1213
func accessPtr(v types.AccessLevel) *types.AccessLevel { return &v }
1314

1415
func TestAugmentArgsForTask_IdleOnCompletePrecedence(t *testing.T) {
@@ -170,6 +171,24 @@ func TestAugmentArgsForTask_IdleOnCompletePrecedence(t *testing.T) {
170171
opts: TaskAugmentOptions{},
171172
expected: []string{"agent", "run", "--idle-on-complete"},
172173
},
174+
{
175+
name: "adds snapshot controls when configured",
176+
task: &types.Task{
177+
AgentConfigSnapshot: &types.AmbientAgentConfig{
178+
SnapshotDisabled: boolPtr(true),
179+
SnapshotUploadTimeoutSecs: intPtr(90),
180+
SnapshotScriptTimeoutSecs: intPtr(45),
181+
},
182+
},
183+
opts: TaskAugmentOptions{},
184+
expected: []string{
185+
"agent", "run",
186+
"--no-snapshot",
187+
"--snapshot-upload-timeout", "90s",
188+
"--snapshot-script-timeout", "45s",
189+
"--idle-on-complete",
190+
},
191+
},
173192
}
174193

175194
for _, tt := range tests {

internal/types/messages.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,21 @@ type SessionSharingConfig struct {
107107

108108
// AmbientAgentConfig represents the agent configuration.
109109
type AmbientAgentConfig struct {
110-
EnvironmentID *string `json:"environment_id,omitempty"`
111-
BasePrompt *string `json:"base_prompt,omitempty"`
112-
ModelID *string `json:"model_id,omitempty"`
113-
ProfileID *string `json:"profile_id,omitempty"`
114-
SkillSpec *string `json:"skill_spec,omitempty"`
115-
MCPServers map[string]json.RawMessage `json:"mcp_servers,omitempty"`
116-
ComputerUseEnabled *bool `json:"computer_use_enabled,omitempty"`
117-
IdleTimeoutMinutes *int `json:"idle_timeout_minutes,omitempty"`
118-
Harness *Harness `json:"harness,omitempty"`
119-
HarnessAuthSecrets *HarnessAuthSecrets `json:"harness_auth_secrets,omitempty"`
120-
BedrockInferenceRole *string `json:"bedrock_inference_role,omitempty"`
121-
SessionSharing *SessionSharingConfig `json:"session_sharing,omitempty"`
110+
EnvironmentID *string `json:"environment_id,omitempty"`
111+
BasePrompt *string `json:"base_prompt,omitempty"`
112+
ModelID *string `json:"model_id,omitempty"`
113+
ProfileID *string `json:"profile_id,omitempty"`
114+
SkillSpec *string `json:"skill_spec,omitempty"`
115+
MCPServers map[string]json.RawMessage `json:"mcp_servers,omitempty"`
116+
ComputerUseEnabled *bool `json:"computer_use_enabled,omitempty"`
117+
IdleTimeoutMinutes *int `json:"idle_timeout_minutes,omitempty"`
118+
Harness *Harness `json:"harness,omitempty"`
119+
HarnessAuthSecrets *HarnessAuthSecrets `json:"harness_auth_secrets,omitempty"`
120+
BedrockInferenceRole *string `json:"bedrock_inference_role,omitempty"`
121+
SessionSharing *SessionSharingConfig `json:"session_sharing,omitempty"`
122+
SnapshotDisabled *bool `json:"snapshot_disabled,omitempty"`
123+
SnapshotUploadTimeoutSecs *int `json:"snapshot_upload_timeout_secs,omitempty"`
124+
SnapshotScriptTimeoutSecs *int `json:"snapshot_script_timeout_secs,omitempty"`
122125
}
123126

124127
// Task represents an ambient agent job.

0 commit comments

Comments
 (0)