infiniflow/ragflow · error · RuntimeError
Unexpected error during execution
Error message
Unexpected error during execution: {str(e)} What it means
Catch-all for any non-ServerError exception during Aliyun code execution — covers SDK client-side failures (serialization of arguments, enum mismatch), local parsing of the structured result, and network errors that do not surface as ServerError. The original exception text is embedded.
Solutions
- Read str(e) to classify: connection errors mean the instance is gone — recreate it; parse errors mean SDK/result-shape drift.
- Ensure `arguments` contains only JSON-serializable values.
- Pin the agentrun-sdk version tested with this provider.
- Verify the instance still exists (or just recreate) before retrying execution.
Defensive patterns
Strategy: try-catch
Try / catch
try:
result = provider.execute_code(instance_id, code, "python", timeout=10)
except RuntimeError as e:
msg = str(e).lower()
if "not exist" in msg or "connect" in msg:
instance = provider.create_instance("python") # dead sandbox: recreate and retry
result = provider.execute_code(instance.instance_id, code, "python", timeout=10)
else:
raise Prevention
- Keep arguments strictly JSON-serializable.
- Track instance age and proactively recreate sandboxes before they vanish.
- Pin the agentrun-sdk version; parsing drift lands in this catch-all.
When it happens
Trigger: execute_code when: the arguments dict cannot be serialized into the runner format, the agentrun-sdk version changed result shapes and the structured-result parsing breaks, Sandbox.connect to a dead instance raises, or the response JSON is not a dict as expected.
Common situations: instance_id points to an already-destroyed sandbox; SDK version drift (the file notes CodeLanguage enum changes around 0.0.26); non-JSON-serializable values inside arguments; transient connectivity loss mid-request.
Related errors
- Unexpected error creating instance
- Failed to create sandbox instance
- Provider not initialized. Call initialize() first.
- E2B provider is not yet fully implemented. Please use the…
- Execution timed out after
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/730a8e3350a9e427.
Report an issue: GitHub.
Appendix: source
Thrown at agent/sandbox/providers/aliyun_codeinterpreter.py:311
exit_code=exit_code,
execution_time=execution_time,
metadata={
"instance_id": instance_id,
"language": normalized_lang,
"context_id": result.get("contextId") if isinstance(result, dict) else None,
"timeout": timeout,
"result_present": structured_result.get("present", False),
"result_value": structured_result.get("value"),
"result_type": structured_result.get("type"),
},
)
except ServerError as e:
if "timeout" in str(e).lower():
raise TimeoutError(f"Execution timed out after {timeout} seconds")
raise RuntimeError(f"Failed to execute code: {str(e)}")
except Exception as e:
raise RuntimeError(f"Unexpected error during execution: {str(e)}")
def destroy_instance(self, instance_id: str) -> bool:
"""
Destroy an Aliyun Code Interpreter instance.
Args:
instance_id: ID of the instance to destroy
Returns:
True if destruction successful, False otherwise
"""
if not self._initialized or not self._config:
raise RuntimeError("Provider not initialized. Call initialize() first.")
try:
# Delete sandbox by ID directly
Sandbox.delete_by_id(sandbox_id=instance_id)
View on GitHub (pinned to 554fb1133a)