Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions backend/agents/create_agent_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,6 @@ async def create_agent_config(
}
system_prompt = Template(prompt_template["system_prompt"], undefined=StrictUndefined).render(render_kwargs)

_print_prompt_with_token_count(system_prompt, agent_id, "BEFORE_INJECTION")

if agent_info.get("model_id") is not None:
model_info = get_model_by_model_id(agent_info.get("model_id"))
model_name = model_info["display_name"] if model_info is not None else "main_model"
Expand Down Expand Up @@ -452,25 +450,9 @@ async def prepare_prompt_templates(
prompt_templates = get_agent_prompt_template(is_manager, language)
prompt_templates["system_prompt"] = system_prompt

# Print final prompt with all injections
_print_prompt_with_token_count(prompt_templates["system_prompt"], agent_id, "FINAL_PROMPT")

return prompt_templates


def _print_prompt_with_token_count(prompt: str, agent_id: int = None, stage: str = "PROMPT"):
"""Print prompt content and estimate token count using tiktoken."""
try:
import tiktoken
encoding = tiktoken.get_encoding("cl100k_base")
token_count = len(encoding.encode(prompt))
logger.info(f"[Skill Debug][{stage}] Agent {agent_id} token count: {token_count}")
logger.info(f"[Skill Debug][{stage}] Agent {agent_id} prompt:\n{prompt}")
except Exception as e:
logger.warning(f"[Skill Debug][{stage}] Failed to count tokens: {e}")
logger.info(f"[Skill Debug][{stage}] Agent {agent_id} prompt:\n{prompt}")


async def join_minio_file_description_to_query(minio_files, query):
final_query = query
if minio_files and isinstance(minio_files, list):
Expand Down
2 changes: 0 additions & 2 deletions backend/utils/prompt_template_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def get_prompt_template(template_type: str, language: str = LANGUAGE["ZH"], **kw
Returns:
dict: Loaded prompt template
"""
logger.info(
f"Getting prompt template for type: {template_type}, language: {language}, kwargs: {kwargs}")

# Define template path mapping
template_paths = {
Expand Down
2 changes: 0 additions & 2 deletions sdk/nexent/core/utils/prompt_template_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def get_prompt_template(template_type: str, language: str = LANGUAGE["ZH"], **kw
Returns:
dict: Loaded prompt template
"""
logger.info(
f"Getting prompt template for type: {template_type}, language: {language}, kwargs: {kwargs}")

if template_type not in template_paths:
raise ValueError(f"Unsupported template type: {template_type}")
Expand Down
Loading