Skip to content

Commit ba6d3dd

Browse files
committed
[REL-11697] update to match server response; parse config slightly differently
1 parent 3041fad commit ba6d3dd

2 files changed

Lines changed: 20 additions & 25 deletions

File tree

packages/sdk/server-ai/src/ldai/client.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -431,25 +431,26 @@ def agent_graph(
431431
"""
432432
variation = self._client.variation(key, context, {})
433433

434-
if not variation.get("rootConfigKey"):
434+
if not variation.get("root"):
435435
log.debug(f"Agent graph {key} is disabled, no root config key found")
436436
return AgentGraphDefinition(
437437
AIAgentGraphConfig(
438438
key=key,
439-
name="",
440439
root_config_key="",
441440
edges=[],
442-
description="",
443441
enabled=False,
444442
),
445443
nodes={},
446444
context=context,
447445
enabled=False,
448446
)
447+
448+
edge_keys = list[str](variation.get("edges", {}).keys())
449+
all_agent_keys = set[str]([variation.get("root")])
450+
for edge_key in edge_keys:
451+
for single_edge in variation.get("edges", {}).get(edge_key, []):
452+
all_agent_keys.add(single_edge.get("key", ""))
449453

450-
all_agent_keys = [variation["rootConfigKey"]] + [
451-
edge.get("targetConfig", "") for edge in variation.get("edges", []) if edge.get("targetConfig")
452-
]
453454
agent_configs = {
454455
key: self.agent_config(key, context, AIAgentConfigDefault(enabled=False))
455456
for key in all_agent_keys
@@ -462,10 +463,8 @@ def agent_graph(
462463
return AgentGraphDefinition(
463464
AIAgentGraphConfig(
464465
key=key,
465-
name="",
466466
root_config_key="",
467467
edges=[],
468-
description="",
469468
enabled=False,
470469
),
471470
nodes={},
@@ -474,30 +473,28 @@ def agent_graph(
474473
)
475474

476475
try:
476+
edges: list[Edge] = []
477+
for edge_key in edge_keys:
478+
for single_edge in variation.get("edges", {}).get(edge_key, []):
479+
edges.append(Edge(
480+
key=edge_key + "-" + single_edge.get("key", ""),
481+
source_config=edge_key,
482+
target_config=single_edge.get("key", ""),
483+
handoff=single_edge.get("handoff", {}),
484+
))
485+
477486
agent_graph_config = AIAgentGraphConfig(
478-
key=variation["key"],
479-
name=variation["name"],
480-
root_config_key=variation["rootConfigKey"],
481-
edges=[
482-
Edge(
483-
key=edge.get("key", ""),
484-
source_config=edge.get("sourceConfig", ""),
485-
target_config=edge.get("targetConfig", ""),
486-
handoff=edge.get("handoff", {}),
487-
)
488-
for edge in variation["edges"]
489-
],
490-
description=variation["description"],
487+
key=key,
488+
root_config_key=variation.get("root"),
489+
edges=edges,
491490
)
492491
except Exception as e:
493492
log.debug(f"Agent graph {key} is disabled, invalid agent graph config")
494493
return AgentGraphDefinition(
495494
AIAgentGraphConfig(
496495
key=key,
497-
name="",
498496
root_config_key="",
499497
edges=[],
500-
description="",
501498
enabled=False,
502499
),
503500
nodes={},

packages/sdk/server-ai/src/ldai/models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,8 @@ class AIAgentGraphConfig:
365365
"""
366366

367367
key: str
368-
name: str
369368
root_config_key: str
370369
edges: List[Edge]
371-
description: Optional[str] = ""
372370
enabled: bool = True
373371

374372

0 commit comments

Comments
 (0)