Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

fix(workflow): retry transient Midscene output errors (#34)

Leyanga31668b45ef7
diff --git a/.github/workflows/midscene-omarchy-4.0.3.yml b/.github/workflows/midscene-omarchy-4.0.3.yml
index 9665d04..6b2bd4b 100644
--- a/.github/workflows/midscene-omarchy-4.0.3.yml
+++ b/.github/workflows/midscene-omarchy-4.0.3.yml
@@ -14,6 +14,7 @@ on:
- "tests/e2e/package.json"
- "tests/e2e/package-lock.json"
- "tests/e2e/gtk_fixture.py"
+ - "tests/e2e/is-transient-midscene-failure.sh"
- "tests/e2e/capture-report-preview.mjs"
- "tests/e2e/cases/**"
- "tests/e2e/midscene.config.ts"
@@ -38,6 +39,7 @@ on:
- "tests/e2e/package.json"
- "tests/e2e/package-lock.json"
- "tests/e2e/gtk_fixture.py"
+ - "tests/e2e/is-transient-midscene-failure.sh"
- "tests/e2e/capture-report-preview.mjs"
- "tests/e2e/cases/**"
- "tests/e2e/midscene.config.ts"
diff --git a/.github/workflows/midscene-ubuntu-22.04.yml b/.github/workflows/midscene-ubuntu-22.04.yml
index f334086..78ce80a 100644
--- a/.github/workflows/midscene-ubuntu-22.04.yml
+++ b/.github/workflows/midscene-ubuntu-22.04.yml
@@ -12,6 +12,7 @@ on:
- "tests/e2e/package.json"
- "tests/e2e/package-lock.json"
- "tests/e2e/gtk_fixture.py"
+ - "tests/e2e/is-transient-midscene-failure.sh"
- "tests/e2e/polish_fixture.py"
- "tests/e2e/cases/**"
- "tests/e2e/midscene.config.ts"
@@ -26,6 +27,7 @@ on:
- "tests/e2e/package.json"
- "tests/e2e/package-lock.json"
- "tests/e2e/gtk_fixture.py"
+ - "tests/e2e/is-transient-midscene-failure.sh"
- "tests/e2e/polish_fixture.py"
- "tests/e2e/cases/**"
- "tests/e2e/midscene.config.ts"
@@ -140,18 +142,18 @@ jobs:
break
fi
- if ! grep -Eq 'Connection error|ETIMEDOUT|failed to call AI model service' "$attempt_log"; then
- echo "Ubuntu Midscene failed for a non-network reason; not retrying." >&2
+ if ! ./is-transient-midscene-failure.sh "$attempt_log"; then
+ echo "Ubuntu Midscene failed for a non-transient reason; not retrying." >&2
exit 1
fi
if [[ $test_attempt -lt 3 ]]; then
- echo "Transient model connection failure on attempt ${test_attempt}; retrying in 10 seconds." >&2
+ echo "Transient model or connection failure on attempt ${test_attempt}; retrying in 10 seconds." >&2
sleep 10
fi
done
if [[ $midscene_passed != true ]]; then
- echo "Ubuntu Midscene exhausted three model-connection attempts." >&2
+ echo "Ubuntu Midscene exhausted three transient-failure attempts." >&2
exit 1
fi
@@ -170,19 +172,19 @@ jobs:
break
fi
- if ! grep -Eq 'Connection error|ETIMEDOUT|ECONNRESET|EAI_AGAIN|UND_ERR_CONNECT_TIMEOUT|failed to call AI model service' "$attempt_log"; then
- echo "Ubuntu polishing Midscene failed for a non-network reason; not retrying." >&2
+ if ! ./is-transient-midscene-failure.sh "$attempt_log"; then
+ echo "Ubuntu polishing Midscene failed for a non-transient reason; not retrying." >&2
exit 1
fi
if [[ $test_attempt -lt 4 ]]; then
retry_delay=$((15 * test_attempt))
- echo "Transient model connection failure on polishing attempt ${test_attempt}; retrying in ${retry_delay} seconds." >&2
+ echo "Transient model or connection failure on polishing attempt ${test_attempt}; retrying in ${retry_delay} seconds." >&2
sleep "$retry_delay"
fi
done
if [[ $polishing_passed != true ]]; then
- echo "Ubuntu polishing Midscene exhausted four model-connection attempts." >&2
+ echo "Ubuntu polishing Midscene exhausted four transient-failure attempts." >&2
exit 1
fi
diff --git a/tests/contracts/test_midscene_retry_classifier.py b/tests/contracts/test_midscene_retry_classifier.py
new file mode 100644
index 0000000..ab77aee
--- /dev/null
+++ b/tests/contracts/test_midscene_retry_classifier.py
@@ -0,0 +1,40 @@
+import subprocess
+import tempfile
+import unittest
+from pathlib import Path
+
+
+ROOT = Path(__file__).resolve().parents[2]
+CLASSIFIER = ROOT / "tests/e2e/is-transient-midscene-failure.sh"
+
+
+class MidsceneRetryClassifierTest(unittest.TestCase):
+ def classify(self, content: str) -> subprocess.CompletedProcess[str]:
+ with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as log:
+ log.write(content)
+ log.flush()
+ return subprocess.run(
+ [CLASSIFIER, log.name],
+ check=False,
+ capture_output=True,
+ text=True,
+ )
+
+ def test_retries_network_and_model_protocol_failures(self):
+ for message in (
+ "AggregateError [ETIMEDOUT]",
+ "XML parse error: Invalid parameters for action KeyboardPress",
+ "Failed to parse action-param-json",
+ ):
+ with self.subTest(message=message):
+ self.assertEqual(self.classify(message).returncode, 0)
+
+ def test_does_not_retry_product_assertion_failures(self):
+ result = self.classify(
+ "Assertion failed: the expected endpoint result is not visible"
+ )
+ self.assertEqual(result.returncode, 1)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/e2e/is-transient-midscene-failure.sh b/tests/e2e/is-transient-midscene-failure.sh
new file mode 100755
index 0000000..13f4040
--- /dev/null
+++ b/tests/e2e/is-transient-midscene-failure.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+set -euo pipefail
+
+if (($# != 1)); then
+ echo "Usage: $0 <midscene-log>" >&2
+ exit 2
+fi
+
+grep -Eq \
+ 'Connection error|ETIMEDOUT|ECONNRESET|EAI_AGAIN|UND_ERR_CONNECT_TIMEOUT|failed to call AI model service|XML parse error|Invalid parameters for action|Failed to parse action-param-json|No valid action generated' \
+ "$1"
diff --git a/tests/e2e/run-omarchy-midscene.sh b/tests/e2e/run-omarchy-midscene.sh
index 2027bee..0a90580 100755
--- a/tests/e2e/run-omarchy-midscene.sh
+++ b/tests/e2e/run-omarchy-midscene.sh
@@ -14,7 +14,6 @@ readonly PLUGIN_DIR="/home/omarchy/.config/omarchy/plugins/md.lifeos.doubao-say"
readonly SHIM_DIR="$(mktemp -d)"
readonly PLUGIN_ARCHIVE="$(mktemp /tmp/doubao-say-omarchy-plugin-XXXXXX.tar)"
readonly MODEL_TEST_ATTEMPTS=4
-readonly MODEL_NETWORK_FAILURE_PATTERN='Connection error|ETIMEDOUT|ECONNRESET|EAI_AGAIN|UND_ERR_CONNECT_TIMEOUT|failed to call AI model service'
export NODE_OPTIONS="${NODE_OPTIONS:-} --require=$ROOT_DIR/tests/e2e/node_modules/@computer-use/libnut/dist/import_libnut.js"
VM_PID=""
@@ -191,19 +190,19 @@ for ((_test_attempt = 1; _test_attempt <= MODEL_TEST_ATTEMPTS; _test_attempt++))
break
fi
- if ! grep -Eq "$MODEL_NETWORK_FAILURE_PATTERN" "$ATTEMPT_LOG"; then
- echo "Omarchy Midscene failed for a non-network reason; not retrying." >&2
+ if ! tests/e2e/is-transient-midscene-failure.sh "$ATTEMPT_LOG"; then
+ echo "Omarchy Midscene failed for a non-transient reason; not retrying." >&2
exit 1
fi
if ((_test_attempt < MODEL_TEST_ATTEMPTS)); then
retry_delay=$((15 * _test_attempt))
- echo "Transient model connection failure on attempt $_test_attempt; retrying in $retry_delay seconds." >&2
+ echo "Transient model or connection failure on attempt $_test_attempt; retrying in $retry_delay seconds." >&2
sleep "$retry_delay"
fi
done
if [[ $MIDSCENE_PASSED != true ]]; then
- echo "Omarchy Midscene exhausted $MODEL_TEST_ATTEMPTS model-connection attempts." >&2
+ echo "Omarchy Midscene exhausted $MODEL_TEST_ATTEMPTS transient-failure attempts." >&2
exit 1
fi
@@ -237,18 +236,18 @@ for ((_test_attempt = 1; _test_attempt <= MODEL_TEST_ATTEMPTS; _test_attempt++))
break
fi
- if ! grep -Eq "$MODEL_NETWORK_FAILURE_PATTERN" "$ATTEMPT_LOG"; then
- echo "Omarchy menu visual test failed for a non-network reason; not retrying." >&2
+ if ! tests/e2e/is-transient-midscene-failure.sh "$ATTEMPT_LOG"; then
+ echo "Omarchy menu visual test failed for a non-transient reason; not retrying." >&2
exit 1
fi
if ((_test_attempt < MODEL_TEST_ATTEMPTS)); then
retry_delay=$((15 * _test_attempt))
- echo "Transient model connection failure on menu attempt $_test_attempt; retrying in $retry_delay seconds." >&2
+ echo "Transient model or connection failure on menu attempt $_test_attempt; retrying in $retry_delay seconds." >&2
sleep "$retry_delay"
fi
done
if [[ $MENU_PASSED != true ]]; then
- echo "Omarchy menu visual test exhausted $MODEL_TEST_ATTEMPTS model-connection attempts." >&2
+ echo "Omarchy menu visual test exhausted $MODEL_TEST_ATTEMPTS transient-failure attempts." >&2
exit 1
fi