Add a per-user lead agent and make the right pane task-focused

This commit is contained in:
Ian Gulliver
2026-10-15 09:40:30 -07:00
parent d212590cdc
commit bdd1ae48f0
68 changed files with 3332 additions and 1364 deletions
+27 -4
View File
@@ -14,10 +14,28 @@ const handoffPrompt = `Write a handoff for a fresh agent that will continue this
const handoffPreamble = "You are continuing this task from a previous agent session, which ended so the work could go on with a fresh context. Its handoff follows.\n\n"
const leadHandoffPreamble = "You are continuing as the human's lead agent from a previous session, which ended so you could go on with a fresh context. Its handoff follows. Signals that arrived meanwhile come next.\n\n"
const leadHandoffPrompt = `Write a handoff for a fresh lead agent that will take over from you with none of your context. ` +
`Cover: the human's standing instructions and preferences; what each task you are tracking is doing and what you are waiting on from it; ` +
`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 string) (api.AgentSession, error) {
sess, err := m.store.GetSession(ctx, sessionID)
if err != nil {
return api.AgentSession{}, err
}
if sess.Owner != "" {
return m.Send(ctx, sessionID, "byre", leadHandoffPrompt, "")
}
return m.Send(ctx, sessionID, "byre", handoffPrompt, "")
}
func isHandoffPrompt(actor, text string) bool {
return actor == "byre" && (text == handoffPrompt || text == leadHandoffPrompt)
}
func (m *Manager) continueFromHandoff(sessionID, handoff string) {
ctx := context.Background()
err := m.handoff(ctx, sessionID, handoff)
@@ -31,10 +49,6 @@ func (m *Manager) handoff(ctx context.Context, sessionID, handoff string) error
if err != nil {
return err
}
task, err := m.store.GetTask(ctx, sess.TaskId)
if err != nil {
return err
}
creator, err := m.store.GetUser(ctx, sess.CreatedBy)
if err != nil {
return err
@@ -45,6 +59,15 @@ func (m *Manager) handoff(ctx context.Context, sessionID, handoff string) error
return err
}
if sess.Owner != "" {
_, err = m.createLead(ctx, creator, leadHandoffPreamble+handoff, sess.Model, "byre", nil)
return err
}
task, err := m.store.GetTask(ctx, sess.TaskId)
if err != nil {
return err
}
_, err = m.create(ctx, task, creator, handoffPreamble+handoff, sess.Model, "byre", nil)
return err
}