MCPcopy
hub / github.com/HKUDS/OpenHarness / build_runtime_system_prompt

Function build_runtime_system_prompt

src/openharness/prompts/context.py:77–166  ·  view source on GitHub ↗

Build the runtime system prompt with project instructions and memory.

(
    settings: Settings,
    *,
    cwd: str | Path,
    latest_user_prompt: str | None = None,
    extra_skill_dirs: Iterable[str | Path] | None = None,
    extra_plugin_roots: Iterable[str | Path] | None = None,
    include_project_memory: bool = True,
)

Source from the content-addressed store, hash-verified

75
76
77def build_runtime_system_prompt(
78 settings: Settings,
79 *,
80 cwd: str | Path,
81 latest_user_prompt: str | None = None,
82 extra_skill_dirs: Iterable[str | Path] | None = None,
83 extra_plugin_roots: Iterable[str | Path] | None = None,
84 include_project_memory: bool = True,
85) -> str:
86 """Build the runtime system prompt with project instructions and memory."""
87 if is_coordinator_mode():
88 sections = [get_coordinator_system_prompt()]
89 else:
90 sections = [build_system_prompt(custom_prompt=settings.system_prompt, cwd=str(cwd))]
91
92 if not is_coordinator_mode() and settings.system_prompt is None:
93 sections[0] = build_system_prompt(cwd=str(cwd))
94
95 if settings.fast_mode:
96 sections.append(
97 "# Session Mode\nFast mode is enabled. Prefer concise replies, minimal tool use, and quicker progress over exhaustive exploration."
98 )
99
100 sections.append(
101 "# Reasoning Settings\n"
102 f"- Effort: {settings.effort}\n"
103 f"- Passes: {settings.passes}\n"
104 "Adjust depth and iteration count to match these settings while still completing the task."
105 )
106
107 skills_section = _build_skills_section(
108 cwd,
109 extra_skill_dirs=extra_skill_dirs,
110 extra_plugin_roots=extra_plugin_roots,
111 settings=settings,
112 )
113 if skills_section and not is_coordinator_mode():
114 sections.append(skills_section)
115
116 if not is_coordinator_mode():
117 sections.append(_build_delegation_section())
118
119 claude_md = load_claude_md_prompt(cwd)
120 if claude_md:
121 sections.append(claude_md)
122
123 local_rules = load_local_rules()
124 if local_rules:
125 sections.append(f"# Local Environment Rules\n\n{local_rules}")
126
127 for title, path in (
128 ("Issue Context", get_project_issue_file(cwd)),
129 ("Pull Request Comments", get_project_pr_comments_file(cwd)),
130 ("Active Repo Context", get_project_active_repo_context_path(cwd)),
131 ):
132 if path.exists():
133 content = path.read_text(encoding="utf-8", errors="replace").strip()
134 if content:

Callers 15

_build_dry_run_previewFunction · 0.90
_context_handlerFunction · 0.90
_session_handlerFunction · 0.90
_effort_handlerFunction · 0.90
_passes_handlerFunction · 0.90
build_runtimeFunction · 0.90
handle_lineFunction · 0.90
submit_follow_upFunction · 0.90
_run_scenarioFunction · 0.90

Calls 12

is_coordinator_modeFunction · 0.90
build_system_promptFunction · 0.90
load_claude_md_promptFunction · 0.90
load_local_rulesFunction · 0.90
get_project_issue_fileFunction · 0.90
load_memory_promptFunction · 0.90
find_relevant_memoriesFunction · 0.90
_build_skills_sectionFunction · 0.85