Skip to content

Move offline evals to AI SDK 1.1.0 - #30

Merged
sattensil merged 12 commits into
feature/offline-evalsfrom
sdk-roll-forward-offline-evals-1x
Nov 24, 2026
Merged

sattensil merged 12 commits into
feature/offline-evalsfrom
sdk-roll-forward-offline-evals-1x

Conversation

@sattensil

@sattensil sattensil commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Moves the offline-evals branch to launchdarkly-ai-server>=1.1.0 and the current models.

  • Ports config, graph and feedback code to the 1.x API (resolve_graph, plain-dict configs, inspect_config).
  • Updates models to Claude 5.5 and GPT-6, drops temperature, and uses the Responses API for OpenAI tool calls.
  • The graph walk fails closed: a failed node, a sanitize handoff without redacted text, or a node that picks no valid route stops before support sees the input.
  • Bootstrap sends customParameters so max_tool_calls takes effect, and retries rate-limited requests. A reached tool limit comes back as an answer.
  • Feedback is attributed to the served support-agent variation.
  • /admin/flush flushes events without closing the LaunchDarkly client.
  • Removes the per-config fallback, the defaults file and the old agent wrapper, which the graph path never called.

Tested from a fresh clone against a throwaway project: bootstrap, every targeted variation, the PII path, the tool limit, UI, traffic generator, feedback, monitoring, and a disabled config. tools/build_rag_dataset.py reproduces datasets/answer-tests.csv, and an offline eval with an Accuracy judge passed on both OpenAI and Anthropic judges.

Carries the agent-graphs migration onto this branch: launchdarkly-ai-server in
place of LDAIClient, plain dicts for configs and contexts, GraphTracker
emitting the graph events by hand, and fallbacks applied in get_config because
the SDK has no `default=` parameter. Three of the four files applied unchanged
from that branch; only config_manager needed resolving.

This branch already had get_agent_graph, which agent-graphs was missing
entirely. Its signature matches the one inferred there, which is the useful
confirmation: the contract was (user_id, graph_key, user_context) returning the
graph, with the caller pulling a tracker off it. The migrated version returns
(graph, tracker) instead, because resolve_graph returns topology only and there
is no get_tracker() to call.

clear_cache is kept from this branch. It is a no-op, but it is part of this
branch's config manager surface and dropping it would break callers.

The graph event keys change with this, as on agent-graphs:

    $ld:ai:graph:handoff    -> handoff_success / handoff_failure
    $ld:ai:graph:invocation -> invocation_success / invocation_failure
    $ld:ai:graph:total      -> total_tokens
    $ld:ai:tool             -> tool_call

Metrics keyed on the old names need recreating. graph:redirect and the
per-node invocation event have no replacement.

Requires Python 3.12+, the launchdarkly-ai-server floor.


Pinned to launchdarkly-ai-server 0.2.4, the current release. Nothing this
migration relies on changed in it, and parse_usage still reports zero for a
provider native token spelling, so the explicit key renaming is still needed.

.python-version was still 3.11 against a requires-python of >=3.12, which
blocked uv from locking at all.

0.2.4 retires $ld:ai:graph:path in favour of one $ld:ai:graph:node per node
entered, so GraphTracker now emits that from track_node_invocation, where the
service already announces each node. The ordered series of those events is the
path. track_path is kept as a log-only no-op so agent_service does not change.

Any LaunchDarkly metric built on $ld:ai:graph:path needs recreating against
$ld:ai:graph:node before this branch reports a path at all.
Carries the same three fixes from the agent-graphs branch, which shares
these files verbatim. Configs are plain dicts now, but these call sites
were still reading them as objects, and none of them failed loudly.

extract_tool_configs_from_launchdarkly read config.tools and
config.to_dict(). Both fail on a dict, and the to_dict() call raised
inside a try that logged and returned empty, so every node in the graph
ran with no tools at all. Tools are read from model.parameters.tools,
which is where LaunchDarkly serves them.

