Bold questions
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package agents
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
|
||||
"g.fc.run/misc/byre/internal/api"
|
||||
)
|
||||
|
||||
const handoffPrompt = `Write a handoff for a fresh agent that will continue this task with none of your context. ` +
|
||||
`Cover: the goal; decisions made and why; the current state (what is done, what is in progress, what is verified); ` +
|
||||
`dead ends tried; open questions; and the files that matter. Be complete: the next agent sees nothing else. ` +
|
||||
`Your final message is the handoff, and nothing else.`
|
||||
|
||||
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"
|
||||
|
||||
func (m *Manager) Compact(ctx context.Context, sessionID string) (api.AgentSession, error) {
|
||||
return m.Send(ctx, sessionID, "byre", handoffPrompt, "")
|
||||
}
|
||||
|
||||
func (m *Manager) continueFromHandoff(sessionID, handoff string) {
|
||||
ctx := context.Background()
|
||||
err := m.handoff(ctx, sessionID, handoff)
|
||||
if err != nil {
|
||||
slog.Error("continue from handoff", "session", sessionID, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) handoff(ctx context.Context, sessionID, handoff string) error {
|
||||
sess, err := m.store.GetSession(ctx, sessionID)
|
||||
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
|
||||
}
|
||||
|
||||
err = m.retire(ctx, sess, "byre")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = m.create(ctx, task, creator, handoffPreamble+handoff, sess.Model, "byre")
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user