Drop unused thread_id from questions

This commit is contained in:
Ian Gulliver
2026-10-20 20:46:45 -07:00
parent 6ec3cafde5
commit e5a7fc4c1a
7 changed files with 319 additions and 339 deletions
-1
View File
@@ -127,7 +127,6 @@ func (m *Manager) AnswerAgain(ctx context.Context, creator api.User, create api.
ProjectId: t.ProjectId,
TaskId: t.Id,
AgentSessionId: sessionID,
ThreadId: id,
Payload: item.Payload,
CreatedAt: time.Now().UTC(),
}, newResponse(id, creator.Login, create))
+4 -25
View File
@@ -25,7 +25,6 @@ type askArgs struct {
Context string `json:"context"`
Question string `json:"question"`
Attachments []api.Attachment `json:"attachments"`
ThreadID string `json:"thread_id"`
}
func (m *Manager) askTool(l *live) mcp.Tool {
@@ -50,8 +49,7 @@ func (m *Manager) askTool(l *live) mcp.Tool {
"An answer of \"Use your judgment for this decision and continue within the existing task instructions.\" lets you settle that one decision yourself; " +
"it never grants an authorization the owner must give explicitly, such as to deploy, push or commit: ask for that on its own. " +
"One call is one decision, answered by picking from its own choices. When you have several decisions, such as a design with several choices, " +
"never bundle them into one call that asks for approval of them all: call this once per decision, each with its own context and choices; they are answered together. " +
"To answer a follow-up question from the human, call this again with the thread_id they gave you.",
"never bundle them into one call that asks for approval of them all: call this once per decision, each with its own context and choices; they are answered together.",
InputSchema: json.RawMessage(`{
"type": "object",
"properties": {
@@ -72,8 +70,7 @@ func (m *Manager) askTool(l *live) mcp.Tool {
"caption": {"type": "string"}
},
"required": ["kind"]
}},
"thread_id": {"type": "string"}
}}
},
"required": ["context", "question"]
}`),
@@ -90,16 +87,12 @@ func (m *Manager) ask(ctx context.Context, l *live, raw json.RawMessage) (string
return "", fmt.Errorf("malformed ask_human call: %w", err)
}
err = m.validateAsk(ctx, l, args)
err = validateAsk(args)
if err != nil {
return "", err
}
id := store.NewID()
thread := args.ThreadID
if thread == "" {
thread = id
}
attachments := args.Attachments
if attachments == nil {
@@ -130,7 +123,6 @@ func (m *Manager) ask(ctx context.Context, l *live, raw json.RawMessage) (string
ProjectId: l.projectID,
TaskId: l.taskID,
AgentSessionId: l.id,
ThreadId: thread,
Payload: store.ToPayload(payload),
State: api.Open,
CreatedAt: time.Now().UTC(),
@@ -247,7 +239,7 @@ func (m *Manager) cancelQuestion(ctx context.Context, l *live, raw json.RawMessa
return fmt.Sprintf("Question %s withdrawn.", item.Id), nil
}
func (m *Manager) validateAsk(ctx context.Context, l *live, args askArgs) error {
func validateAsk(args askArgs) error {
problems := []string{}
if strings.TrimSpace(args.Context) == "" {
@@ -287,18 +279,6 @@ func (m *Manager) validateAsk(ctx context.Context, l *live, args askArgs) error
}
}
if args.ThreadID != "" {
item, err := m.store.GetInboxItem(ctx, args.ThreadID)
switch {
case errors.Is(err, store.ErrNotFound):
problems = append(problems, fmt.Sprintf("thread_id %s does not exist", args.ThreadID))
case err != nil:
return err
case item.AgentSessionId != l.id:
problems = append(problems, fmt.Sprintf("thread_id %s belongs to another session", args.ThreadID))
}
}
if len(problems) > 0 {
return fmt.Errorf("ask_human rejected, nothing was filed. Fix and call again: %s", strings.Join(problems, "; "))
}
@@ -551,7 +531,6 @@ func deliveryMessage(pending []store.Pending) string {
text = *r.Text
}
fmt.Fprintf(b, "%s answered (none of your options): %s\n", who, text)
fmt.Fprintf(b, "If this asks you something back, answer by calling ask_human with thread_id %q.\n", p.Item.ThreadId)
}
if len(r.Images) > 0 {