This commit is contained in:
Ian Gulliver
2026-10-21 10:23:02 -07:00
parent 3dfd59115e
commit e2faadf61e
2 changed files with 13 additions and 23 deletions
+9 -19
View File
@@ -7,7 +7,6 @@ import (
"fmt"
"log/slog"
"strings"
"sync"
"time"
"g.fc.run/ai/byre/internal/antigravity"
@@ -15,16 +14,11 @@ import (
)
type agySteps struct {
mu sync.Mutex
text map[int]*strings.Builder
tools map[string]bool
}
func newAgySteps() *agySteps {
return &agySteps{text: map[int]*strings.Builder{}, tools: map[string]bool{}}
}
func (m *Manager) handleAntigravity(ctx context.Context, l *live, p antigravityProcess, ev antigravity.Event) error {
func (m *Manager) handleAntigravity(ctx context.Context, l *live, p antigravityProcess, steps *agySteps, ev antigravity.Event) error {
switch ev.Kind {
case "init":
return nil
@@ -34,7 +28,7 @@ func (m *Manager) handleAntigravity(ctx context.Context, l *live, p antigravityP
if err != nil {
return err
}
return m.agyStep(ctx, l, p, ev, su)
return m.agyStep(ctx, l, steps, ev, su)
case "result":
res, err := ev.Result()
@@ -52,24 +46,22 @@ func (m *Manager) handleAntigravity(ctx context.Context, l *live, p antigravityP
return m.emit(ctx, l, agentActor, "agent.vendor", raw)
}
func (m *Manager) agyStep(ctx context.Context, l *live, p antigravityProcess, ev antigravity.Event, su antigravity.StepUpdate) error {
func (m *Manager) agyStep(ctx context.Context, l *live, steps *agySteps, ev antigravity.Event, su antigravity.StepUpdate) error {
switch su.StepType {
case "user_input":
return nil
case "agent_response":
p.steps.mu.Lock()
b := p.steps.text[su.StepIndex]
b := steps.text[su.StepIndex]
if b == nil {
b = &strings.Builder{}
p.steps.text[su.StepIndex] = b
steps.text[su.StepIndex] = b
}
b.WriteString(su.TextDelta)
done := su.State != "ACTIVE"
if done {
delete(p.steps.text, su.StepIndex)
delete(steps.text, su.StepIndex)
}
p.steps.mu.Unlock()
if su.TextDelta != "" {
m.store.Broadcast(m.event(l, agentActor, "agent.delta", map[string]any{"text": su.TextDelta}))
@@ -89,13 +81,11 @@ func (m *Manager) agyStep(ctx context.Context, l *live, p antigravityProcess, ev
if su.ToolInfo != nil {
info = *su.ToolInfo
}
p.steps.mu.Lock()
called := p.steps.tools[id]
p.steps.tools[id] = su.State == "ACTIVE"
called := steps.tools[id]
steps.tools[id] = su.State == "ACTIVE"
if su.State != "ACTIVE" {
delete(p.steps.tools, id)
delete(steps.tools, id)
}
p.steps.mu.Unlock()
if !called {
name, input, err := agyToolCall(su.ToolName, info.Parameters)