Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions .github/workflows/openhands-autofix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -145,30 +146,19 @@ 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]
if missing:
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"),
Expand All @@ -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"})
Expand All @@ -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()

Expand All @@ -210,6 +212,7 @@ jobs:
else:
logger.warning("No final response from agent.")


if __name__ == "__main__":
main()
PY
Expand Down