Skip to content

fix: Drop await from LDAIClient factory calls#33

Merged
jsonbailey merged 2 commits into
mainfrom
jb/async-cleanup
May 19, 2026
Merged

fix: Drop await from LDAIClient factory calls#33
jsonbailey merged 2 commits into
mainfrom
jb/async-cleanup

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented May 19, 2026

Summary

The LDAIClient factory methods create_model, create_agent, and create_agent_graph were converted from async def to plain def in launchdarkly-server-sdk-ai 1.0.0 — they do no async work, so the await was misleading. The run() methods on the returned ManagedModel / ManagedAgent / ManagedAgentGraph objects remain async.

This PR drops await from the three affected example call-sites in features/, 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 — dropped await on aiclient.create_model(...); pin bumped.
  • features/create_agent/create_agent_example.py — dropped await on aiclient.create_agent(...); pin bumped.
  • features/create_agent_graph/create_agent_graph_example.py — dropped await on aiclient.create_agent_graph(...); pin bumped.

features/create_judge/ and all getting_started/* examples were untouched: create_judge() was already sync, and getting_started/* use the older completion_config / agent_config API 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 awaits model.run() / agent.run() / graph.run() and response.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 install resolves launchdarkly-server-sdk-ai 1.0.0 from PyPI in all three examples after pinning.

  • features/create_model (poetry run model with LAUNCHDARKLY_COMPLETION_KEY=sample-ai-config) — full chat + judge evaluation flow ran successfully.
  • features/create_agent (poetry run agent with LAUNCHDARKLY_AGENT_KEY=sample-ai-config) — factory call succeeded and agent.run() returned a response. The example then errored on summary.usage because the example file uses .usage, but the SDK renamed that attribute to .tokens in 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 .usage references in features/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 .usage issue would prevent a clean run.

Test plan

  • CI passes.
  • Spot-check one of the affected examples against the published 1.0.0 release.

jsonbailey and others added 2 commits May 18, 2026 21:52
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>
@jsonbailey jsonbailey marked this pull request as ready for review May 19, 2026 05:15
@jsonbailey jsonbailey requested a review from a team as a code owner May 19, 2026 05:15
@jsonbailey jsonbailey changed the title refactor: Drop await from LDAIClient factory calls fix: Drop await from LDAIClient factory calls May 19, 2026
@jsonbailey jsonbailey merged commit 7a42f9b into main May 19, 2026
3 checks passed
@jsonbailey jsonbailey deleted the jb/async-cleanup branch May 19, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants