calesthio/OpenMontage · error · TimeoutError

TokenHub task {task_id} did not finish within {timeout_secon

Error message

TokenHub task {task_id} did not finish within {timeout_seconds}s

What it means

Raised when a TokenHub video task is still in a non-terminal state (queued/running/in_progress) when the caller-supplied timeout_seconds elapses. Unlike status='failed' (error 252), the job was healthy — just slow — and may still complete on the provider after this tool gives up.

Source

Thrown at tools/video/hunyuan_cloud_video.py:490

                    raise RuntimeError(
                        f"TokenHub task {task_id} completed but no data.url: {data}"
                    )
                return video_url

            if status == "failed":
                error_info = data.get("error") or {}
                error_msg = error_info.get("message", "unknown error")
                raise RuntimeError(
                    f"TokenHub task {task_id} failed: {error_msg}"
                )

            # queued / running / in_progress — continue polling
            if status not in ("queued", "running", "in_progress"):
                raise RuntimeError(
                    f"TokenHub task {task_id} returned unknown status: {status}"
                )

        raise TimeoutError(
            f"TokenHub task {task_id} did not finish within {timeout_seconds}s"
        )

    # ------------------------------------------------------------------
    # Error handling helpers
    # ------------------------------------------------------------------

    @staticmethod
    def _safe_error(exc: Exception) -> str:
        """Redact secret values from exception messages."""
        msg = str(exc)
        for var in ("TENCENT_TOKENHUB_API_KEY",):
            val = os.environ.get(var, "")
            if val:
                msg = msg.replace(val, "[redacted]")
        return msg

    @staticmethod

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Increase timeout_seconds on the tool call to match the expected render time for your duration/resolution.
  2. Reduce requested duration or resolution so the task finishes sooner.
  3. Space out batch submissions to avoid queue saturation.
  4. Retry later — the task may have finished server-side even though this call timed out (beware duplicate billing).

Example fix

# before
{"operation": "text_to_video", "timeout_seconds": 120}

# after
{"operation": "text_to_video", "timeout_seconds": 900}
Defensive patterns

Strategy: retry

Validate before calling

expected_render_secs = 60 + 15 * inputs.get("duration", 5)  # rough heuristic
inputs["timeout_seconds"] = max(inputs.get("timeout_seconds", 0), int(expected_render_secs * 1.5))

Try / catch

try:
    result = hunyuan_cloud_video(inputs)
except TimeoutError as e:
    if "did not finish within" in str(e):
        time.sleep(60)
        result = hunyuan_cloud_video({**inputs, "timeout_seconds": inputs["timeout_seconds"] * 2})
    else:
        raise

Prevention

When it happens

Trigger: Long Hunyuan generations (high duration/resolution) where the poll loop runs past timeout_seconds; provider queues backed up at peak times; an aggressively small timeout configured by the caller.

Common situations: Default timeout tuned for short clips used on long renders; concurrent batch submissions exhausting provider capacity; regional TokenHub slowdowns; retry storms amplifying queue depth.

Understand the failure class

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/5d770aa641f260aa. Report an issue: GitHub.