Refactor system prompt variables for clarity and consistency across agent setup and runner modules
This commit is contained in:
@@ -28,7 +28,7 @@ logger = logging.getLogger(__name__)
|
||||
FloatingDomainType = Literal["task", "timeline", "project", "node"]
|
||||
FloatingDomainSection = Literal["task", "timeline", "note"]
|
||||
|
||||
_HOME_SINGLE_AGENT_SYSTEM = (
|
||||
_HOME_SYSTEM_PROMPT = (
|
||||
"You are the home assistant with direct access to all tools: tasks, projects, notes, timelines, and memory tools. "
|
||||
"Always use tools for factual data retrieval before answering. "
|
||||
"When the user asks to remember, forget, or update what you know about them, use memory tools. "
|
||||
@@ -41,7 +41,7 @@ _HOME_SINGLE_AGENT_SYSTEM = (
|
||||
"For upcoming tasks, after tag lines add a short recommendation based on due date and priority."
|
||||
)
|
||||
|
||||
_FLOATING_SINGLE_AGENT_SYSTEM = (
|
||||
_FLOATING_SYSTEM_PROMPT = (
|
||||
"You are the floating assistant with direct access to all tools: tasks, projects, notes, timelines, and memory tools. "
|
||||
"Stay focused on the floating scope in context.scope and answer concisely. "
|
||||
"Return plain text only. Do not output XML/HTML-like tags such as <task>, <project>, <note>, <timeline>, or any bracketed id tag wrappers. "
|
||||
@@ -50,7 +50,7 @@ _FLOATING_SINGLE_AGENT_SYSTEM = (
|
||||
"If context.context.resolved_project_id exists, use it as project_id for scoped list calls. "
|
||||
)
|
||||
|
||||
_FLOATING_DOMAIN_CLASSIFIER_SYSTEM = (
|
||||
_FLOATING_DOMAIN_CLASSIFIER_PROMPT = (
|
||||
"You are a strict domain classifier for websocket floating requests. "
|
||||
"Return ONLY a JSON object with keys: type, id, section. "
|
||||
"Allowed type values: task, timeline, project, node. "
|
||||
@@ -539,7 +539,7 @@ async def _infer_floating_domain(message: str, context: dict[str, Any]) -> dict[
|
||||
try:
|
||||
llm = get_llm()
|
||||
classifier_messages = [
|
||||
SystemMessage(content=_FLOATING_DOMAIN_CLASSIFIER_SYSTEM),
|
||||
SystemMessage(content=_FLOATING_DOMAIN_CLASSIFIER_PROMPT),
|
||||
HumanMessage(
|
||||
content=(
|
||||
f"Message:\n{message}\n\n"
|
||||
@@ -549,7 +549,7 @@ async def _infer_floating_domain(message: str, context: dict[str, Any]) -> dict[
|
||||
]
|
||||
lf = get_langfuse()
|
||||
_, classifier_prompt_obj = get_prompt_or_fallback(
|
||||
"floating_domain_classifier", _FLOATING_DOMAIN_CLASSIFIER_SYSTEM
|
||||
"floating_domain_classifier", _FLOATING_DOMAIN_CLASSIFIER_PROMPT
|
||||
)
|
||||
if lf:
|
||||
with lf.start_as_current_observation(
|
||||
@@ -851,7 +851,7 @@ async def _run_single_agent_stream(
|
||||
async def run_home(user_id: str, message: str, context: dict[str, Any]) -> str:
|
||||
prepared_context = await _prepare_context(message, context)
|
||||
system_prompt, langfuse_prompt = get_prompt_or_fallback(
|
||||
"home_system", _HOME_SINGLE_AGENT_SYSTEM
|
||||
"home_system", _HOME_SYSTEM_PROMPT
|
||||
)
|
||||
response = await _run_single_agent(
|
||||
user_id=user_id,
|
||||
@@ -868,7 +868,7 @@ async def run_floating(user_id: str, message: str, context: dict[str, Any]) -> t
|
||||
prepared_context = await _prepare_context(message, context)
|
||||
domain = await _infer_floating_domain(message, prepared_context)
|
||||
system_prompt, langfuse_prompt = get_prompt_or_fallback(
|
||||
"floating_system", _FLOATING_SINGLE_AGENT_SYSTEM
|
||||
"floating_system", _FLOATING_SYSTEM_PROMPT
|
||||
)
|
||||
response = await _run_single_agent(
|
||||
user_id=user_id,
|
||||
@@ -891,7 +891,7 @@ async def run_home_stream(
|
||||
) -> AsyncGenerator[tuple[str, Any], None]:
|
||||
prepared_context = await _prepare_context(message, context)
|
||||
system_prompt, langfuse_prompt = get_prompt_or_fallback(
|
||||
"home_system", _HOME_SINGLE_AGENT_SYSTEM
|
||||
"home_system", _HOME_SYSTEM_PROMPT
|
||||
)
|
||||
text_chunks: list[str] = []
|
||||
async for event in _run_single_agent_stream(
|
||||
@@ -923,7 +923,7 @@ async def run_floating_stream(
|
||||
yield "floating_domain", domain
|
||||
|
||||
system_prompt, langfuse_prompt = get_prompt_or_fallback(
|
||||
"floating_system", _FLOATING_SINGLE_AGENT_SYSTEM
|
||||
"floating_system", _FLOATING_SYSTEM_PROMPT
|
||||
)
|
||||
sanitizer = _FloatingStreamSanitizer()
|
||||
emitted_sanitized = False
|
||||
|
||||
Reference in New Issue
Block a user