Skip to content

Commit 279f81f

Browse files
intel352claude
andcommitted
fix: session auto-expiry + Ollama thinking suppression
1. Session cleanup: on daemon startup, mark sessions older than 24h as completed. Prevents indefinite accumulation of stale sessions. 2. Bump workflow-plugin-agent to v0.6.4: Ollama thinking disabled by default (think:false), uses native NumPredict for max tokens. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a179ace commit 279f81f

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
charm.land/bubbletea/v2 v2.0.1
88
charm.land/lipgloss/v2 v2.0.0
99
github.com/GoCodeAlone/workflow v0.3.56
10-
github.com/GoCodeAlone/workflow-plugin-agent v0.6.3
10+
github.com/GoCodeAlone/workflow-plugin-agent v0.6.4
1111
github.com/charmbracelet/glamour v0.10.0
1212
github.com/google/generative-ai-go v0.20.1
1313
github.com/google/uuid v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ github.com/GoCodeAlone/modular/modules/scheduler v1.14.0 h1:JSrzo4FB7uGASExv+fCL
6868
github.com/GoCodeAlone/modular/modules/scheduler v1.14.0/go.mod h1:emkR2AnilabLJZv1rOTDO9eGpRBmZs487H00Lnp9jIc=
6969
github.com/GoCodeAlone/workflow v0.3.56 h1:jsJmVwCRLz7XOTLQNoyE7POBDW3SmqbG/18VnAzbaEc=
7070
github.com/GoCodeAlone/workflow v0.3.56/go.mod h1:uATRqpqPubm+g2jJtYoaMTMmjlUaXnLsSdZk5of+jW0=
71-
github.com/GoCodeAlone/workflow-plugin-agent v0.6.3 h1:oMbDvhR3EFwXiy1Gt04UPvrxzE0JTxKc0m5PXPMc6bY=
72-
github.com/GoCodeAlone/workflow-plugin-agent v0.6.3/go.mod h1:rUvcW5BpQYVV+QmUjYJJ7BZHa3tmOZqCUuztk/++EJM=
71+
github.com/GoCodeAlone/workflow-plugin-agent v0.6.4 h1:9DuFAaG2r3XOADa3WQntwS60rTiqKMux+YuXJMJxoeY=
72+
github.com/GoCodeAlone/workflow-plugin-agent v0.6.4/go.mod h1:rUvcW5BpQYVV+QmUjYJJ7BZHa3tmOZqCUuztk/++EJM=
7373
github.com/GoCodeAlone/workflow-plugin-authz v0.2.2 h1:xnaNLQybNv4u/TeC1+pJuwUHbLPZaCOtcWcUn4HVeq4=
7474
github.com/GoCodeAlone/workflow-plugin-authz v0.2.2/go.mod h1:jyeRNdNl8qCXwTc1lGYPazz97ZjCVrE2OGgqGheBJV0=
7575
github.com/GoCodeAlone/yaegi v0.17.1 h1:aPAwU29L9cGceRAff02c5pjQcT5KapDB4fWFZK9tElE=

internal/daemon/service.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@ func NewService(ctx context.Context) (*Service, error) {
5555
if err != nil {
5656
return nil, err
5757
}
58+
sm := NewSessionManager(engine.DB)
59+
// Clean up stale sessions from previous daemon runs (24h expiry).
60+
if cleaned, err := sm.CleanupStale(ctx, 24*time.Hour); err != nil {
61+
log.Printf("session cleanup: %v", err)
62+
} else if cleaned > 0 {
63+
log.Printf("session cleanup: marked %d stale sessions as completed", cleaned)
64+
}
65+
5866
svc := &Service{
5967
startedAt: time.Now(),
6068
engine: engine,
61-
sessions: NewSessionManager(engine.DB),
69+
sessions: sm,
6270
permGate: newPermissionGate(),
6371
approvalGate: NewApprovalGate(),
6472
plans: NewPlanManager(engine.Hooks),

internal/daemon/sessions.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ func (sm *SessionManager) SetBackground(ctx context.Context, id string) error {
123123
return err
124124
}
125125

126+
// CleanupStale marks sessions older than maxAge as completed.
127+
// Called on daemon startup to prevent indefinite accumulation.
128+
func (sm *SessionManager) CleanupStale(ctx context.Context, maxAge time.Duration) (int64, error) {
129+
cutoff := time.Now().Add(-maxAge).Format(time.RFC3339)
130+
result, err := sm.db.ExecContext(ctx,
131+
`UPDATE sessions SET status = 'completed' WHERE status = 'active' AND created_at < ?`, cutoff)
132+
if err != nil {
133+
return 0, err
134+
}
135+
return result.RowsAffected()
136+
}
137+
126138
// Subscribe returns a channel for receiving session events.
127139
func (sm *SessionManager) Subscribe(sessionID string) chan any {
128140
ch := make(chan any, 64)

0 commit comments

Comments
 (0)