Avoid decoding full tool results when forking conversations
This commit is contained in:
@@ -973,6 +973,22 @@ func (s *Store) TaskEvents(ctx context.Context, taskID string, after int64, limi
|
||||
return scanEvents(rows)
|
||||
}
|
||||
|
||||
// ForkEvents returns only the payload fields needed to find a safe conversation boundary.
|
||||
// Tool results can contain large captures that would otherwise be decoded just to discard them.
|
||||
func (s *Store) ForkEvents(ctx context.Context, taskID, sessionID string) ([]api.Event, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `
|
||||
SELECT seq, kind, project_id, task_id, agent_session_id, owner, actor,
|
||||
json_object('vendor_uuid', json_extract(payload, '$.vendor_uuid'),
|
||||
'id', json_extract(payload, '$.id'), 'tool_use_id', json_extract(payload, '$.tool_use_id')),
|
||||
created_at
|
||||
FROM events WHERE task_id = ? AND agent_session_id = ? ORDER BY seq
|
||||
`, taskID, sessionID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return scanEvents(rows)
|
||||
}
|
||||
|
||||
func (s *Store) TranscriptEvents(ctx context.Context, taskID string, after int64, limit int) ([]api.Event, error) {
|
||||
query := "SELECT " + eventColumns + " FROM events WHERE task_id = ? AND seq > ?"
|
||||
args := []any{taskID, after}
|
||||
|
||||
Reference in New Issue
Block a user