edge.target_config does not exist on GraphEdge; the attribute is
target_key. This raised on the first routing decision, so the graph
could not advance past its root node.

generic_agent read max_tool_calls through agent_config.to_dict() inside
a try that fell back to 20, so a config setting a lower ceiling silently
did not get it.

_update_context recovered the variation key from a private tracker
attribute behind a hasattr guard that is always false on a dict, so
every node reported variation "default" and model "unknown". Both come
off the node now, from meta["variationKey"] and the model dict.

clear_cache already exists on this branch's config manager, so unlike
agent-graphs nothing had to be restored there.

Verified offline against a stub client: a two-node graph resolves, edges
expose target_key, tools come back from model.parameters, and the
tracker emits only current event keys.
Pins launchdarkly-ai-server>=1.1.0 and launchdarkly-server-sdk>=9.18.4.

The shared runtime files now match tutorial/agent-graphs, which is already on
1.x: graph events carry the node's config and variation keys so monitoring
attributes them, contexts are converted before track() so events are not
dropped, feedback no longer reads a tracker that dicts don't have, and the
security agent's redacted text replaces the original message for later nodes.

Feedback names support-agent and its served variation again, as it did before
the SDK move, so monitoring counts thumbs up and down.

Models move to Claude Haiku 5.5, Claude Sonnet 5.5, gpt-6-luna and gpt-6.2-sol.
None of them accept temperature, and GPT-6 needs the Responses API for tool
calls, whose replies are content blocks, so responses are read with .text. The
pii-detector prompt now asks for its fields inside the closing JSON, which
Haiku 5.5 otherwise leaves out about half the time.

nest_asyncio was imported but never installed on this branch, so the first
chat failed; nothing on the async path needs it, so the import is gone.
Bootstrap retries rate-limited API calls instead of skipping them, which left a
variation and its targeting rule missing.
A failed security agent used to fall through to the first edge, which sent the
unredacted message on to the support agent. Any node error now ends the walk
and returns an error, and the invocation is recorded as a failure.
A node reached through a sanitize handoff now has to return redacted
text, or the walk stops instead of passing the raw input on.

Bootstrap sends each variation's customParameters as model.custom, so
max_tool_calls from the manifest reaches the agents.

The per-config fallback, the defaults file and the old agent wrapper
had no callers on the graph path, so they are gone. The README lists
the files that exist.
Now that max_tool_calls reaches the agents, the free tier hits its limit
of 3. Raising there stopped the graph walk and counted a generation error.

@jeffdupont jeffdupont left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The SDK move itself is right: init_client(client=...), inspect_config, resolve_graph and parse_ai_config are used as 1.1.0 defines them, the new fail-closed redaction checks are good, and all the old ldai references are gone. A few features quietly stop working, though (inline, plus these):

  • Blocking sleep on the event loop. agents/ld_agent_helpers.py _rate_limit_llm_call calls time.sleep, and it runs from GenericAgent.ainvoke on the server's event loop with a module-wide timestamp, so one call can stall every concurrent request for up to a second. asyncio.sleep, or dropping the limiter, would fix it.
  • The README documents AGENT_REGISTRY, which no longer exists (README lines 118, 126, 131-134). The table row and the "add a new agent type" snippet tell readers to edit something that was deleted.
  • Updating a variation drops model.custom. bootstrap/create_configs.py update_variation sends only instructions, tools and modelConfigKey, while create_variation also sends custom. A variation updated through the overwrite path loses max_tool_calls and falls back to 20.

Also worth a look: this changes many of the same files as #29 with a different approach (and drops the [otel] extra #29 relies on), so whichever merges second needs a full rebase.

Comment thread tools_impl/dynamic_tool_factory.py Resolved
Comment thread config_manager.py Resolved
Comment thread config_manager.py Resolved
Co-authored-by: Cursor <cursoragent@cursor.com>
@sattensil

Copy link
Copy Markdown
Collaborator Author

