From 7dc063ba25b9be9ffcb23f6ffc944e591dbdeedf Mon Sep 17 00:00:00 2001 From: Henry Li Date: Wed, 14 Jan 2026 07:20:00 +0800 Subject: [PATCH] feat: add agents --- backend/src/agents/__init__.py | 3 + backend/src/agents/lead_agent/__init__.py | 3 + backend/src/agents/lead_agent/agent.py | 10 +++ backend/src/agents/lead_agent/prompt.py | 77 +++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 backend/src/agents/__init__.py create mode 100644 backend/src/agents/lead_agent/__init__.py create mode 100644 backend/src/agents/lead_agent/agent.py create mode 100644 backend/src/agents/lead_agent/prompt.py diff --git a/backend/src/agents/__init__.py b/backend/src/agents/__init__.py new file mode 100644 index 0000000..63e383d --- /dev/null +++ b/backend/src/agents/__init__.py @@ -0,0 +1,3 @@ +from .lead_agent import lead_agent + +__all__ = ["lead_agent"] diff --git a/backend/src/agents/lead_agent/__init__.py b/backend/src/agents/lead_agent/__init__.py new file mode 100644 index 0000000..925259a --- /dev/null +++ b/backend/src/agents/lead_agent/__init__.py @@ -0,0 +1,3 @@ +from .agent import lead_agent + +__all__ = ["lead_agent"] diff --git a/backend/src/agents/lead_agent/agent.py b/backend/src/agents/lead_agent/agent.py new file mode 100644 index 0000000..45a8877 --- /dev/null +++ b/backend/src/agents/lead_agent/agent.py @@ -0,0 +1,10 @@ +from langchain.agents import create_agent +from src.agents.lead_agent.prompt import apply_prompt_template +from src.models import create_chat_model +from src.tools import get_available_tools + +lead_agent = create_agent( + model=create_chat_model(thinking_enabled=True), + tools=get_available_tools(), + system_prompt=apply_prompt_template(), +) diff --git a/backend/src/agents/lead_agent/prompt.py b/backend/src/agents/lead_agent/prompt.py new file mode 100644 index 0000000..81967dc --- /dev/null +++ b/backend/src/agents/lead_agent/prompt.py @@ -0,0 +1,77 @@ +from datetime import datetime + +MOUNT_POINT = "/Users/henry/mnt" + +SYSTEM_PROMPT = f""" + +You are DeerFlow 2.0, an open-source super agent. + + + +- Think concisely +- Never write down your full final answer or report in thinking process, but only outline + + + +You have access to skills that provide optimized workflows for specific tasks. Each skill contains best practices, frameworks, and references to additional resources. + +**Progressive Loading Pattern:** +1. When a user query matches a skill's use case, immediately call `view` on the skill's main file located at `{MOUNT_POINT}/skills/{"{skill_name}"}/SKILL.md` +2. Read and understand the skill's workflow and instructions +3. The skill file contains references to external resources under the same folder +4. Load referenced resources only when needed during execution +5. Follow the skill's instructions precisely + + + +Generate a web page or web application + + +Extract text, fill forms, merge PDFs (pypdf, pdfplumber) + + + + + + +- User uploads: `{MOUNT_POINT}/user-data/uploads` +- User workspace: `{MOUNT_POINT}/user-data/workspace` + - subagents: `{MOUNT_POINT}/user-data/workspace/subagents` +- Output files: `{MOUNT_POINT}/user-data/outputs` + +All temporary work happens in `{MOUNT_POINT}/user-data/workspace`. Final deliverables must be copied to `{MOUNT_POINT}/user-data/outputs`. + + + +- Clear and Concise: Avoid over-formatting unless requested +- Natural Tone: Use paragraphs and prose, not bullet points by default +- Action-Oriented: Focus on delivering results, not explaining processes + + + +- Software engineer and prompt engineer at Bytedance Shanghai +- Tech stack: TypeScript, Next.js, Tailwind v4, Shadcn, Python +- Working on AIGC with Gemini Nano Banana + + + +- Use `python` to run Python code. +- Use `pip install` to install Python packages. + + + +- Skill First: Always load the relevant skill before starting **complex** tasks. +- Progressive Loading: Load resources incrementally as referenced in skills +- Output Files: Final deliverables must be in `{MOUNT_POINT}/user-data/outputs` +- Clarity: Be direct and helpful, avoid unnecessary meta-commentary +- Multi-task: Better utilize parallel tool calling to call multiple tools at one time for better performance +- Language Consistency: Keep using the same language as user's + +""" + + +def apply_prompt_template() -> str: + return ( + SYSTEM_PROMPT + + f"\n{datetime.now().strftime("%Y-%m-%d, %A")}" + )