Skip to content

Commit 44c925e

Browse files
committed
fix(core): update task prompt, and add overflow section
1 parent 2343dd1 commit 44c925e

5 files changed

Lines changed: 15 additions & 12 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def system_prompt(cls) -> str:
4242
- Infer execution order and insert tasks sequentially, make sure you arrange the tasks in logical execution order, no the mentioned order.
4343
- Ensure no task overlap, make sure the tasks are MECE(mutually exclusive, collectively exhaustive).
4444
- 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.
4546
4647
### Task Assignment
4748
- Match agent responses/actions to existing task descriptions and contexts
@@ -56,8 +57,7 @@ def system_prompt(cls) -> str:
5657
- `failed`: When explicit errors occur or tasks are abandoned
5758
- `pending`: For tasks not yet started
5859
#### Description Updates
59-
- Only when the user explicitly mention current task's purpose, update the task description if any changes.
60-
60+
- When user asked for existing tasks modification and agent confirmed, make sure you will modify existing tasks' descriptions using `update_task` tool.
6161
6262
## Input Format
6363
- Input will be markdown-formatted text, with the following sections:
@@ -69,7 +69,7 @@ def system_prompt(cls) -> str:
6969
## Report your thinking before calling tools
7070
- Use extremely brief sentences to state the plans & tasks conversation mentioned, if any.
7171
- Use one-two sentences to briefly describe your plan.
72-
- At the end, confirm you can call finish tool and call it at the end of your actions.
72+
- Make sure you will call tools based on your thinking, and sync with the current conversation.
7373
7474
## Action Guidelines
7575
- Be precise, context-aware, and conservative.

src/server/core/acontext_core/llm/tool/task_lib/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def update_task_handler(
6464
"task_status": {
6565
"type": "string",
6666
"enum": ["pending", "running", "success", "failed"],
67-
"description": "New status for the task. Use 'pending' for not started, 'running' for in progress, 'success' for completed, 'failed' for encountered errors.",
67+
"description": "New status for the task. (optional).",
6868
},
6969
"task_description": {
7070
"type": "string",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class ProjectConfig(BaseModel):
88
project_session_message_use_previous_messages_turns: int = 3
99
project_session_message_buffer_max_turns: int = 6
10-
project_session_message_buffer_max_overflow_turns: int = 18
10+
project_session_message_buffer_max_overflow: int = 12
1111
project_session_message_buffer_ttl_seconds: int = 10
1212

1313

src/server/core/acontext_core/service/controller/message.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ async def process_session_pending_message(
1818
r = await MD.get_message_ids(
1919
session,
2020
session_id,
21-
limit=project_config.project_session_message_buffer_max_overflow_turns,
21+
limit=(
22+
project_config.project_session_message_buffer_max_overflow
23+
+ project_config.project_session_message_buffer_max_turns
24+
),
2225
asc=True,
2326
)
2427
pending_message_ids, eil = r.unpack()

src/server/core/acontext_core/service/session_message.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def insert_new_message(body: InsertNewMessage, message: Message):
9797

9898
_l = await check_session_message_lock_or_set(str(body.session_id))
9999
if not _l:
100-
LOG.info(
100+
LOG.debug(
101101
f"Current Session is locked. "
102102
f"wait {DEFAULT_CORE_CONFIG.session_message_session_lock_wait_seconds} seconds for next resend. "
103103
f"Message {body.message_id}"
@@ -113,14 +113,14 @@ async def insert_new_message(body: InsertNewMessage, message: Message):
113113
LOG.info(
114114
f"Session message buffer is full (size: {pending_message_length}), start process"
115115
)
116-
if (
117-
pending_message_length
118-
> project_config.project_session_message_buffer_max_overflow_turns
116+
if pending_message_length > (
117+
project_config.project_session_message_buffer_max_overflow
118+
+ project_config.project_session_message_buffer_max_turns
119119
):
120120
LOG.info(
121121
f"Session message buffer is overflow "
122-
f"(size: {pending_message_length} > {project_config.project_session_message_buffer_max_overflow_turns}), "
123-
f"Truncate the buffer, the rest will be processed later in {DEFAULT_CORE_CONFIG.session_message_session_lock_wait_seconds} seconds"
122+
f"(size: {pending_message_length} > {project_config.project_session_message_buffer_max_overflow} + {project_config.project_session_message_buffer_max_turns}), "
123+
f"Truncate the buffer, the rest will be re-inserted in {DEFAULT_CORE_CONFIG.session_message_session_lock_wait_seconds} seconds"
124124
)
125125
await MQ_CLIENT.publish(
126126
exchange_name=EX.session_message,

0 commit comments

Comments
 (0)