Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def route(state: WorkflowState) -> str:
compiled = agent_builder.compile()
return compiled, fn_name_to_config_key, node_keys

async def run(self, input: Any) -> AgentGraphRunnerResult:
async def run(self, input: str) -> AgentGraphRunnerResult:
"""
Run the agent graph with the given input.

Expand All @@ -295,7 +295,7 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
handler = LDMetricsCallbackHandler(self._node_keys, self._fn_name_to_config_key)

result = await self._compiled.ainvoke( # type: ignore[call-overload]
{'messages': [HumanMessage(content=str(input))]},
{'messages': [HumanMessage(content=input)]},
config={'callbacks': [handler], 'recursion_limit': 25},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
self._tool_name_map: Dict[str, str] = {}
self._node_metrics: Dict[str, LDAIMetrics] = {}

async def run(self, input: Any) -> AgentGraphRunnerResult:
async def run(self, input: str) -> AgentGraphRunnerResult:
"""
Run the agent graph with the given input.

Expand All @@ -81,15 +81,14 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
if root_key:
path.append(root_key)

input_str = str(input)
start_ns = time.perf_counter_ns()
state = _RunState(last_handoff_ns=start_ns, last_node_key=root_key)
try:
from agents import Runner
root_agent = self._build_agents(path, state)
if root_key:
self._node_metrics[root_key] = LDAIMetrics(success=False)
result = await Runner.run(root_agent, input_str)
result = await Runner.run(root_agent, input)
self._flush_final_segment(state, result)
self._collect_tool_calls(result)

Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/server-ai/src/ldai/managed_agent_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""ManagedAgentGraph — LaunchDarkly managed wrapper for agent graph execution."""

from typing import Any, Dict
from typing import Dict

from ldai.agent_graph import AgentGraphDefinition
from ldai.providers import AgentGraphRunner
Expand Down Expand Up @@ -38,14 +38,14 @@ def __init__(
self._graph = graph
self._runner = runner

async def run(self, input: Any) -> ManagedGraphResult:
async def run(self, input: str) -> ManagedGraphResult:
"""
Run the agent graph with the given input.

Delegates to the underlying AgentGraphRunner, then drives all
LaunchDarkly tracking from ``result.metrics``.

:param input: The input prompt or structured input for the graph
:param input: The user input prompt to process through the graph.
:return: ManagedGraphResult containing the content, metric summary,
and raw response.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Protocol, runtime_checkable
from typing import Protocol, runtime_checkable

from ldai.providers.types import AgentGraphRunnerResult

Expand All @@ -18,11 +18,11 @@ class AgentGraphRunner(Protocol):
the caller just passes input.
"""

async def run(self, input: Any) -> AgentGraphRunnerResult:
async def run(self, input: str) -> AgentGraphRunnerResult:
"""
Run the agent graph with the given input.

:param input: The input to the agent graph (string prompt or structured input)
:param input: The string prompt to send to the agent graph
:return: AgentGraphRunnerResult containing the content, raw response, and AIGraphMetrics
"""
...
Loading