File size: 2,334 Bytes
a60c0af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Helpers for coordinating note tool usage instructions."""

from __future__ import annotations

import json

from models import TodoItem


def build_note_guidance(task: TodoItem) -> str:
    """Generate note tool usage guidance for a specific task."""

    tags_list = ["deep_research", f"task_{task.id}"]
    tags_literal = json.dumps(tags_list, ensure_ascii=False)

    if task.note_id:
        read_payload = json.dumps({"action": "read", "note_id": task.note_id}, ensure_ascii=False)
        update_payload = json.dumps(
            {
                "action": "update",
                "note_id": task.note_id,
                "task_id": task.id,
                "title": f"Task {task.id}: {task.title}",
                "note_type": "task_state",
                "tags": tags_list,
                "content": "Please add the new information from this round to the task overview",
            },
            ensure_ascii=False,
        )

        return (
            "Note collaboration guide:\n"
            f"- Current task note ID: {task.note_id}.\n"
            f"- Before writing the summary, you must call: [TOOL_CALL:note:{read_payload}] to get the latest content.\n"
            f"- After completing analysis, call: [TOOL_CALL:note:{update_payload}] to sync incremental information.\n"
            "- When updating, maintain the original paragraph structure and add new content to the corresponding sections.\n"
            f"- Recommended to keep tags as {tags_literal} so other Agents can quickly locate it.\n"
            "- After successfully syncing to notes, then output the summary for the user.\n"
        )

    create_payload = json.dumps(
        {
            "action": "create",
            "task_id": task.id,
            "title": f"Task {task.id}: {task.title}",
            "note_type": "task_state",
            "tags": tags_list,
            "content": "Please record task overview, sources overview",
        },
        ensure_ascii=False,
    )

    return (
        "Note collaboration guide:\n"
        f"- No note has been created for this task yet, please first call: [TOOL_CALL:note:{create_payload}].\n"
        "- After successful creation, record the returned note_id and reuse it in all subsequent updates.\n"
        "- After syncing notes, then output the summary for the user.\n"
    )