ThinkRun

llms.txt

Error Codes

All API responses include structured error information. Use the code and retryable fields for programmatic error handling.

Response Format

Error responses follow this structure:

{
  "success": false,
  "error": "Element not found: button.submit",
  "code": "ELEMENT_NOT_FOUND",
  "hint": "Verify the selector exists. Try taking a snapshot first.",
  "retryable": true   // local/bridge mode only
}

Cloud mode includes hint. Local bridge mode includes retryable. Both include code.

Cloud API Error Codes

Source: error-handler.ts — returned by all /api/sessions/* endpoints

CodeHTTPRetryMeaningHint
ELEMENT_NOT_FOUND404YESCSS selector matched nothingTake a snapshot to inspect the DOM
ELEMENT_IN_IFRAME404YESElement is inside an iframeUse a frame-aware selector
ELEMENT_IN_SHADOW_DOM404YESElement is inside a shadow DOMUse >>> shadow-piercing syntax
NAVIGATION_TIMEOUT504YESPage took too long to loadIncrease timeout or check URL
OPERATION_TIMEOUT504YESOperation exceeded time limitSimplify the operation or increase timeout
SESSION_CLOSED410FATALBrowser session was closedCreate a new session
PAGE_NAVIGATED409YESNavigation occurred during operationWait for navigation, then retry
BROWSER_PROTOCOL_ERROR502YESBrowser internal communication errorRetry or create new session
STORAGE_TIMEOUT503YESStorage backend slow or unreachableRetry in a few seconds
STORAGE_ERROR502YESStorage backend returned an errorUsually transient, retry
BROWSER_POOL_UNAVAILABLE503YESNo browser instances availableRetry in 10-30 seconds
SESSION_LIMIT_REACHED429YESMaximum concurrent sessions reachedDelete unused sessions first (DELETE /api/sessions/:id), or wait up to 30 min for idle sessions to auto-expire, then retry
PROVISIONING_FAILED503YESCloud machine provisioning failedRetry in 30 seconds
INVALID_API_KEY401NOAPI key invalid or expiredCheck or regenerate your API key
EVALUATE_FAILED400FATALJavaScript evaluation errorCheck script for syntax errors
PAYLOAD_TOO_LARGE413NORequest body exceeds size limitReduce payload size
INSUFFICIENT_CREDITS402FATALNot enough credits for this operationPurchase credits at /api/credits/checkout
WS_DISCONNECTED503YESChrome extension WebSocket disconnectedEnsure the extension is running and connected
CLI_TIMEOUT504YESServer-side CLI agent timed outTry a simpler task or increase timeout
CLI_FAILED502YESServer-side CLI agent process errorCheck server logs; agent exited non-zero
NETWORK_ERROR502YESTarget URL unreachableVerify URL is correct and accessible
INTERNAL_ERROR500YESUnclassified server errorCheck server logs

Local Mode Error Codes

Source: local native host — run thinkrun attach <tabId> before issuing commands

CodeHTTPRetryMeaningHint
EXTENSION_NOT_CONNECTED503YESChrome extension is disconnected or still reconnectingIf the extension is not installed, open Chrome with ThinkRun. Otherwise wait briefly or run thinkrun doctor.
EXTENSION_DISCONNECTED503YESExtension disconnected mid-requestRun thinkrun doctor first. If the bridge is healthy, use thinkrun session debug --json for continuity details.
REQUEST_TIMEOUT504YESNative host request timed out (30s)Retry or check extension responsiveness
COMMAND_TIMEOUT504YESExtension command execution timed outSimplify the action or increase timeout
TAB_NOT_FOUND410FATALTarget tab was closed or the remembered local binding is staleRun: thinkrun tabs, then thinkrun attach <tabId> for a live tab
TAB_NOT_OWNED403FATALAgent session does not own this tabRun: thinkrun attach <tabId> to claim this tab
TAB_OWNED_BY_OTHER_SESSION403FATALAnother local session owns the tab, or the local authority cache is staleRun: thinkrun session debug --json first. If continuity is still yours, re-attach only to rebuild authority. If another live owner holds the tab, use thinkrun new-window or wait for release.
SESSION_NOT_FOUND404FATALAgent session ID not registered in native hostRun: thinkrun attach <tabId> to register a session
ELEMENT_NOT_FOUND404YESCSS selector matched nothingCheck selector against page DOM
NAVIGATION_FAILED502YESPage load failed (net::ERR_*)Verify URL is accessible
SCRIPT_ERROR400FATALJavaScript syntax or runtime errorFix the script
TASK_TIMEOUTNOAI task exceeded configured timeoutIncrease --timeout or break the task into smaller steps
BRIDGE_UNREACHABLEFATALLocal bridge could not be reached before the attach or switch request was issuedRun: thinkrun doctor
NATIVE_HOST_UNREACHABLEFATALClient-side bridge route could not be reached after port revalidationRun: thinkrun doctor. If a mutating command was in flight, verify page state before retrying.
NATIVE_HOST_ERRORFATALNative host bridge is not running or encountered a fatal errorRun: thinkrun doctor

Blank status cells on native-host bridge errors mean the CLI surfaced a structured local error before any HTTP response was produced.

Native-host self-install (thinkbrowse-host --install) returns a non-zero exit code on partial manifest-write failures so scripts can detect incomplete installs.

Fatal vs Transient Errors

The task executor uses a smart circuit breaker to distinguish fatal errors (stop immediately) from transient errors (retry with backoff). The native-host bridge has its own circuit breaker that opens after 3 consecutive non-app errors (e.g. command timeouts). If thinkrun doctor reports a circuit-breaker trip, run thinkrun reset-connection to re-arm it without reloading the extension.

Fatal (stop immediately)

2 consecutive fatal errors aborts the task.

  • SESSION_CLOSED — browser gone
  • TAB_NOT_FOUND — tab gone
  • TAB_NOT_OWNED — run attach
  • TAB_OWNED_BY_OTHER_SESSION — session debug before any re-attach
  • SESSION_NOT_FOUND — run attach
  • SCRIPT_ERROR — bad JavaScript
  • EVALUATE_FAILED — eval error
  • BRIDGE_UNREACHABLE — doctor before retrying attach, switch-tab, or focus
  • NATIVE_HOST_UNREACHABLE — doctor + verify page state before manually re-issuing mutating commands
  • NATIVE_HOST_ERROR — run doctor
  • INVALID_API_KEY — bad key
  • INSUFFICIENT_CREDITS — buy credits

Transient (retry with backoff)

5 transient errors within 60s aborts the task.

  • ELEMENT_NOT_FOUND — may appear during load
  • NAVIGATION_TIMEOUT — slow page
  • EXTENSION_NOT_CONNECTED — reconnecting
  • BROWSER_PROTOCOL_ERROR — transient
  • HTTP 502, 503, 504, 524

Handling Errors Programmatically

# Check the code field in the response
RESP=$(curl -s -X POST "$BASE/api/sessions/$SID/click" \
  -H "x-api-key: $API_KEY" -H "Content-Type: application/json" \
  -d '{"selector": ".nonexistent"}')

CODE=$(echo "$RESP" | jq -r '.code // empty')
case "$CODE" in
  SESSION_CLOSED|TAB_NOT_FOUND)
    echo "Fatal: session gone, create a new one" ;;
  TAB_NOT_OWNED|SESSION_NOT_FOUND)
    echo "Fatal: run thinkrun attach <tabId>" ;;
  TAB_OWNED_BY_OTHER_SESSION)
    echo "Inspect session debug first; same-lineage re-attach may still recover authority" ;;
  BRIDGE_UNREACHABLE|NATIVE_HOST_ERROR)
    echo "Fatal: run thinkrun doctor" ;;
  NATIVE_HOST_UNREACHABLE)
    echo "Fatal: safe reads already exhausted retries; run thinkrun doctor and verify page state before re-issuing mutating commands" ;;
  INVALID_API_KEY|INSUFFICIENT_CREDITS)
    echo "Fatal: fix credentials or buy credits" ;;
  SESSION_LIMIT_REACHED)
    echo "Delete unused sessions, then retry" ;;
  ELEMENT_NOT_FOUND|NAVIGATION_TIMEOUT)
    echo "Transient: retry after delay" ;;
  EVALUATE_FAILED|SCRIPT_ERROR)
    echo "Fatal: fix the script" ;;
esac

TAB_OWNED_BY_OTHER_SESSION is the main nuanced case in local mode: check thinkrun session debug --json first, because a same-lineage re-attach can recover local authority without taking over a foreign tab.