Files
hunjing/backend/app/application/agent/prompt_composer.py
T
2026-08-21 16:00:13 +08:00

22 lines
708 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""通用 Agent 提示组合。"""
from __future__ import annotations
from app.modules.agent import AgentDefinition
from app.modules.skills import SkillManifest
def compose_system_messages(
base_messages: list[str],
agent: AgentDefinition | None,
skills: list[SkillManifest],
) -> list[str]:
"""按稳定基础提示、Agent 身份、技能说明的顺序组合提示。"""
messages = list(base_messages)
if agent is not None and agent.system_prompt:
messages.append(f"【Agent:{agent.name}】\n{agent.system_prompt}")
for skill in skills:
if skill.prompt:
messages.append(f"【{skill.name}·能力注入】\n{skill.prompt}")
return messages