Addressed all six review items in 63f85cc (and added offline unit coverage in tests/test_review_fixes.py):

  1. Dynamic tool schemas & descriptions (tools_impl/dynamic_tool_factory.py): Read parameters and description from the top-level config["tools"][name] dict returned by parse_ai_config in 1.1.0 and apply both to the dynamically constructed tools.
  2. Graph & node tracking payloads (config_manager.py, api/services/agent_service.py): Use launchdarkly_ai_server.make_track_data for $ld:ai:graph:node (plus nodeKey and index) and all per-node events, and populate graph-level variationKey and version from the evaluated graph variation metadata.
  3. Feedback attribution (api/models.py, api/main.py, ui/chat_interface.py, config_manager.py, tools/traffic_generator.py): Pass agent_configurations, served variation_key/version, and user_context from the response into /feedback -> track_feedback, and fail closed (return False) rather than emitting an empty variationKey.
  4. Non-blocking rate limiter (agents/ld_agent_helpers.py, agents/generic_agent.py): Switched _rate_limit_llm_call to async using await asyncio.sleep(...) with monotonic slot reservation so concurrent requests never block the event loop.
  5. update_variation custom parameters (bootstrap/create_configs.py): Forward model.custom (customParameters, including max_tool_calls) on the PATCH overwrite path to match create_variation.
  6. README architecture (README.md): Replaced references to the deleted AGENT_REGISTRY with the dynamic create_generic_agent execution flow.

Branch target note: #30 targets feature/offline-evals (the standalone branch used by the Offline Evals tutorial), while #29 targets main (Part 1 of the LangGraph series) — the two branches remain intentionally separate and do not merge into each other.

@sattensil
sattensil requested a review from jeffdupont November 20, 2026 17:52

@jeffdupont jeffdupont left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. Most of my earlier points are fixed: the rate limiter is now async, the README describes create_generic_agent instead of AGENT_REGISTRY, update_variation keeps model.custom, feedback is attributed to the served variation, and the graph-node payload matches the SDK's.

The tool-schema fix introduced a blocker: with the schema the bootstrap script creates, every search_v1 call now fails. Details inline, with one related should-fix and two nits.

Comment thread tools_impl/dynamic_tool_factory.py Resolved
Comment thread tools_impl/dynamic_tool_factory.py Resolved
Comment thread config_manager.py Resolved
Comment thread api/main.py Resolved
…_data, and matched feedback configKey

Co-authored-by: Cursor <cursoragent@cursor.com>
@sattensil
sattensil requested a review from jeffdupont November 23, 2026 17:39

@jeffdupont jeffdupont left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all four of my round-2 items are fixed. I ran search_v1 through the dynamic schema with the locked langchain-core 1.2.19: invoke and ainvoke work with only query, with top_k, and with top_k: null. search_v2 now takes extra fields, the tracking import is public, and feedback uses the served config key.

One thing to fix before merge, inline: the reranking test schema doesn't match the bootstrap one. Plus two optional nits.

Comment thread tests/test_review_fixes.py Resolved
Comment thread api/main.py Resolved
Comment thread tools_impl/dynamic_tool_factory.py Resolved
…ls and feedback fallback

Co-authored-by: Cursor <cursoragent@cursor.com>
@sattensil
sattensil requested a review from jeffdupont November 23, 2026 18:47

@jeffdupont jeffdupont left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all three of my round-3 items are fixed: the bootstrap reranking schema now matches the test (and the results=None fallback is real), the feedback fallback uses the resolved agent, and the schema mapper uses integer/number instead of a name check.

One optional nit inline.

monkeypatch.setattr(search_v2_mod, "_get_vector_store", lambda: FakeVectorStore())
search_v2_mod._cached_search.cache_clear()

# Exact bootstrap schemas for search_v1 (top_k: number optional) + extra custom field on search_v2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this comment still says top_k: number, but the schemas below (and bootstrap) now use integer.

@sattensil
sattensil merged commit 3a071c9 into feature/offline-evals Nov 24, 2026
@sattensil
sattensil deleted the sdk-roll-forward-offline-evals-1x branch November 24, 2026 17:57
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