Skip to content

Commit d669bbe

Browse files
jsonbaileyclaude
andcommitted
feat!: narrow AgentGraphRunner.run input from Any to str
Aligns with Runner.run (already narrowed in #165) and with the JS AgentGraphRunner interface, which already takes string. The spec is being updated in parallel (sdk-specs#164). BREAKING CHANGE: AgentGraphRunner.run(input: Any) is now AgentGraphRunner.run(input: str). Callers must pass a str. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ffc40a7 commit d669bbe

4 files changed

Lines changed: 10 additions & 11 deletions

File tree

packages/ai-providers/server-ai-langchain/src/ldai_langchain/langgraph_agent_graph_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def route(state: WorkflowState) -> str:
274274
compiled = agent_builder.compile()
275275
return compiled, fn_name_to_config_key, node_keys
276276

277-
async def run(self, input: Any) -> AgentGraphRunnerResult:
277+
async def run(self, input: str) -> AgentGraphRunnerResult:
278278
"""
279279
Run the agent graph with the given input.
280280
@@ -295,7 +295,7 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
295295
handler = LDMetricsCallbackHandler(self._node_keys, self._fn_name_to_config_key)
296296

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

packages/ai-providers/server-ai-openai/src/ldai_openai/openai_agent_graph_runner.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(
6363
self._tool_name_map: Dict[str, str] = {}
6464
self._node_metrics: Dict[str, LDAIMetrics] = {}
6565

66-
async def run(self, input: Any) -> AgentGraphRunnerResult:
66+
async def run(self, input: str) -> AgentGraphRunnerResult:
6767
"""
6868
Run the agent graph with the given input.
6969
@@ -81,15 +81,14 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
8181
if root_key:
8282
path.append(root_key)
8383

84-
input_str = str(input)
8584
start_ns = time.perf_counter_ns()
8685
state = _RunState(last_handoff_ns=start_ns, last_node_key=root_key)
8786
try:
8887
from agents import Runner
8988
root_agent = self._build_agents(path, state)
9089
if root_key:
9190
self._node_metrics[root_key] = LDAIMetrics(success=False)
92-
result = await Runner.run(root_agent, input_str)
91+
result = await Runner.run(root_agent, input)
9392
self._flush_final_segment(state, result)
9493
self._collect_tool_calls(result)
9594

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""ManagedAgentGraph — LaunchDarkly managed wrapper for agent graph execution."""
22

3-
from typing import Any, Dict
3+
from typing import Dict
44

55
from ldai.agent_graph import AgentGraphDefinition
66
from ldai.providers import AgentGraphRunner
@@ -38,14 +38,14 @@ def __init__(
3838
self._graph = graph
3939
self._runner = runner
4040

41-
async def run(self, input: Any) -> ManagedGraphResult:
41+
async def run(self, input: str) -> ManagedGraphResult:
4242
"""
4343
Run the agent graph with the given input.
4444
4545
Delegates to the underlying AgentGraphRunner, then drives all
4646
LaunchDarkly tracking from ``result.metrics``.
4747
48-
:param input: The input prompt or structured input for the graph
48+
:param input: The user input prompt to process through the graph.
4949
:return: ManagedGraphResult containing the content, metric summary,
5050
and raw response.
5151
"""

packages/sdk/server-ai/src/ldai/providers/agent_graph_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Protocol, runtime_checkable
1+
from typing import Protocol, runtime_checkable
22

33
from ldai.providers.types import AgentGraphRunnerResult
44

@@ -18,11 +18,11 @@ class AgentGraphRunner(Protocol):
1818
the caller just passes input.
1919
"""
2020

21-
async def run(self, input: Any) -> AgentGraphRunnerResult:
21+
async def run(self, input: str) -> AgentGraphRunnerResult:
2222
"""
2323
Run the agent graph with the given input.
2424
25-
:param input: The input to the agent graph (string prompt or structured input)
25+
:param input: The string prompt to send to the agent graph
2626
:return: AgentGraphRunnerResult containing the content, raw response, and AIGraphMetrics
2727
"""
2828
...

0 commit comments

Comments
 (0)