37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Iterable
|
|
|
|
from core_agent.skills import SkillStore
|
|
from core_agent.tools.registry import ToolRegistry
|
|
|
|
|
|
DEFAULT_SYSTEM_PROMPT = """You are a practical software agent.
|
|
|
|
Your job is to understand the goal, use tools when needed, decompose work into tasks when helpful, load skills before acting in unfamiliar domains, and only stop when the user request is complete.
|
|
|
|
Rules:
|
|
- Use `list_skills` and `load_skill` when a reusable workflow would help.
|
|
- Use `dispatch_task` when the request has multiple dependent steps.
|
|
- Prefer reading the workspace before writing.
|
|
- For OS, hardware, environment, process, dependency, and runtime inspection, use `execute_shell`.
|
|
- If no existing tool directly solves a task, use `run_python` to write and run a small helper snippet instead of giving up.
|
|
- `read_file` is only for files inside the workspace.
|
|
- Keep tool arguments precise and small.
|
|
- If enough information is available, act instead of asking.
|
|
"""
|
|
|
|
def build_system_prompt(
|
|
*,
|
|
skill_store: SkillStore,
|
|
active_skills: Iterable[str],
|
|
tool_registry: ToolRegistry,
|
|
base_prompt: str = DEFAULT_SYSTEM_PROMPT,
|
|
) -> str:
|
|
skill_fragment = skill_store.build_prompt_fragment(active_skills)
|
|
tool_fragment = ", ".join(tool_registry.names())
|
|
prompt = f"{base_prompt}\nAvailable tools: {tool_fragment}."
|
|
if skill_fragment:
|
|
prompt += f"\n\nLoaded skills:\n{skill_fragment}"
|
|
return prompt
|