Skip to content

fix: Modernize agent-graphs to AI SDK 0.20+#27

Open
sattensil wants to merge 1 commit into
tutorial/agent-graphsfrom
fix/agent-graphs-modernize-ai-sdk-0.20
Open

fix: Modernize agent-graphs to AI SDK 0.20+#27
sattensil wants to merge 1 commit into
tutorial/agent-graphsfrom
fix/agent-graphs-modernize-ai-sdk-0.20

Conversation

@sattensil
Copy link
Copy Markdown
Collaborator

Summary

Brings tutorial/agent-graphs in line with the SDK modernization that landed on main via #24, plus two config_manager methods that were added to main in the offline-evals work (2026-04-09) but never back-ported to this branch.

SDK migration

  • pyproject.toml: bump launchdarkly-server-sdk-ai pin >=0.10.0>=0.20.0; drop the [tool.uv.sources] git override pointing at python-server-sdk-ai@main so we install the published package.
  • config_manager.py: canonicalize from ldai.clientfrom ldai.
  • Replace removed config.tracker attribute with config.create_tracker() across config_manager.py, agents/generic_agent.py, agents/ld_agent_helpers.py, api/services/agent_service.py, api/main.py.
  • In generic_agent.py, hoist tracker = agent_config.create_tracker() once so the try/except shares a single tracker (avoids creating four trackers per call).

Pre-existing branch bug, fixed

This branch was broken at import time before this PR: AgentService.__init__ calls self.config_manager.clear_cache() and agent_service.py:50 calls self.config_manager.get_agent_graph(...), but neither was defined on this branch's FixedConfigManager. Both methods were added on main (commit dbdf4e9, "Add offline-evals tutorial companion") and never picked up here. Ported with no logic changes.

Test plan

  • Install launchdarkly-server-sdk-ai>=0.20.0 in a fresh venv (resolves to 1.0.1).
  • Import config_manager, agents.ld_agent_helpers, agents.generic_agent, api.services.agent_service, api.main — all succeed (previously api.main failed with AttributeError: 'FixedConfigManager' object has no attribute 'clear_cache').
  • End-to-end agent-graph run against a real LaunchDarkly project and graph.

🤖 Generated with Claude Code

Brings tutorial/agent-graphs in line with the modernization that
landed on main via #24 (devrel-agents-tutorial), plus the missing
config_manager methods added on main in the offline-evals work
that this branch never picked up.

SDK migration:
- pyproject.toml: launchdarkly-server-sdk-ai >=0.10.0 -> >=0.20.0;
  drop [tool.uv.sources] git override pinning to python-server-sdk-ai@main
- config_manager.py: from ldai.client -> from ldai
- Replace removed `config.tracker` attribute with
  `config.create_tracker()` across config_manager.py, generic_agent.py,
  ld_agent_helpers.py, agent_service.py, api/main.py
- In generic_agent.py hoist `tracker = agent_config.create_tracker()`
  once so the try/except shares a single tracker

Fix pre-existing import-time AttributeError on this branch:
- agent_service.AgentService.__init__ calls
  `self.config_manager.clear_cache()` and
  `self.config_manager.get_agent_graph(...)` but neither existed on
  FixedConfigManager in this branch. Port both from main (clear_cache
  is a no-op; get_agent_graph wraps ai_client.agent_graph).

Verified by importing config_manager, agents.ld_agent_helpers,
agents.generic_agent, api.services.agent_service, and api.main in a
fresh venv with launchdarkly-server-sdk-ai 1.0.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant