Skip to content

feat(harness): add interactive modes and GPU selection - #611

Open
Graffioh wants to merge 1 commit into
Luce-Org:mainfrom
Graffioh:agent/harness-interactive-gpu-controls
Open

feat(harness): add interactive modes and GPU selection#611
Graffioh wants to merge 1 commit into
Luce-Org:mainfrom
Graffioh:agent/harness-interactive-gpu-controls

Conversation

@Graffioh

@Graffioh Graffioh commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add opt-in HARNESS_INTERACTIVE=1 TUI sessions for the existing Claude Code, Codex, OpenCode, Hermes, Pi, and OpenClaw launchers while preserving deterministic one-shot defaults
  • add explicit TARGET_DEVICE / DRAFT_DEVICE placement on top of standard CUDA/HIP visibility controls, including dual-architecture HIP documentation
  • keep interactive client state under .harness-work/interactive/, show startup/client heartbeats, and report GPU status with the backend-appropriate NVIDIA or ROCm tool
  • extend the CPU-only launcher contract to cover every interactive command shape, persistent client home, device forwarding, and invalid-mode rejection

Validation

  • bash -n harness/clients/*.sh harness/tests/test_client_launcher_timeouts.sh
  • bash harness/tests/test_client_launcher_timeouts.sh
  • bash harness/tests/test_run_pi_timeout.sh harness/clients/run_pi.sh
  • python3 -m py_compile harness/client_test_runner.py harness/clients/summarize_backend_pair.py
  • uv run --frozen --extra dev ruff check .
  • CPU-only launcher contract coverage passes, including all interactive command shapes and timeout behavior

HIP live validation

Run on the HIP-only validation host with the available Radeon 8060S (gfx1151) selected via:

  • HIP_VISIBLE_DEVICES=1
  • TARGET_DEVICE=hip:0
  • DRAFT_DEVICE=hip:0

Passed:

  • direct Lucebox HIP server smoke: /health and exact response hip-live-ok
  • full HTTP protocol probe: all 7 profiles passed (claude_code, codex, hermes, openclaw, openwebui, opencode, pi)
  • real Codex CLI 0.147.0 one-shot request
  • real interactive Codex request, returning hip-interactive-codex-ok
  • real Claude Code 2.1.223 one-shot request
  • server logs confirmed successful HIP target/draft execution on gfx1151

Deferred validation

  • Live CUDA-backed validation (the validation host is HIP-only)
  • Live HIP interactive validation for OpenCode, Hermes, Pi, and OpenClaw; those real client packages were not installed on the validation host

The HIP validation is complete for the available server and client paths.

@Graffioh
Graffioh marked this pull request as ready for review August 15, 2026 08:42

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="harness/clients/common.sh">

<violation number="1" location="harness/clients/common.sh:179">
P2: If the OpenClaw config preflight fails or times out, `set -e` exits `run_with_timeout` before the heartbeat cleanup runs, leaving its background loop alive and continuing to emit progress. Install heartbeat cleanup in an unconditional trap or run the wrapped command through an errexit-safe conditional.</violation>

<violation number="2" location="harness/clients/common.sh:395">
P2: When the HIP server uses default or `TARGET_DEVICE=auto:0` placement, `finish_report` invokes `nvidia-smi` because `auto:0` is never resolved to HIP. Resolve `auto` from the actual server backend before selecting the GPU tool, or make startup expose the resolved backend.</violation>

<violation number="3" location="harness/clients/common.sh:404">
P3: The rocm-smi `--device` selection only handles a single-integer HIP_VISIBLE_DEVICES. Comma-separated lists (documented for dual-GPU HIP runs) fail the `^[0-9]+$` regex, so --device is dropped and rocm-smi reports all devices instead of the selected slot. Consider splitting the list on commas and passing the mapped runtime-index list, or drop --device entirely since HIP_VISIBLE_DEVICES already scopes visibility.</violation>
</file>

<file name="harness/clients/run_codex.sh">

<violation number="1" location="harness/clients/run_codex.sh:44">
P2: The interactive Codex branch drops `--skip-git-repo-check`, which the one-shot path explicitly uses, so a `codex --cd <dir>` TUI can fail to open when that directory is not a git repo. Add the flag to the interactive command for parity with the non-interactive launcher.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread harness/clients/common.sh
tail -n 120 "$SERVER_LOG" || true
echo "--- gpu ---"
nvidia-smi --query-gpu=name,memory.used,memory.total,utilization.gpu --format=csv,noheader || true
local resolved_backend="${TARGET_DEVICE%%:*}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When the HIP server uses default or TARGET_DEVICE=auto:0 placement, finish_report invokes nvidia-smi because auto:0 is never resolved to HIP. Resolve auto from the actual server backend before selecting the GPU tool, or make startup expose the resolved backend.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At harness/clients/common.sh, line 395:

<comment>When the HIP server uses default or `TARGET_DEVICE=auto:0` placement, `finish_report` invokes `nvidia-smi` because `auto:0` is never resolved to HIP. Resolve `auto` from the actual server backend before selecting the GPU tool, or make startup expose the resolved backend.</comment>

<file context>
@@ -304,5 +392,24 @@ finish_report() {
   tail -n 120 "$SERVER_LOG" || true
   echo "--- gpu ---"
-  nvidia-smi --query-gpu=name,memory.used,memory.total,utilization.gpu --format=csv,noheader || true
+  local resolved_backend="${TARGET_DEVICE%%:*}"
+  if [[ -z "$TARGET_DEVICE" ]] && grep -Eq 'target_device[[:space:]]*=[[:space:]]*hip:' "$SERVER_LOG"; then
+    resolved_backend="hip"
</file context>

Comment thread harness/clients/common.sh

local started_at heartbeat_pid rc elapsed
started_at="$(date +%s)"
(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: If the OpenClaw config preflight fails or times out, set -e exits run_with_timeout before the heartbeat cleanup runs, leaving its background loop alive and continuing to emit progress. Install heartbeat cleanup in an unconditional trap or run the wrapped command through an errexit-safe conditional.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At harness/clients/common.sh, line 179:

<comment>If the OpenClaw config preflight fails or times out, `set -e` exits `run_with_timeout` before the heartbeat cleanup runs, leaving its background loop alive and continuing to emit progress. Install heartbeat cleanup in an unconditional trap or run the wrapped command through an errexit-safe conditional.</comment>

<file context>
@@ -118,18 +157,53 @@ run_with_timeout() {
+
+  local started_at heartbeat_pid rc elapsed
+  started_at="$(date +%s)"
+  (
+    while sleep 10; do
+      elapsed=$(( $(date +%s) - started_at ))
</file context>

< /dev/null > "$CLIENT_OUT" 2>&1
RC=$?
if [[ "$HARNESS_INTERACTIVE" == "1" ]]; then
codex_cmd=("$CODEX_BIN" --cd "$REPO_DIR" --sandbox "$CODEX_SANDBOX" --model "$MODEL_ID")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The interactive Codex branch drops --skip-git-repo-check, which the one-shot path explicitly uses, so a codex --cd <dir> TUI can fail to open when that directory is not a git repo. Add the flag to the interactive command for parity with the non-interactive launcher.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At harness/clients/run_codex.sh, line 44:

<comment>The interactive Codex branch drops `--skip-git-repo-check`, which the one-shot path explicitly uses, so a `codex --cd <dir>` TUI can fail to open when that directory is not a git repo. Add the flag to the interactive command for parity with the non-interactive launcher.</comment>

<file context>
@@ -38,22 +38,29 @@ start_lucebox_server
-  < /dev/null > "$CLIENT_OUT" 2>&1
-RC=$?
+if [[ "$HARNESS_INTERACTIVE" == "1" ]]; then
+  codex_cmd=("$CODEX_BIN" --cd "$REPO_DIR" --sandbox "$CODEX_SANDBOX" --model "$MODEL_ID")
+  if [[ -n "$INTERACTIVE_PROMPT" ]]; then codex_cmd+=("$INTERACTIVE_PROMPT"); fi
+  run_interactive_client "Codex" "$CLIENT_OUT" env "${codex_env[@]}" "${codex_cmd[@]}"
</file context>
Suggested change
codex_cmd=("$CODEX_BIN" --cd "$REPO_DIR" --sandbox "$CODEX_SANDBOX" --model "$MODEL_ID")
codex_cmd=("$CODEX_BIN" --cd "$REPO_DIR" --skip-git-repo-check --sandbox "$CODEX_SANDBOX" --model "$MODEL_ID")

Comment thread harness/clients/common.sh
if [[ "$resolved_backend" == "hip" ]]; then
if command -v rocm-smi >/dev/null 2>&1; then
local rocm_device_args=()
if [[ "${HIP_VISIBLE_DEVICES:-}" =~ ^[0-9]+$ ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The rocm-smi --device selection only handles a single-integer HIP_VISIBLE_DEVICES. Comma-separated lists (documented for dual-GPU HIP runs) fail the ^[0-9]+$ regex, so --device is dropped and rocm-smi reports all devices instead of the selected slot. Consider splitting the list on commas and passing the mapped runtime-index list, or drop --device entirely since HIP_VISIBLE_DEVICES already scopes visibility.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At harness/clients/common.sh, line 404:

<comment>The rocm-smi `--device` selection only handles a single-integer HIP_VISIBLE_DEVICES. Comma-separated lists (documented for dual-GPU HIP runs) fail the `^[0-9]+$` regex, so --device is dropped and rocm-smi reports all devices instead of the selected slot. Consider splitting the list on commas and passing the mapped runtime-index list, or drop --device entirely since HIP_VISIBLE_DEVICES already scopes visibility.</comment>

<file context>
@@ -304,5 +392,24 @@ finish_report() {
+  if [[ "$resolved_backend" == "hip" ]]; then
+    if command -v rocm-smi >/dev/null 2>&1; then
+      local rocm_device_args=()
+      if [[ "${HIP_VISIBLE_DEVICES:-}" =~ ^[0-9]+$ ]]; then
+        rocm_device_args=(--device "$HIP_VISIBLE_DEVICES")
+      fi
</file context>

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