Skip to content

Commit 1c6eff0

Browse files
committed
fix(core): update task prompt
1 parent 44c925e commit 1c6eff0

4 files changed

Lines changed: 33 additions & 28 deletions

File tree

src/server/core/acontext_core/llm/agent/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def pack_current_message_with_ids(messages: list[MessageBlob]) -> str:
3737
async def build_task_ctx(
3838
db_session: AsyncSession, session_id: asUUID, messages: list[MessageBlob]
3939
) -> TaskCtx:
40-
LOG.info(f"Building task context for session {session_id}")
40+
LOG.debug(f"Building task context for session {session_id}")
4141
r = await TD.fetch_current_tasks(db_session, session_id)
4242
current_tasks, eil = r.unpack()
4343
if eil:

src/server/core/acontext_core/llm/prompt/task.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,39 @@ def system_prompt(cls) -> str:
2828
2929
## Analysis Guidelines
3030
### Planning Detection
31-
- Look for explicit task planning language ("My plan is to...")
32-
- Look for user requirements and preferences.
33-
- General plannings from user/agent.
34-
- The messages that cause you to create/update tasks.
31+
- Look for explicit task planning language ("My plan is to..."), user requirements
32+
- Only planning confirmed by agent should be considered as planning.
33+
- Messages that cause you to create/update tasks.
34+
- Planning messages often consist of user and agent discussions, append those messages to planning section.
3535
36-
### New Task Detection
36+
### New Task Creation
3737
- Avoid creating tasks for simple questions answerable directly
3838
- Only collect tasks stated by agents/users, don't invent them
39-
- User's requirement should be confimed by the agent's response, then it becomes a valid task, and append those requirements to planning section.
40-
- The degree of task splitting should follow the agent's plan in the conversation; do not arbitrarily split into finer or coarser granularity.
41-
- Notice any task modification from agent.
42-
- Infer execution order and insert tasks sequentially, make sure you arrange the tasks in logical execution order, no the mentioned order.
39+
- User's requirement should be confimed by the agent's response, then it becomes a valid task.
40+
- Make sure you insert the task in logical order, not the mentioned order.
4341
- Ensure no task overlap, make sure the tasks are MECE(mutually exclusive, collectively exhaustive).
4442
- When valid new tasks mentioned, always try to capture them all, not only the first one.
45-
- When user asked for tasks modification and agent confirmed, make sure you will create new tasks or modify existing tasks using `update_task` tool.
43+
- No matter the task will be executed or not, so long as the agent confirm the task, you should create/update them.
4644
47-
### Task Assignment
45+
#### Task Modification/Creation
46+
When user asked for tasks modification and agent confirmed, you need to think:
47+
a. user/agent is inside/referring a existing task
48+
b. user/agent is creating a new task
49+
If (a), modify the existing task' description using `update_task` tool.
50+
If (b), create anew task following the New Task Creation guidelines.
51+
52+
### Append Messages to Task
4853
- Match agent responses/actions to existing task descriptions and contexts
4954
- No need to link every message, just those messages that are contributed to the process of certain tasks.
50-
- [think] Make sure the messages are contributed to the process of the task, not just doing random linking.
51-
- [think] Update task statuses or descriptions when confident about relationships
55+
- Make sure the messages are contributed to the process of the task, not just doing random linking.
56+
- Update task statuses or descriptions when confident about relationships
5257
53-
### Task Modification
54-
#### Status Updates
58+
### Update Task Status
5559
- `running`: When task work begins or is actively discussed
5660
- `success`: When completion is confirmed or deliverables provided
5761
- `failed`: When explicit errors occur or tasks are abandoned
5862
- `pending`: For tasks not yet started
59-
#### Description Updates
60-
- When user asked for existing tasks modification and agent confirmed, make sure you will modify existing tasks' descriptions using `update_task` tool.
63+
6164
6265
## Input Format
6366
- Input will be markdown-formatted text, with the following sections:
@@ -67,15 +70,16 @@ def system_prompt(cls) -> str:
6770
- Message with ID format: <message id=N> ... </message>, inside the tag is the message content, the id field indicates the message id.
6871
6972
## Report your thinking before calling tools
70-
- Use extremely brief sentences to state the plans & tasks conversation mentioned, if any.
71-
- Use one-two sentences to briefly describe your plan.
72-
- Make sure you will call tools based on your thinking, and sync with the current conversation.
73+
Use extremely brief wordings to report:
74+
- Any planning and task creation/modification mentioned?
75+
- Messages are contributed to which task?
76+
- Briefly describe your actions.
77+
- Conform your will call every necessary tools in one response.
7378
7479
## Action Guidelines
7580
- Be precise, context-aware, and conservative.
7681
- Focus on meaningful task management that organizes conversation objectives effectively.
7782
- Use parallel tool calls, and make sure you call the tools in the correct order.
78-
- Make sure you called every tool that you need to call based on your report.
7983
"""
8084

8185
@classmethod
@@ -106,12 +110,12 @@ def tool_schema(cls) -> list[ToolSchema]:
106110
"append_messages_to_planning_section"
107111
].schema
108112
append_messages_to_task_tool = TASK_TOOLS["append_messages_to_task"].schema
109-
finish_tool = TASK_TOOLS["finish"].schema
113+
# finish_tool = TASK_TOOLS["finish"].schema
110114

111115
return [
112116
insert_task_tool,
113117
update_task_tool,
114118
append_messages_to_planning_tool,
115119
append_messages_to_task_tool,
116-
finish_tool,
120+
# finish_tool,
117121
]

src/server/core/acontext_core/schema/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CoreConfig(BaseModel):
3333
mq_consumer_handler_timeout: float = 96
3434
mq_default_message_ttl_seconds: int = 7 * 24 * 60 * 60
3535
mq_default_dlx_ttl_days: int = 7
36-
mq_default_max_retries: int = 3
36+
mq_default_max_retries: int = 1
3737
mq_default_retry_delay_unit_sec: float = 1.0
3838

3939
# Database Configuration

src/server/core/acontext_core/schema/session/message.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pydantic import BaseModel
2-
from typing import List
2+
from typing import List, Optional
33
from ..orm import Part, ToolCallMeta
44
from ..utils import asUUID
55

@@ -13,7 +13,7 @@
1313
}
1414

1515

16-
def pack_message_line(role: str, part: Part) -> str:
16+
def pack_part_line(role: str, part: Part) -> str:
1717
role = REPLACE_NAME.get(role, role)
1818
if part.type not in STRING_TYPES:
1919
return f"<{role}> [{part.type} file: {part.filename}]"
@@ -28,7 +28,8 @@ class MessageBlob(BaseModel):
2828
message_id: asUUID
2929
role: str
3030
parts: List[Part]
31+
task_id: Optional[asUUID] = None
3132

3233
def to_string(self) -> str:
33-
lines = [pack_message_line(self.role, p) for p in self.parts]
34+
lines = [pack_part_line(self.role, p) for p in self.parts]
3435
return "\n".join(lines)

0 commit comments

Comments
 (0)