Scope lead notes by project and share them with task agents
This commit is contained in:
@@ -26,7 +26,7 @@ const leadGuidance = `You are the human's lead agent in byre, shown in the left
|
||||
- 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. It is always refused for 10 seconds after the human moves the pane themselves, since they just picked what to look at. 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, and "The move hold is over" means 10 seconds passed since the human's last move: show what you held back, if it still matters and the pane's other rules allow it, 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, 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.
|
||||
- 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." File each note under the project it is about with project_id when it concerns that project's code, UI, docs or process, and with no project_id only when it holds for how the human works everywhere; apply a project's notes only to that project's tasks. Task agents start with their creator's every-project notes and their project's, and suggest new ones with suggest_note, which reaches you as a signal: save a suggestion only when it holds and your notes don't already cover it, choosing its project yourself, and otherwise drop it; neither needs a word to the human. 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, and read_transcript shows each review's findings. 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.
|
||||
|
||||
@@ -16,15 +16,18 @@ func (m *Manager) noteTools(tool func(name, description, schema string, run func
|
||||
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.",
|
||||
"Give project_id when the note is about one project (its code, UI, docs or process); omit it when it holds for the human in every project. "+
|
||||
"Without id it adds a note; with id it replaces that note's text and project. byre gives you every note at the start of each new lead session.",
|
||||
`{"type": "object", "properties": {
|
||||
"text": {"type": "string"},
|
||||
"project_id": {"type": "string", "description": "The project the note applies to; omit for every project."},
|
||||
"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"`
|
||||
Text string `json:"text"`
|
||||
ProjectID string `json:"project_id"`
|
||||
ID string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal(raw, &args)
|
||||
if err != nil {
|
||||
@@ -34,7 +37,13 @@ func (m *Manager) noteTools(tool func(name, description, schema string, run func
|
||||
if text == "" {
|
||||
return "", errors.New("text is empty")
|
||||
}
|
||||
n, err := m.store.SaveLeadNote(ctx, user.Login, args.ID, text, leadActor(user.Login))
|
||||
if args.ProjectID != "" {
|
||||
_, err = m.store.GetProject(ctx, args.ProjectID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
n, err := m.store.SaveLeadNote(ctx, user.Login, args.ID, args.ProjectID, text, leadActor(user.Login))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -66,11 +75,63 @@ func (m *Manager) noteTools(tool func(name, description, schema string, run func
|
||||
"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)
|
||||
return m.notesText(ctx, user.Login, "")
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
const taskNotesGuidance = "The human's lead agent keeps the notes below on how the human works, in every project and in this one. Follow them in this task. " +
|
||||
"When the human shows you a preference, a priority or the reasoning behind a choice that will recur, such as a correction or an overrule, suggest a note with suggest_note; the lead decides whether to keep it."
|
||||
|
||||
func (m *Manager) suggestNoteTool(l *live) mcp.Tool {
|
||||
return mcp.Tool{
|
||||
Name: "suggest_note",
|
||||
Description: "Suggest a note to the human's lead agent about how the human works: the choice and the why, in their terms, general enough to apply to the next case. " +
|
||||
"The lead decides whether to save it, and for this project or every project. Don't suggest one-off facts about this task or what the notes already say.",
|
||||
InputSchema: json.RawMessage(`{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"text": {"type": "string", "description": "The note, as you would want it worded."},
|
||||
"evidence": {"type": "string", "description": "What the human said or did that shows it."}
|
||||
},
|
||||
"required": ["text", "evidence"]
|
||||
}`),
|
||||
Handler: func(ctx context.Context, raw json.RawMessage) (string, error) {
|
||||
args := struct {
|
||||
Text string `json:"text"`
|
||||
Evidence string `json:"evidence"`
|
||||
}{}
|
||||
err := json.Unmarshal(raw, &args)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("malformed suggest_note call: %w", err)
|
||||
}
|
||||
text := strings.TrimSpace(args.Text)
|
||||
if text == "" {
|
||||
return "", fmt.Errorf("%w: text must not be empty", ErrInvalid)
|
||||
}
|
||||
task, err := m.store.GetTask(ctx, l.taskID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, found, err := m.activeLead(ctx, task.CreatedBy)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !found {
|
||||
return "", fmt.Errorf("%w: %s has no lead agent to take the suggestion", ErrConflict, task.CreatedBy)
|
||||
}
|
||||
signal := fmt.Sprintf("%s suggests a note on how %s works:\n%s\nEvidence: %s\nSave it with remember if it holds and your notes don't already cover it, under project_id %s or for every project as fits; otherwise drop it.",
|
||||
m.taskLabel(ctx, task.Id), task.CreatedBy, text, strings.TrimSpace(args.Evidence), task.ProjectId)
|
||||
err = m.store.AddLeadInput(ctx, store.LeadInput{Owner: task.CreatedBy, Kind: store.LeadSignal, Actor: "byre", Text: signal})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m.deliverLead(task.CreatedBy)
|
||||
return "Suggestion sent to the lead.", nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) DeleteLeadNote(ctx context.Context, login, id string) error {
|
||||
text, err := m.store.DeleteLeadNote(ctx, login, id, login)
|
||||
if err != nil {
|
||||
@@ -89,18 +150,41 @@ func (m *Manager) DeleteLeadNote(ctx context.Context, login, id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) notesText(ctx context.Context, owner string) (string, error) {
|
||||
func (m *Manager) notesText(ctx context.Context, owner, onlyProject 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
|
||||
projects, err := m.store.ListProjects(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
b := &strings.Builder{}
|
||||
fmt.Fprintf(b, "Your notes on how %s works (%d):", owner, len(notes))
|
||||
writeNotes(b, notes, "", fmt.Sprintf("Notes on how %s works in every project", owner))
|
||||
for _, p := range projects {
|
||||
if onlyProject != "" && p.Id != onlyProject {
|
||||
continue
|
||||
}
|
||||
writeNotes(b, notes, p.Id, fmt.Sprintf("Notes on how %s works in project %s (%s)", owner, p.Name, p.Id))
|
||||
}
|
||||
if b.Len() == 0 {
|
||||
return fmt.Sprintf("There are no notes yet on how %s works.", owner), nil
|
||||
}
|
||||
return strings.TrimPrefix(b.String(), "\n\n"), nil
|
||||
}
|
||||
|
||||
func writeNotes(b *strings.Builder, notes []api.LeadNote, projectID, heading string) {
|
||||
scoped := []api.LeadNote{}
|
||||
for _, n := range notes {
|
||||
if deref(n.ProjectId) == projectID {
|
||||
scoped = append(scoped, n)
|
||||
}
|
||||
}
|
||||
if len(scoped) == 0 {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(b, "\n\n%s (%d):", heading, len(scoped))
|
||||
for _, n := range scoped {
|
||||
fmt.Fprintf(b, "\n- [%s] %s", n.Id, n.Text)
|
||||
}
|
||||
return b.String(), nil
|
||||
}
|
||||
|
||||
@@ -685,6 +685,12 @@ func (m *Manager) startLive(ctx context.Context, sess api.AgentSession, task api
|
||||
tools := append([]mcp.Tool{m.askTool(l), m.cancelQuestionTool(l), m.setMergeTitleTool(l), m.stopMergeTool(l), m.setTaskSummaryTool(l), m.searchClosedTool(l), m.exposePortTool(l)}, m.subtaskTools(l)...)
|
||||
if sess.Role == api.Implementer {
|
||||
g += longTitleGuidance(task)
|
||||
notes, err := m.notesText(ctx, task.CreatedBy, task.ProjectId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
l.notes = "\n\n" + taskNotesGuidance + "\n\n" + notes
|
||||
tools = append(tools, m.suggestNoteTool(l))
|
||||
}
|
||||
if sess.Role == api.Implementer && task.WorkflowStage != nil {
|
||||
frozen, err := m.store.TaskWorkflow(ctx, task.Id)
|
||||
@@ -716,7 +722,7 @@ func (m *Manager) startLive(ctx context.Context, sess api.AgentSession, task api
|
||||
return nil, err
|
||||
}
|
||||
g = leadGuidance
|
||||
notes, err := m.notesText(ctx, l.owner)
|
||||
notes, err := m.notesText(ctx, l.owner, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user