Skip to content

refactor: extract shared prompt sections into reusable _partials + add system issue reporting#289

Open
GindaChen wants to merge 4 commits intomainfrom
refactor-prompts
Open

refactor: extract shared prompt sections into reusable _partials + add system issue reporting#289
GindaChen wants to merge 4 commits intomainfrom
refactor-prompts

Conversation

@GindaChen
Copy link
Copy Markdown
Collaborator

Summary

Refactors duplicated sections across prompt SKILL.md files into reusable partials and adds a new system issue reporting feature.

Changes

Partials Infrastructure (manager.py)

  • Added _load_partials() method that reads _partials/*.md files and stores their content
  • Updated render() to auto-inject partials as partial_<name> variables before processing caller variables
  • Skips _-prefixed directories when scanning for skills

6 Partial Files (_partials/)

Partial Extracted From
goal_and_project_root.md planning, iteration, idea
experiment_tracking.md planning, iteration, agent, plan
environment_setup.md planning, iteration, agent, plan
learn_from_history.md planning, iteration
rules.md planning, iteration, idea
system_issue_reporting.md NEW — all prompts

System Issue Reporting (new feature)

  • Agent writes structured bug reports to .wild/issues/ when it suspects a research-agent system bug
  • Attempts gh issue create --repo hao-ai-lab/research-agent if gh CLI is available
  • Only reports issues the agent is confident are system bugs, not user errors

Refactored 5 SKILL.md files to use {{partial_*}} variables:

  • wild_v2_planning, wild_v2_iteration, wild_v2_idea
  • ra_mode_agent, ra_mode_plan

Impact

  • 244 additions, 312 deletions = 68 fewer lines overall
  • Adding a new shared section now requires editing one file instead of five
  • All 40 existing tests pass; smoke tests verify partials render correctly

…-process launch

- Create server/sidecar/ package with 5 focused modules:
  - tmux_manager.py: pane lifecycle
  - server_api.py: HTTP callbacks
  - alerts.py: rule-based + LLM alert detection
  - metrics.py: WandB reading/posting
  - gpu.py: GPU detection/retry
- Rewrite agent/sidecar_agent.py as the real orchestrator (monitor_job lives here)
- Reduce tools/job_sidecar.py to ~80-line CLI shim (deprecated)
- launch_run_in_tmux() now spawns monitor_job() in-process via daemon thread
- Add optional job_pane parameter — no subprocess, no pane split needed
- Deprecate --run-sidecar flag (kept for frozen binary backward compat)
- Add 37 unit tests covering all modules (tests/test_sidecar.py)
- skill_manager_test.py: import from skills.manager (moved from server.py)
- test_parse_opencode_event.py: import from chat.streaming (moved from server.py)
- test_sidecar_integration.py: end-to-end test exercising monitor_job()
  with real tmux panes and a fake callback server. Tests success, failure,
  and running status reporting. Auto-skips in CI where tmux is unavailable.
- Add partials infrastructure to PromptSkillManager: _load_partials()
  reads _partials/*.md and injects them as partial_<name> variables
- Create 6 partial files:
  - goal_and_project_root.md (Goal + Project Root header)
  - experiment_tracking.md (CRITICAL experiment tracking block)
  - environment_setup.md (Python env detection + setup)
  - learn_from_history.md (shell history inspection)
  - rules.md (autonomy + auto-commit rules)
  - system_issue_reporting.md (NEW: bug reporting via local file + gh CLI)
- Refactor 5 SKILL.md files to use {{partial_*}} variables:
  - wild_v2_planning, wild_v2_iteration, wild_v2_idea
  - ra_mode_agent, ra_mode_plan
- System issue reporting: agent saves .wild/issues/*.md and attempts
  gh issue create --repo hao-ai-lab/research-agent when gh is available
@GindaChen
Copy link
Copy Markdown
Collaborator Author

Execution Flow

User Request: Refactor prompts to abstract similar headers + add system issue reporting for research-agent bugs.

Approach:

  1. Analyzed all 13 SKILL.md files — identified 5 duplicated sections across planning/iteration/idea/agent/plan prompts
  2. Extended PromptSkillManager.render() to auto-inject partials from _partials/*.md as {{partial_*}} template variables
  3. Created 6 partials (5 extracted + 1 new system_issue_reporting.md)
  4. Rewrote 5 SKILL.md files to reference partials instead of duplicating content
  5. Verified: 40 existing tests pass + smoke tests confirm partial rendering works correctly

Key design decision: Partials are injected before caller variables, so {{workdir}} and {{server_url}} inside partials get resolved by the same variable pass that handles the rest of the template. No Jinja2 dependency needed.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 21, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant