[OPIK-5184] [SDK] feat: Make Prompt and ChatPrompt resilient to backend sync failures#6125
Merged
petrotiurin merged 5 commits intomainfrom Apr 9, 2026
Conversation
…c failures Prompts now work locally even when the backend is unreachable. sync_with_backend() is public, returns bool, exposes a synced property, and only catches API/network errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…sync failures Equivalent to the Python SDK changes: createPrompt/createChatPrompt now return unsynced instances on API/timeout errors instead of throwing. Adds synced property, syncWithBackend() method, and requireSynced() guard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s, fix test fixtures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover OpikApiError, OpikApiTimeoutError, non-API error propagation, and syncWithBackend delegation for chat prompts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
alexkuzmik
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
Prompt()andChatPrompt()constructors (Python) andcreatePrompt()/createChatPrompt()(TypeScript) now gracefully handle backend unavailability instead of crashing. When the backend is unreachable, prompts work locally and can be synced later viasync_with_backend()/syncWithBackend().Key changes across both SDKs:
ValueError,TypeError,PromptTemplateStructureMismatch) still propagate normallysyncedproperty to check if a prompt was successfully persistedsync_with_backend()/syncWithBackend()method for manual retryformat()and all local operationsChange checklist
Issues
AI-WATERMARK
AI-WATERMARK: yes
Testing
Python SDK:
All 16 tests pass. Pre-commit hooks (ruff, ruff-format, mypy) pass.
TypeScript SDK:
All 42 tests pass.
tsc --noEmitpasses with zero errors.Scenarios validated:
sync_with_backend()returnsFalse/falseon failure,True/trueon successsyncedproperty reflects current sync stateValueError,TypeError) propagate and prevent constructionChatPromptcreation updated for renamed methodDocumentation
N/A
🤖 Generated with Claude Code