qa296 commited on
Commit ·
7393848
1
Parent(s): f514fb7
refactor(agent): change consciousness loop from non-blocking to sequential mode
Browse files- backend/agent/engine.py +3 -7
backend/agent/engine.py
CHANGED
|
@@ -49,16 +49,12 @@ class AgentEngine:
|
|
| 49 |
}
|
| 50 |
|
| 51 |
async def run(self):
|
| 52 |
-
"""Main consciousness loop -
|
| 53 |
print("Agent consciousness started...")
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
# 使用 create_task 让每次思考在后台运行
|
| 57 |
while True:
|
| 58 |
-
|
| 59 |
-
asyncio.create_task(self._let_llm_decide())
|
| 60 |
-
# 不等待,直接继续下一轮
|
| 61 |
-
await asyncio.sleep(0.1) # 短暂停顿让出事件循环
|
| 62 |
|
| 63 |
async def _let_llm_decide(self):
|
| 64 |
"""Let LLM decide next action"""
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
async def run(self):
|
| 52 |
+
"""Main consciousness loop - sequential mode"""
|
| 53 |
print("Agent consciousness started...")
|
| 54 |
|
| 55 |
+
# 等待每个思考完成后再启动下一个,避免并发堆积
|
|
|
|
| 56 |
while True:
|
| 57 |
+
await self._let_llm_decide()
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
async def _let_llm_decide(self):
|
| 60 |
"""Let LLM decide next action"""
|