Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 14 additions & 4 deletions claude-agent/job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,14 @@ def build_fix_prompt() -> str:
return "\n".join(parts)


async def execute_task() -> dict:
"""Execute the task using Claude Agent SDK."""
async def execute_task(working_dir: str | None = None) -> dict:
"""Execute the task using Claude Agent SDK.

Args:
working_dir: Directory where Claude should work. If provided (repo was cloned),
Claude works in the repo. Otherwise uses WORKSPACE.

"""
prompt = build_prompt()
print(f"[job_runner] Mode: {MODE}")
print(f"[job_runner] Model: {CLAUDE_MODEL}")
Expand All @@ -392,10 +398,14 @@ async def execute_task() -> dict:
perm_mode = "plan" if MODE == "plan" else "bypassPermissions"
print(f"[job_runner] Permission mode: {perm_mode}")

# Use the cloned repo directory if available, otherwise use WORKSPACE
cwd = working_dir or WORKSPACE
print(f"[job_runner] Claude working directory: {cwd}")

options = ClaudeAgentOptions(
model=CLAUDE_MODEL,
permission_mode=perm_mode,
cwd=WORKSPACE,
cwd=cwd,
)

collected_text: list[str] = []
Expand Down Expand Up @@ -706,7 +716,7 @@ async def main():
print(f"[job_runner] Working in repo: {repo_dir}")

try:
result = await execute_task()
result = await execute_task(working_dir=repo_dir)
await send_result(
status="completed",
result=result,
Expand Down
11 changes: 11 additions & 0 deletions devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ dev:
- '*.pyc'
- .venv/
disableDownload: true
onUpload:
exec:
- name: rebuild-agent-image
command: |-
echo "[agent] Rebuilding image for Jobs..."
docker build -t mainloop-agent-controller:dev claude-agent/ && \
kind load docker-image mainloop-agent-controller:dev --name mainloop-test && \
echo "[agent] Done - new Jobs will use updated code"
local: true
onChange: ['*.py']
command:
- /entrypoint.sh
logs: {}
Expand All @@ -194,6 +204,7 @@ hooks:
- name: create-secrets
events:
- before:deploy
- before:dev
command: ./scripts/kind/create-secrets.sh

- name: load-images
Expand Down
2 changes: 2 additions & 0 deletions scripts/kind/create-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ kubectl --context="${KIND_CONTEXT}" create secret generic mainloop-secrets \
--namespace mainloop \
--from-literal=claude-secret-token="${CLAUDE_CODE_OAUTH_TOKEN-}" \
--from-literal=github-token="${GITHUB_TOKEN-}" \
--from-literal=db-username=mainloop \
--from-literal=db-password=mainloop \
--dry-run=client -o yaml | kubectl --context="${KIND_CONTEXT}" apply -f -

# Create ghcr-secret (optional - for pulling from GHCR if needed)
Expand Down
Loading