diff --git a/.github/workflows/openhands-autofix-ci.yml b/.github/workflows/openhands-autofix-ci.yml index 5f96ccf..8404b38 100644 --- a/.github/workflows/openhands-autofix-ci.yml +++ b/.github/workflows/openhands-autofix-ci.yml @@ -126,6 +126,7 @@ jobs: logger = get_logger(__name__) + def _load_repo_skills(repo_root: Path) -> list: """Load repo skills from .openhands/skills and legacy .openhands/microagents.""" skills: list = [] @@ -145,23 +146,6 @@ jobs: logger.error(f"Missing required env vars: {missing}") sys.exit(1) - prompt = f""" - You are fixing CI failures on PR #{os.getenv("PR_NUMBER")} in {os.getenv("REPO_NAME")}. - The PR title is: {os.getenv("PR_TITLE", "(no title)")}. - - Goals: - 1) Reproduce the failing checks locally (run the same tests/build the CI runs). - 2) Fix the failures. Prioritize dependency bumps and test fixes. - 3) Commit changes to the current branch (already checked out) and push if needed. - 4) Leave a concise summary of what you changed. - - Notes: - - Branch checked out: {os.getenv("PR_HEAD_BRANCH")} - - Base branch: {os.getenv("PR_BASE_BRANCH")} - - If tests already pass locally, state that and exit. - - Do not force-push; use the existing branch and push normally. - """ - llm_model = os.getenv("LLM_MODEL") llm_base_url = os.getenv("LLM_BASE_URL") missing = [name for name, val in {"LLM_MODEL": llm_model, "LLM_BASE_URL": llm_base_url}.items() if not val] @@ -169,6 +153,12 @@ jobs: logger.error(f"Missing required env vars: {missing}") sys.exit(1) + repo_root = Path.cwd() + skills = _load_repo_skills(repo_root) + if skills: + logger.info(f"Loaded {len(skills)} repo skills for context") + agent_context = AgentContext(skills=skills) if skills else None + llm = LLM( model=llm_model, api_key=os.getenv("LLM_API_KEY"), @@ -177,12 +167,6 @@ jobs: drop_params=True, ) - repo_root = Path.cwd() - skills = _load_repo_skills(repo_root) - if skills: - logger.info(f"Loaded {len(skills)} repo skills for context") - agent_context = AgentContext(skills=skills) if skills else None - tools = get_default_tools(enable_browser=False) condenser = get_default_condenser( llm.model_copy(update={"usage_id": "condenser"}) @@ -199,6 +183,24 @@ jobs: agent = Agent(**agent_kwargs) convo = Conversation(agent=agent, workspace=os.getcwd()) + + prompt = f""" +You are fixing CI failures on PR #{os.getenv('PR_NUMBER')} in {os.getenv('REPO_NAME')}. +The PR title is: {os.getenv('PR_TITLE', '(no title)')}. + +Goals: +1) Reproduce the failing checks locally (run the same tests/build the CI runs). +2) Fix the failures. Prioritize dependency bumps and test fixes. +3) Commit changes to the current branch (already checked out) and push if needed. +4) Leave a concise summary of what you changed. + +Notes: +- Branch checked out: {os.getenv('PR_HEAD_BRANCH')} +- Base branch: {os.getenv('PR_BASE_BRANCH')} +- If tests already pass locally, state that and exit. +- Do not force-push; use the existing branch and push normally. +""" + convo.send_message(prompt.strip()) convo.run() @@ -210,6 +212,7 @@ jobs: else: logger.warning("No final response from agent.") + if __name__ == "__main__": main() PY