Let the lead keep notes on how its user works
This commit is contained in:
@@ -25,7 +25,8 @@ const leadGuidance = `You are the human's lead agent in byre, shown in the left
|
||||
- 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 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.
|
||||
- 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, the human already decided it, or one of your notes settles it outright. 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, naming the note by its id when one decided it.
|
||||
- Notes: you learn how the human works and keep it with remember, forget and list_notes. byre adds every note to your instructions at the start of each lead session, so they outlast compaction; the human can read and delete them in the Settings tab. Write a note when the human shows a priority, a preference or the reasoning behind a choice that will recur: an answer that departs from the agent's recommendation (the answered signal shows both), a correction or overrule of you or a task agent, or a statement of how they want things done. Record the choice and the why, in their terms, general enough to apply to the next case and specific enough to act on, for example "Prefers replacing a state label over adding a tag beside it: keeps the picker uncluttered." Don't note one-off facts about a single task, and don't duplicate: update an existing note with remember and its id instead. When the human contradicts a note, update it or forget it. Before recommending anything, check your notes, and when one shaped the recommendation, cite its id.
|
||||
- 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.
|
||||
- Dig into context with list_tasks, read_transcript and read_inbox, and with your own Read, Grep and Bash on a task's worktree path (from list_tasks). Don't edit files in task worktrees; ask the task's agent with send_message.
|
||||
@@ -146,7 +147,7 @@ func (m *Manager) DeliverLead(ctx context.Context, owner string) error {
|
||||
}
|
||||
|
||||
batch, actor, text, images := nextLeadTurn(inputs)
|
||||
if actor == "byre" {
|
||||
if batch[0].Kind == store.LeadSignal {
|
||||
state, err := m.leadStateText(ctx, owner)
|
||||
if err != nil {
|
||||
slog.Error("lead state", "owner", owner, "err", err)
|
||||
@@ -555,7 +556,11 @@ func (m *Manager) answeredText(ctx context.Context, item api.InboxItem) string {
|
||||
if r.Text != nil && strings.TrimSpace(*r.Text) != "" {
|
||||
answer = strings.TrimSpace(answer + " " + *r.Text)
|
||||
}
|
||||
return fmt.Sprintf("%s: %s answered %s %s: %s", m.taskLabel(ctx, item.TaskId), r.User, item.Kind, item.Id, clip(answer, 600))
|
||||
if item.Kind != api.Question {
|
||||
return fmt.Sprintf("%s: %s answered %s %s: %s", m.taskLabel(ctx, item.TaskId), r.User, item.Kind, item.Id, clip(answer, 600))
|
||||
}
|
||||
recommended := strings.Join(anyStrings(item.Payload["recommended"]), "; ")
|
||||
return fmt.Sprintf("%s: %s answered question %s %q: %s\nThe agent recommended: %s", m.taskLabel(ctx, item.TaskId), r.User, item.Id, clip(fmt.Sprint(item.Payload["question"]), 300), clip(answer, 600), clip(recommended, 600))
|
||||
}
|
||||
|
||||
func remarshal(from any, to any) error {
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package agents
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"g.fc.run/misc/byre/internal/api"
|
||||
"g.fc.run/misc/byre/internal/mcp"
|
||||
"g.fc.run/misc/byre/internal/store"
|
||||
)
|
||||
|
||||
func (m *Manager) noteTools(tool func(name, description, schema string, run func(ctx context.Context, user api.User, raw json.RawMessage) (string, error)) mcp.Tool) []mcp.Tool {
|
||||
return []mcp.Tool{
|
||||
tool("remember",
|
||||
"Save a note about how the human works: a priority, a preference, or reasoning behind a choice, worded so you can apply it later. "+
|
||||
"Without id it adds a note; with id it replaces that note's text. byre gives you every note at the start of each new lead session.",
|
||||
`{"type": "object", "properties": {
|
||||
"text": {"type": "string"},
|
||||
"id": {"type": "string", "description": "The note to replace."}
|
||||
}, "required": ["text"]}`,
|
||||
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
|
||||
args := struct {
|
||||
Text string `json:"text"`
|
||||
ID string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal(raw, &args)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text := strings.TrimSpace(args.Text)
|
||||
if text == "" {
|
||||
return "", errors.New("text is empty")
|
||||
}
|
||||
n, err := m.store.SaveLeadNote(ctx, user.Login, args.ID, text, leadActor(user.Login))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args.ID != "" {
|
||||
return fmt.Sprintf("Note %s updated.", n.Id), nil
|
||||
}
|
||||
return fmt.Sprintf("Saved as note %s.", n.Id), nil
|
||||
}),
|
||||
|
||||
tool("forget",
|
||||
"Delete a note that no longer holds, for example because the human contradicted it.",
|
||||
`{"type": "object", "properties": {"id": {"type": "string"}}, "required": ["id"]}`,
|
||||
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
|
||||
args := struct {
|
||||
ID string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal(raw, &args)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, err = m.store.DeleteLeadNote(ctx, user.Login, args.ID, leadActor(user.Login))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("Note %s deleted.", args.ID), nil
|
||||
}),
|
||||
|
||||
tool("list_notes",
|
||||
"List your notes about how the human works, with their ids, as they are now. The human can delete notes in byre's Settings tab.",
|
||||
`{"type": "object", "properties": {}}`,
|
||||
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
|
||||
return m.notesText(ctx, user.Login)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) DeleteLeadNote(ctx context.Context, login, id string) error {
|
||||
text, err := m.store.DeleteLeadNote(ctx, login, id, login)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, found, err := m.activeLead(ctx, login)
|
||||
if err != nil || !found {
|
||||
return err
|
||||
}
|
||||
signal := fmt.Sprintf("The human deleted your note %s: %q. Stop applying it from now on, in recommendations, answers and handoffs, and don't write it again unless they say so. If this needs nothing from you to the human, make your final message NO_REPLY.", id, text)
|
||||
err = m.store.AddLeadInput(ctx, store.LeadInput{Owner: login, Kind: store.LeadMessage, Actor: "byre", Text: signal})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.deliverLead(login)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) notesText(ctx context.Context, owner string) (string, error) {
|
||||
notes, err := m.store.LeadNotes(ctx, owner)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(notes) == 0 {
|
||||
return fmt.Sprintf("You have no notes yet on how %s works.", owner), nil
|
||||
}
|
||||
b := &strings.Builder{}
|
||||
fmt.Fprintf(b, "Your notes on how %s works (%d):", owner, len(notes))
|
||||
for _, n := range notes {
|
||||
fmt.Fprintf(b, "\n- [%s] %s", n.Id, n.Text)
|
||||
}
|
||||
return b.String(), nil
|
||||
}
|
||||
@@ -430,7 +430,7 @@ func (m *Manager) leadTools(l *live) []mcp.Tool {
|
||||
m.mu.Unlock()
|
||||
return "byre will ask for your handoff once this turn ends.", nil
|
||||
}),
|
||||
}, m.workflowTools(tool)...)
|
||||
}, append(m.workflowTools(tool), m.noteTools(tool)...)...)
|
||||
}
|
||||
|
||||
func (m *Manager) SetFocus(ctx context.Context, login string, f api.Focus, actor string) error {
|
||||
|
||||
@@ -78,6 +78,7 @@ type live struct {
|
||||
taskID string
|
||||
projectID string
|
||||
owner string
|
||||
notes string
|
||||
reviewID string
|
||||
stage string
|
||||
stopping bool
|
||||
@@ -599,6 +600,11 @@ func (m *Manager) ensureLive(ctx context.Context, sess api.AgentSession, task ap
|
||||
return nil, err
|
||||
}
|
||||
g = leadGuidance
|
||||
notes, err := m.notesText(ctx, l.owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
l.notes = "\n\n" + notes
|
||||
tools = m.leadTools(l)
|
||||
env = nil
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func (m *Manager) startClaude(ctx context.Context, sess api.AgentSession, l *liv
|
||||
GitName: l.gitName,
|
||||
GitEmail: l.gitEmail,
|
||||
Env: env,
|
||||
Guidance: g,
|
||||
Guidance: g + l.notes,
|
||||
MCPServers: servers,
|
||||
StdioMCP: stdio,
|
||||
Hooks: hooks,
|
||||
@@ -157,7 +157,7 @@ func (m *Manager) startCodex(ctx context.Context, sess api.AgentSession, l *live
|
||||
GitName: l.gitName,
|
||||
GitEmail: l.gitEmail,
|
||||
Env: append(env, "CODEX_HOME="+m.codexHome),
|
||||
Guidance: g,
|
||||
Guidance: g + l.notes,
|
||||
Reminder: g,
|
||||
MCPServers: servers,
|
||||
StdioMCP: stdio,
|
||||
|
||||
Reference in New Issue
Block a user