Skip to content

Commit 7d6ad23

Browse files
authored
fix!: Remove stale ManagedModel message management and AgentGraphResult type (#170)
1 parent 6d1ce4c commit 7d6ad23

5 files changed

Lines changed: 8 additions & 60 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
ProviderConfig,
3333
)
3434
from ldai.providers import (
35-
AgentGraphResult,
3635
AgentGraphRunner,
3736
AgentGraphRunnerResult,
3837
GraphMetrics,
@@ -50,7 +49,6 @@
5049
'LDAIClient',
5150
'Evaluator',
5251
'AgentGraphRunner',
53-
'AgentGraphResult',
5452
'AgentGraphRunnerResult',
5553
'GraphMetrics',
5654
'GraphMetricSummary',

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

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import List
33

44
from ldai import log
5-
from ldai.models import AICompletionConfig, LDMessage
5+
from ldai.models import AICompletionConfig
66
from ldai.providers.runner import Runner
77
from ldai.providers.types import JudgeResult, ManagedResult, RunnerResult
88
from ldai.tracker import LDAIConfigTracker
@@ -12,9 +12,10 @@ class ManagedModel:
1212
"""
1313
LaunchDarkly managed wrapper for AI model invocations.
1414
15-
Holds a Runner. Handles conversation management, judge evaluation
16-
dispatch, and tracking automatically via ``create_tracker()``.
17-
Obtain an instance via ``LDAIClient.create_model()``.
15+
Holds a Runner. Handles judge evaluation dispatch and tracking
16+
automatically via ``create_tracker()``. Conversation history is
17+
managed by the runner. Obtain an instance via
18+
``LDAIClient.create_model()``.
1819
"""
1920

2021
def __init__(
@@ -24,37 +25,26 @@ def __init__(
2425
):
2526
self._ai_config = ai_config
2627
self._model_runner = model_runner
27-
self._messages: List[LDMessage] = []
2828

2929
async def run(self, prompt: str) -> ManagedResult:
3030
"""
3131
Run the model with a prompt string.
3232
33-
Appends the prompt to the conversation history, prepends any
34-
system messages from the config, delegates to the runner, and
35-
appends the response to the history.
33+
Delegates to the runner, then dispatches judge evaluations and
34+
records tracking metrics.
3635
3736
:param prompt: The user prompt to send to the model
3837
:return: ManagedResult containing the model's response, metric summary,
3938
and an optional evaluations task
4039
"""
4140
tracker = self._ai_config.create_tracker()
4241

43-
user_message = LDMessage(role='user', content=prompt)
44-
self._messages.append(user_message)
45-
4642
result: RunnerResult = await tracker.track_metrics_of_async(
4743
lambda r: r.metrics,
4844
lambda: self._model_runner.run(prompt),
4945
)
5046

51-
assistant_message = LDMessage(role='assistant', content=result.content)
52-
53-
input_text = '\r\n'.join(m.content for m in self._messages) if self._messages else ''
54-
55-
evaluations_task = self._track_judge_results(tracker, input_text, result.content)
56-
57-
self._messages.append(assistant_message)
47+
evaluations_task = self._track_judge_results(tracker, prompt, result.content)
5848

5949
return ManagedResult(
6050
content=result.content,
@@ -88,25 +78,6 @@ async def _run_and_track(eval_task: asyncio.Task) -> List[JudgeResult]:
8878

8979
return asyncio.create_task(_run_and_track(evaluator_task))
9080

91-
def get_messages(self, include_config_messages: bool = False) -> List[LDMessage]:
92-
"""
93-
Get all messages in the conversation history.
94-
95-
:param include_config_messages: When True, prepends config messages.
96-
:return: List of conversation messages.
97-
"""
98-
if include_config_messages:
99-
return (self._ai_config.messages or []) + self._messages
100-
return list(self._messages)
101-
102-
def append_messages(self, messages: List[LDMessage]) -> None:
103-
"""
104-
Append messages to the conversation history without invoking the model.
105-
106-
:param messages: Messages to append.
107-
"""
108-
self._messages.extend(messages)
109-
11081
def get_model_runner(self) -> Runner:
11182
"""
11283
Return the underlying runner for advanced use.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from ldai.providers.runner import Runner
44
from ldai.providers.runner_factory import RunnerFactory
55
from ldai.providers.types import (
6-
AgentGraphResult,
76
AgentGraphRunnerResult,
87
GraphMetrics,
98
GraphMetricSummary,
@@ -17,7 +16,6 @@
1716

1817
__all__ = [
1918
'AIProvider',
20-
'AgentGraphResult',
2119
'AgentGraphRunner',
2220
'AgentGraphRunnerResult',
2321
'GraphMetrics',

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,3 @@ def to_dict(self) -> Dict[str, Any]:
204204
if self.error_message is not None:
205205
result['errorMessage'] = self.error_message
206206
return result
207-
208-
209-
@dataclass
210-
class AgentGraphResult:
211-
"""Contains the result of an agent graph run."""
212-
213-
output: str
214-
"""The agent graph's final output content."""
215-
216-
raw: Any
217-
"""The provider-native response object from the graph run."""
218-
219-
metrics: LDAIMetrics
220-
"""Metrics recorded during the graph run."""
221-
222-
evaluations: Optional[List[JudgeResult]] = None
223-
"""Optional list of judge evaluation results produced for the graph run."""

packages/sdk/server-ai/tests/test_runner_abcs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22

33
from ldai.providers import (
4-
AgentGraphResult,
54
AgentGraphRunner,
65
AgentGraphRunnerResult,
76
ToolRegistry,
@@ -78,6 +77,5 @@ def test_tool_registry_is_dict_of_callables():
7877
def test_top_level_exports():
7978
import ldai
8079
assert hasattr(ldai, 'AgentGraphRunner')
81-
assert hasattr(ldai, 'AgentGraphResult')
8280
assert hasattr(ldai, 'RunnerResult')
8381
assert hasattr(ldai, 'ToolRegistry')

0 commit comments

Comments
 (0)