Support configuring effort alongside model

This commit is contained in:
Ian Gulliver
2026-10-23 08:40:00 -07:00
parent 6bbae3fffe
commit d6d9dd86d9
40 changed files with 805 additions and 541 deletions
+15 -11
View File
@@ -25,7 +25,7 @@ const leadHandoffPrompt = `Write a handoff for a fresh lead agent that will take
`questions you have surfaced or answered and why; what you last pointed the human's attention at; and anything you promised to do or check. ` +
`Be complete: the next agent sees nothing else. Your final message is the handoff, and nothing else.`
func (m *Manager) Compact(ctx context.Context, sessionID, model string) (api.AgentSession, error) {
func (m *Manager) Compact(ctx context.Context, sessionID, model, effort string) (api.AgentSession, error) {
sess, err := m.store.GetSession(ctx, sessionID)
if err != nil {
return api.AgentSession{}, err
@@ -44,29 +44,33 @@ func (m *Manager) Compact(ctx context.Context, sessionID, model string) (api.Age
if err != nil {
return api.AgentSession{}, err
}
return m.launchCompaction(ctx, sess, task, model)
return m.launchCompaction(ctx, sess, task, model, effort)
}
func (m *Manager) launchCompaction(ctx context.Context, sess api.AgentSession, task api.Task, model string) (api.AgentSession, error) {
type modelChoice struct {
model, effort string
}
func (m *Manager) launchCompaction(ctx context.Context, sess api.AgentSession, task api.Task, model, effort string) (api.AgentSession, error) {
prompt := handoffPrompt
if sess.Owner != "" {
prompt = leadHandoffPrompt
}
m.mu.Lock()
m.handoffModel[sess.Id] = model
m.handoffModel[sess.Id] = modelChoice{model, effort}
m.mu.Unlock()
return m.launch(ctx, sess, task, "byre", prompt, "", "", nil)
}
func (m *Manager) continuationModel(sess api.AgentSession) string {
func (m *Manager) continuationModel(sess api.AgentSession) modelChoice {
m.mu.Lock()
model := m.handoffModel[sess.Id]
c := m.handoffModel[sess.Id]
delete(m.handoffModel, sess.Id)
m.mu.Unlock()
if model == "" {
return sess.Model
if c.model == "" {
return modelChoice{sess.Model, sess.Effort}
}
return model
return c
}
func isHandoffPrompt(actor, text string) bool {
@@ -107,7 +111,7 @@ func (m *Manager) handoff(ctx context.Context, sessionID, handoff string) error
if err != nil {
return err
}
_, err = m.createLead(ctx, creator, leadHandoffPreamble+handoff, model, "byre", "", "", nil)
_, err = m.createLead(ctx, creator, leadHandoffPreamble+handoff, model.model, model.effort, "byre", "", "", nil)
return err
}
@@ -118,7 +122,7 @@ func (m *Manager) handoff(ctx context.Context, sessionID, handoff string) error
if err != nil {
return err
}
next := sessionFor(task, creator, sess.Member, model)
next := sessionFor(task, creator, sess.Member, model.model, model.effort)
next.State = api.AgentSessionStateRunning
err = m.store.ReplaceSession(ctx, sess.Id, next, task.ProjectId, "byre")
if errors.Is(err, store.ErrStateChanged) {