Repository navigation
Move offline evals to AI SDK 1.1.0 - #30
Conversation
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
left a comment
There was a problem hiding this comment.
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_callcallstime.sleep, and it runs fromGenericAgent.ainvokeon 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.pyupdate_variationsends only instructions, tools andmodelConfigKey, whilecreate_variationalso sendscustom. A variation updated through the overwrite path losesmax_tool_callsand 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.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed all six review items in
Branch target note: |
jeffdupont
left a comment
There was a problem hiding this comment.
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.
…_data, and matched feedback configKey Co-authored-by: Cursor <cursoragent@cursor.com>
jeffdupont
left a comment
There was a problem hiding this comment.
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.
…ls and feedback fallback Co-authored-by: Cursor <cursoragent@cursor.com>
jeffdupont
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Optional: this comment still says top_k: number, but the schemas below (and bootstrap) now use integer.
Moves the offline-evals branch to
launchdarkly-ai-server>=1.1.0and the current models.resolve_graph, plain-dict configs,inspect_config).temperature, and uses the Responses API for OpenAI tool calls.customParameterssomax_tool_callstakes effect, and retries rate-limited requests. A reached tool limit comes back as an answer./admin/flushflushes events without closing the LaunchDarkly client.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.pyreproducesdatasets/answer-tests.csv, and an offline eval with an Accuracy judge passed on both OpenAI and Anthropic judges.