Run tasks on Codex beside Claude; drop turn caps and mid-turn snapshots

This commit is contained in:
Ian Gulliver
2026-10-15 14:55:58 -07:00
parent 17898b0191
commit 74707f6398
53 changed files with 1904 additions and 1295 deletions
+15 -12
View File
@@ -10,7 +10,6 @@ import (
"time"
"g.fc.run/misc/byre/internal/api"
"g.fc.run/misc/byre/internal/claude"
"g.fc.run/misc/byre/internal/store"
)
@@ -67,12 +66,13 @@ func (m *Manager) createLead(ctx context.Context, owner api.User, prompt, model,
}
id := newUUID()
vendor := vendorOf(model)
sess := api.AgentSession{
Id: id,
Owner: owner.Login,
Vendor: api.Claude,
Vendor: vendor,
Model: model,
VendorSessionId: id,
VendorSessionId: initialVendorSessionID(vendor, id),
State: api.AgentSessionStateIdle,
Role: api.Lead,
CreatedBy: owner.Login,
@@ -105,6 +105,10 @@ func (m *Manager) MessageLead(ctx context.Context, user api.User, text, model st
}
if model != "" && model != sess.Model {
err = checkModel(sess, model)
if err != nil {
return api.AgentSession{}, err
}
err = m.store.SetSessionModel(ctx, sess.Id, model, user.Login)
if err != nil {
return api.AgentSession{}, err
@@ -200,17 +204,17 @@ func (m *Manager) parkLeads(ctx context.Context) error {
return nil
}
func (m *Manager) leadTurnEnded(ctx context.Context, l *live, res claude.Result) error {
func (m *Manager) leadTurnEnded(ctx context.Context, l *live, res endResult) error {
m.mu.Lock()
interrupted := l.interrupted
compacting := l.compacting
wantCompact := l.wantCompact
m.mu.Unlock()
finished := !res.IsError && !interrupted && strings.TrimSpace(res.Result) != ""
finished := !res.isError && !interrupted && strings.TrimSpace(res.result) != ""
handoff := compacting && finished
payload := store.ToPayload(res)
payload := res.payload
if handoff {
payload["handoff"] = true
}
@@ -219,17 +223,16 @@ func (m *Manager) leadTurnEnded(ctx context.Context, l *live, res claude.Result)
return err
}
window := res.ModelUsage[l.contextModel].ContextWindow
if window > 0 {
err = m.updateContext(ctx, l, l.contextUsed, window)
if res.window > 0 {
err = m.updateContext(ctx, l, l.contextUsed, res.window)
if err != nil {
return err
}
}
var state map[string]any
if res.IsError && !interrupted {
state = map[string]any{"error": fmt.Sprintf("the turn ended with an error (%s): %s", res.Subtype, res.Result)}
if res.isError && !interrupted {
state = map[string]any{"error": fmt.Sprintf("the turn ended with an error (%s): %s", res.subtype, res.result)}
}
err = m.store.SetSessionState(ctx, l.id, api.AgentSessionStateIdle, agentActor, state)
if err != nil {
@@ -238,7 +241,7 @@ func (m *Manager) leadTurnEnded(ctx context.Context, l *live, res claude.Result)
switch {
case handoff:
go m.continueFromHandoff(l.id, res.Result)
go m.continueFromHandoff(l.id, res.result)
case wantCompact && finished && !compacting:
go func() {
_, err := m.Compact(context.Background(), l.id)