no gemini

This commit is contained in:
Ian Gulliver
2026-10-18 16:24:11 -07:00
parent c4d7a67dad
commit 603a0eda6b
4 changed files with 83 additions and 2 deletions
+39
View File
@@ -7,8 +7,10 @@ import (
"log/slog"
"strings"
"sync"
"time"
"g.fc.run/ai/byre/internal/antigravity"
"g.fc.run/ai/byre/internal/api"
)
type agySteps struct {
@@ -151,6 +153,7 @@ func (m *Manager) agyTurnEnded(ctx context.Context, l *live, p antigravityProces
m.mu.Lock()
final := l.lastText
m.mu.Unlock()
go m.readAgyRateLimit()
success := res.Status == "SUCCESS"
bounce := false
@@ -194,6 +197,42 @@ func (m *Manager) agyTurnEnded(ctx context.Context, l *live, p antigravityProces
return m.turnEnded(ctx, l, r)
}
var agyWindowMins = map[string]int{"5h": 300, "weekly": 7 * 24 * 60}
func (m *Manager) readAgyRateLimit() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
groups, err := antigravity.ReadUsage(ctx)
if err != nil {
slog.Error("read antigravity rate limits", "err", err)
return
}
m.mu.Lock()
m.rateLimits[api.Antigravity] = agyRateLimit(groups)
m.mu.Unlock()
m.store.Broadcast(api.Event{Kind: "admin.health", Actor: "byre", Payload: map[string]any{}})
}
func agyRateLimit(groups []antigravity.UsageGroup) map[string]any {
info := map[string]any{"status": "allowed"}
windows := map[string]any{}
for _, g := range groups {
for _, b := range g.Buckets {
window := map[string]any{"utilization": 1 - b.RemainingFraction, "resetsAt": b.ResetTime.Unix()}
if mins := agyWindowMins[b.Window]; mins != 0 {
window["windowMins"] = mins
}
windows[b.ID] = window
if b.RemainingFraction <= 0 {
info["status"] = "rejected"
info["rateLimitType"] = b.ID
}
}
}
info["unifiedWindows"] = windows
return info
}
func (m *Manager) agyBeforeModel(l *live) antigravity.HookFunc {
return func(ctx context.Context, input json.RawMessage) (map[string]any, error) {
in := struct {
+1
View File
@@ -161,6 +161,7 @@ func New(st *store.Store, worktreeRoot, leadRoot, handsRoot, codexHome, antigrav
}
go m.signalLoop()
go m.readCodexRateLimit()
go m.readAgyRateLimit()
return m
}