fix: Drop await from LDAIClient factory calls#33
Merged
Conversation
The factory methods create_model, create_agent, and create_agent_graph are now synchronous in launchdarkly-server-sdk-ai 0.21.0. The run() methods on the returned objects remain async. Also bumps the SDK pin in the affected examples to >=0.21.0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The sync factory methods released as 1.0.0 (not 0.21.0). The breaking change triggered a major bump under semver. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tracisiebel
approved these changes
May 19, 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.
Summary
The
LDAIClientfactory methodscreate_model,create_agent, andcreate_agent_graphwere converted fromasync defto plaindefinlaunchdarkly-server-sdk-ai1.0.0 — they do no async work, so theawaitwas misleading. Therun()methods on the returnedManagedModel/ManagedAgent/ManagedAgentGraphobjects remain async.This PR drops
awaitfrom the three affected example call-sites infeatures/, updates the inline doc comments to match, and pins the SDK for those examples at>=1.0.0,<2.0.0.Requirements
Requires
launchdarkly-server-sdk-ai>=1.0.0(released, on PyPI).Related SDK PR: launchdarkly/python-server-sdk-ai#187 (
feat!: Make AI config factory methods synchronous).Examples updated
features/create_model/create_model_example.py— droppedawaitonaiclient.create_model(...); pin bumped.features/create_agent/create_agent_example.py— droppedawaitonaiclient.create_agent(...); pin bumped.features/create_agent_graph/create_agent_graph_example.py— droppedawaitonaiclient.create_agent_graph(...); pin bumped.features/create_judge/and allgetting_started/*examples were untouched:create_judge()was already sync, andgetting_started/*use the oldercompletion_config/agent_configAPI rather than the factory methods, so they don't depend on the 1.0.0 release.async def async_main()was kept as-is in all three updated examples — each still awaitsmodel.run()/agent.run()/graph.run()andresponse.evaluations, so the function must remain async.End-to-end verification
Verified against the local SDK worktree (sync factory implementation) and re-verified that
poetry installresolveslaunchdarkly-server-sdk-ai 1.0.0from PyPI in all three examples after pinning.features/create_model(poetry run modelwithLAUNCHDARKLY_COMPLETION_KEY=sample-ai-config) — full chat + judge evaluation flow ran successfully.features/create_agent(poetry run agentwithLAUNCHDARKLY_AGENT_KEY=sample-ai-config) — factory call succeeded andagent.run()returned a response. The example then errored onsummary.usagebecause the example file uses.usage, but the SDK renamed that attribute to.tokensin 0.20 ("Rename LDAIMetrics.usage and AIGraphMetrics.usage to .tokens"). This is a pre-existing example bug unrelated to this PR and should be addressed separately. (See the same.usagereferences infeatures/create_agent_graph.)features/create_agent_graph— not run end-to-end. The change is mechanical and identical in shape to the other two factories, and the same pre-existing.usageissue would prevent a clean run.Test plan