update init agent
This commit is contained in:
parent
d8dc973b95
commit
9162b4258d
@ -109,13 +109,7 @@ async def init_agent(config: AgentConfig):
|
||||
"""
|
||||
|
||||
|
||||
# 从连接池获取 checkpointer
|
||||
checkpointer = None
|
||||
if config.session_id:
|
||||
from .checkpoint_manager import get_checkpointer_manager
|
||||
manager = get_checkpointer_manager()
|
||||
checkpointer = await manager.acquire_for_agent()
|
||||
await prepare_checkpoint_message(config, checkpointer)
|
||||
|
||||
|
||||
# 加载配置
|
||||
final_system_prompt = await load_system_prompt_async(
|
||||
@ -152,6 +146,7 @@ async def init_agent(config: AgentConfig):
|
||||
# 创建新的 agent(不再缓存)
|
||||
logger.info(f"Creating new agent for session: {getattr(config, 'session_id', 'no-session')}")
|
||||
|
||||
checkpointer = None
|
||||
create_start = time.time()
|
||||
if config.robot_type == "deep_agent":
|
||||
# 使用 DeepAgentX 创建 agent
|
||||
@ -181,7 +176,12 @@ async def init_agent(config: AgentConfig):
|
||||
)
|
||||
middleware.append(tool_output_middleware)
|
||||
|
||||
if checkpointer:
|
||||
# 从连接池获取 checkpointer
|
||||
if config.session_id:
|
||||
from .checkpoint_manager import get_checkpointer_manager
|
||||
manager = get_checkpointer_manager()
|
||||
checkpointer = await manager.acquire_for_agent()
|
||||
await prepare_checkpoint_message(config, checkpointer)
|
||||
summarization_middleware = SummarizationMiddleware(
|
||||
model=llm_instance,
|
||||
max_tokens_before_summary=SUMMARIZATION_MAX_TOKENS,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user