Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Simplify cloud telemetry final uploads

shukieshah81e5810cd3cf
diff --git a/cli/beacon-hooks/cmd/session_end.go b/cli/beacon-hooks/cmd/session_end.go
index 53f737ae..62f51a2c 100644
--- a/cli/beacon-hooks/cmd/session_end.go
+++ b/cli/beacon-hooks/cmd/session_end.go
@@ -46,6 +46,9 @@ func runSessionEnd(cmd *cobra.Command, args []string) {
platformLogger.Info("Session ended", "platform", platformFlag)
emitHookEvent(platformLogger, "session.ended", "session", "info", "Agent session ended", input, sessionFields("", input))
uploadCloudTelemetry(platformLogger, true)
+ } else {
+ platformLogger.Info("Session ended", "platform", platformFlag)
+ uploadCloudTelemetry(platformLogger, true)
}
cleaned := state.CleanupStaleForPlatform(platformFlag)
diff --git a/cli/beacon-hooks/internal/cloudshuttle/shuttle.go b/cli/beacon-hooks/internal/cloudshuttle/shuttle.go
index dce3eb65..1fb4803a 100644
--- a/cli/beacon-hooks/internal/cloudshuttle/shuttle.go
+++ b/cli/beacon-hooks/internal/cloudshuttle/shuttle.go
@@ -19,14 +19,12 @@ import (
"os"
"path"
"path/filepath"
- "strconv"
"strings"
"syscall"
"time"
)
const (
- defaultInterval = 60 * time.Second
defaultLogPath = "/tmp/beacon/runtime.jsonl"
defaultStatePath = "/tmp/beacon/shuttle-state.json"
defaultTokenURI = "https://oauth2.googleapis.com/token"
@@ -42,7 +40,6 @@ type Config struct {
Bucket string
Prefix string
CredentialsB64 string
- Interval time.Duration
Provider string
RunID string
UserID string
@@ -69,14 +66,6 @@ type tokenResponse struct {
}
func ConfigFromEnv() Config {
- interval := defaultInterval
- if raw := strings.TrimSpace(os.Getenv("BEACON_CLOUD_UPLOAD_INTERVAL")); raw != "" {
- if raw == "0" {
- interval = 0
- } else if parsed, err := time.ParseDuration(raw); err == nil {
- interval = parsed
- }
- }
statePath := firstEnvDefault(defaultStatePath, "BEACON_CLOUD_SHUTTLE_STATE")
return Config{
LogPath: firstEnvDefault(defaultLogPath, "BEACON_CLOUD_LOG_PATH", "BEACON_ENDPOINT_LOG", "BEACON_LOG_PATH", "BEACON_RUNTIME_LOG"),
@@ -84,7 +73,6 @@ func ConfigFromEnv() Config {
Bucket: strings.TrimSpace(os.Getenv("BEACON_CLOUD_GCS_BUCKET")),
Prefix: strings.Trim(strings.TrimSpace(os.Getenv("BEACON_CLOUD_GCS_PREFIX")), "/"),
CredentialsB64: strings.TrimSpace(os.Getenv("BEACON_CLOUD_GCS_CREDENTIALS_B64")),
- Interval: interval,
Provider: firstEnvDefault("claude_code_web", "BEACON_RUN_PROVIDER"),
RunID: resolveRunID(statePath),
UserID: firstEnvDefault("unknown", "BEACON_CLOUD_USER_ID_HASH", "BEACON_CLOUD_USER_ID"),
@@ -139,7 +127,7 @@ func Upload(ctx context.Context, cfg Config, force bool) error {
if info.Size() == 0 {
return nil
}
- if !force && !uploadDue(cfg, info.Size(), time.Now().UTC()) {
+ if !force {
return nil
}
snapshot, cleanup, err := snapshotLog(cfg.LogPath)
@@ -176,27 +164,6 @@ func ObjectName(cfg Config) string {
return path.Join(parts...)
}
-func uploadDue(cfg Config, currentSize int64, now time.Time) bool {
- if cfg.Interval <= 0 {
- return false
- }
- st, err := readState(cfg.StatePath)
- if err != nil {
- return true
- }
- if currentSize != st.LastSize {
- // Still respect interval to avoid uploading on every hook during active runs.
- }
- if st.LastUpload == "" {
- return true
- }
- last, err := time.Parse(time.RFC3339, st.LastUpload)
- if err != nil {
- return true
- }
- return now.Sub(last) >= cfg.Interval
-}
-
func snapshotLog(logPath string) (string, func(), error) {
lock, err := os.OpenFile(logPath+".lock", os.O_CREATE|os.O_RDWR, 0644)
if err != nil {
@@ -500,8 +467,3 @@ func firstEnvDefault(defaultValue string, keys ...string) string {
func EncodeCredentialsForEnv(data []byte) string {
return base64.StdEncoding.EncodeToString(bytes.TrimSpace(data))
}
-
-func ParseBoolEnv(key string) bool {
- value, _ := strconv.ParseBool(strings.TrimSpace(os.Getenv(key)))
- return value
-}
diff --git a/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go b/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go
index c0c4125f..909a8269 100644
--- a/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go
+++ b/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go
@@ -15,7 +15,6 @@ import (
"path/filepath"
"strings"
"testing"
- "time"
)
func TestObjectNamePartitionsByProviderUserRepoAndRun(t *testing.T) {
@@ -130,17 +129,6 @@ func TestUploadSendsJSONLToGCS(t *testing.T) {
}
}
-func TestUploadRespectsInterval(t *testing.T) {
- dir := t.TempDir()
- statePath := filepath.Join(dir, "state.json")
- if err := writeState(statePath, state{LastUpload: time.Now().UTC().Format(time.RFC3339), LastSize: 10}); err != nil {
- t.Fatalf("write state: %v", err)
- }
- if uploadDue(Config{StatePath: statePath, Interval: time.Hour}, 11, time.Now().UTC()) {
- t.Fatal("uploadDue = true, want false inside interval")
- }
-}
-
func TestStableFallbackRunIDReusesGeneratedValue(t *testing.T) {
statePath := filepath.Join(t.TempDir(), "shuttle-state.json")
first := stableFallbackRunID(statePath)
diff --git a/cli/beacon/README.md b/cli/beacon/README.md
index ba82f788..96f28e3e 100644
--- a/cli/beacon/README.md
+++ b/cli/beacon/README.md
@@ -60,7 +60,6 @@ BEACON_ORIGIN=cloud
BEACON_RUN_PROVIDER=claude_code_web
BEACON_RUN_EPHEMERAL=true
BEACON_CLOUD_USER_ID_HASH=<stable-user-or-test-id>
-BEACON_CLOUD_UPLOAD_INTERVAL=60s
```
Then generate the setup script for a Beacon release and paste it into the