Tencent/WeKnora · error

sandbox: write session file %s: %w

Error message

sandbox: write session file %s: %w

What it means

After the workspace parent directory is created, WriteSessionWorkspaceFile uploads the content via m.client.WriteFile, wrapped as "sandbox: write session file <path>". This is the remote write of a model-authored file failing after directory provisioning succeeded.

Source

Thrown at internal/sandbox/session_manager.go:554

		return err
	}
	if strings.TrimSpace(sessionID) == "" {
		return errors.New("sandbox: session ID required for workspace write")
	}
	clean, err := cleanSessionWorkspaceWritePath(filePath)
	if err != nil {
		return err
	}
	handle, err := m.resolveSession(ctx, sessionID)
	if err != nil {
		return err
	}
	m.ensureSessionWorkspaceDirs(ctx, handle, SessionOutputRoot)
	if err := ignoreExistingDir(m.client.MakeDir(ctx, handle, path.Dir(clean))); err != nil {
		return fmt.Errorf("sandbox: create workspace directory: %w", err)
	}
	if err := m.client.WriteFile(ctx, handle, clean, content); err != nil {
		return fmt.Errorf("sandbox: write session file %s: %w", clean, err)
	}
	return nil
}

// RemoveSessionInputPath deletes a staged attachment. It is a no-op when the
// session has no live sandbox and never provisions one.
func (m *SessionBoundManager) RemoveSessionInputPath(
	ctx context.Context, sessionID, targetPath string,
) error {
	if err := m.requireRemoteBackend(); err != nil {
		return err
	}
	clean, err := cleanSessionInputPath(targetPath)
	if err != nil {
		return err
	}
	handle, ok, err := m.lookupSessionHandle(ctx, sessionID)
	if err != nil || !ok {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Read the wrapped provider error (timeout, 429, 5xx).
  2. Retry; re-resolve the session to provision a fresh sandbox if it expired.
  3. Increase HTTP timeout or chunk large writes.
  4. Verify workspace permissions in the sandbox image.
Defensive patterns

Strategy: try-catch

Validate before calling

// check content size and sandbox liveness before write
if len(content) > maxWorkspaceFileBytes {
    return fmt.Errorf("workspace file too large: %d bytes", len(content))
}
if _, err := mgr.StatSessionFile(ctx, sessionID, "/workspace"); err != nil {
    return fmt.Errorf("sandbox not ready: %w", err)
}

Try / catch

err := mgr.WriteSessionWorkspaceFile(ctx, sessionID, p, data)
if err != nil && strings.Contains(err.Error(), "write session file") {
    // sandbox may have expired mid-write: re-resolve (provisions) and retry
    if retryErr := mgr.WriteSessionWorkspaceFile(ctx, sessionID, p, data); retryErr != nil {
        return fmt.Errorf("persist workspace file %s: %w", p, retryErr)
    }
}

Prevention

When it happens

Trigger: Calling WriteSessionWorkspaceFile when client.WriteFile fails — network interruption, sandbox terminated during transfer, provider API rejection, size limits, or unwritable path.

Common situations: Large model outputs timing out, sandbox expiring mid-write, provider throttling (429), or the image making the workspace read-only.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/da7029cfc4212af2. Report an issue: GitHub.