Timeout for switch lockout
This commit is contained in:
@@ -24,7 +24,7 @@ const leadGuidance = `You are the human's lead agent in byre, shown in the left
|
||||
- A finished turn that needs the human, discussing a task's work, what its agent did or is doing, or whether it is ready to merge: its transcript tab, which ends with the agent's final message. A specific file in its worktree: its files tab.
|
||||
- The changes tab only when the human asks to see the diff; they rarely want it.
|
||||
- Show, don't tell. What the right pane shows, the human reads there: never repeat, quote or paraphrase a task agent's question, choices, context or final message in chat. Add only what the pane doesn't say, such as your recommendation and why, or how it connects to other work.
|
||||
- Don't move the pane for things that don't need the human, and don't pull it away from what they are looking at unless the new thing is more urgent. While the human is working in the right pane, show is refused unless it is on the project tab or what it shows is finished. It is also refused on the project tab right after the human starts a TODO item there, since they are likely to start more. When show is refused, say in chat what you would have shown, and carry on.
|
||||
- Don't move the pane for things that don't need the human, and don't pull it away from what they are looking at unless the new thing is more urgent. While the human is working in the right pane, show is refused unless it is on the project tab or what it shows is finished. It is also refused on the project tab for 10 seconds after the human starts a TODO item there, since they are likely to start more. When show is refused, say in chat what you would have shown, and carry on. "The start hold is over" means those 10 seconds passed with the pane still on the project tab: show what you held back, if it still matters, or make your final message NO_REPLY.
|
||||
- Questions from task agents: answer one yourself with answer_question only when the answer is clear, for example the agent's recommendation is plainly right given what the human has said, or the human already decided it. Otherwise show it to the human with your recommendation and wait. When the human tells you an answer, give it with answer_question. Say which questions you answered and how.
|
||||
- Finished turns: read them and show the human only what matters: work finished and ready to merge, problems, decisions made. Stay quiet about routine progress.
|
||||
- Reviews: after each new snapshot of a task, a reviewer agent from the other vendor reviews the change. The results are on the task's reviews tab, read_transcript shows each review's findings, and a question shows the review of the turn that asked it. They are for the human to look at when they want; mention one only when its findings matter to what the human is deciding.
|
||||
|
||||
@@ -5,8 +5,10 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"g.fc.run/misc/byre/internal/api"
|
||||
"g.fc.run/misc/byre/internal/git"
|
||||
@@ -326,7 +328,7 @@ func (m *Manager) leadTools(l *live) []mcp.Tool {
|
||||
"Omit both task_id and project_id to clear the pane. "+
|
||||
"If the pane already shows that task (or project) on that tab, only the tab order changes and you are told so, even while the human is working in the pane. "+
|
||||
"Otherwise refused while the human is working in the right pane, unless it is on the project tab or what it shows is finished (a merged or discarded task, or an inbox tab with nothing left). "+
|
||||
"Also refused while the pane is on the project tab and the human's last action was starting a TODO item there, until they switch task or tab or message you.",
|
||||
"Also refused while the pane is on the project tab and the human started a TODO item there in the last 10 seconds, unless they switched task or tab or messaged you since; byre signals you \"The start hold is over\" when those 10 seconds pass with the pane still on the project tab.",
|
||||
`{"type": "object", "properties": {
|
||||
"task_id": {"type": "string"},
|
||||
"project_id": {"type": "string", "description": "Ignored when task_id is given."},
|
||||
@@ -357,8 +359,8 @@ func (m *Manager) leadTools(l *live) []mcp.Tool {
|
||||
focused := m.paneFocused[user.Login]
|
||||
startedTodo := m.startedTodo[user.Login]
|
||||
m.mu.Unlock()
|
||||
if startedTodo && current.Tab == api.TabProject {
|
||||
return "", fmt.Errorf("%w: the human just started a TODO item from the project tab and is likely to start more; tell them in chat instead", ErrConflict)
|
||||
if time.Since(startedTodo) < startHold && current.Tab == api.TabProject {
|
||||
return "", fmt.Errorf("%w: the human just started a TODO item from the project tab and is likely to start more; tell them in chat instead. The hold ends %s after that start, unless they move the pane or message you first; byre signals you \"The start hold is over\" when it ends", ErrConflict, startHold)
|
||||
}
|
||||
if focused && current.Tab != api.TabProject {
|
||||
finished, err := m.paneFinished(ctx, current)
|
||||
@@ -461,10 +463,49 @@ func (m *Manager) SetPaneFocus(login string, focused bool) {
|
||||
m.paneFocused[login] = focused
|
||||
}
|
||||
|
||||
const startHold = 10 * time.Second
|
||||
|
||||
const startHoldEnded = "The start hold is over: the human started a TODO item from the project tab 10 seconds ago and the pane is still there, so show works again."
|
||||
|
||||
func (m *Manager) setStartedTodo(login string, started bool) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.startedTodo[login] = started
|
||||
if !started {
|
||||
delete(m.startedTodo, login)
|
||||
return
|
||||
}
|
||||
at := time.Now()
|
||||
m.startedTodo[login] = at
|
||||
time.AfterFunc(startHold, func() {
|
||||
err := m.endStartHold(context.Background(), login, at)
|
||||
if err != nil {
|
||||
slog.Error("end start hold", "login", login, "err", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Manager) endStartHold(ctx context.Context, login string, at time.Time) error {
|
||||
m.mu.Lock()
|
||||
current, ok := m.startedTodo[login]
|
||||
if !ok || !current.Equal(at) {
|
||||
m.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
delete(m.startedTodo, login)
|
||||
m.mu.Unlock()
|
||||
f, err := m.store.GetFocus(ctx, login)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if f.Tab != api.TabProject {
|
||||
return nil
|
||||
}
|
||||
err = m.store.AddLeadInput(ctx, store.LeadInput{Owner: login, Kind: store.LeadSignal, Actor: "byre", Text: startHoldEnded})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.deliverLead(login)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) modelOr(model string, l *live) string {
|
||||
|
||||
@@ -44,7 +44,7 @@ type Manager struct {
|
||||
rateLimits map[api.AgentSessionVendor]map[string]any
|
||||
leadAnswered map[string]bool
|
||||
paneFocused map[string]bool
|
||||
startedTodo map[string]bool
|
||||
startedTodo map[string]time.Time
|
||||
|
||||
deliverMu sync.Mutex
|
||||
leadMu sync.Mutex
|
||||
@@ -106,7 +106,7 @@ func New(st *store.Store, worktreeRoot, leadRoot, codexHome string) *Manager {
|
||||
rateLimits: map[api.AgentSessionVendor]map[string]any{},
|
||||
leadAnswered: map[string]bool{},
|
||||
paneFocused: map[string]bool{},
|
||||
startedTodo: map[string]bool{},
|
||||
startedTodo: map[string]time.Time{},
|
||||
signals: make(chan api.Event, 1024),
|
||||
snaps: map[string]*snapState{},
|
||||
mergeHolders: map[string]string{},
|
||||
|
||||
Reference in New Issue
Block a user