akseljoonas HF Staff commited on
Commit
1de37c8
·
1 Parent(s): c5c099c

remove lmnr dependency

Browse files
agent/core/agent_loop.py CHANGED
@@ -9,7 +9,6 @@ import os
9
 
10
  from litellm import ChatCompletionMessageToolCall, Message, acompletion
11
  from litellm.exceptions import ContextWindowExceededError
12
- from lmnr import observe
13
 
14
  from agent.config import Config
15
  from agent.core.session import Event, OpType, Session
@@ -233,7 +232,6 @@ class Handlers:
233
  logger.info("Abandoned %d pending approval tool(s)", len(tool_calls))
234
 
235
  @staticmethod
236
- @observe(name="run_agent")
237
  async def run_agent(
238
  session: Session, text: str, max_iterations: int = 300
239
  ) -> str | None:
@@ -241,12 +239,6 @@ class Handlers:
241
  Handle user input (like user_input_or_turn in codex.rs:1291)
242
  Returns the final assistant response content, if any.
243
  """
244
- # Set session ID for this trace
245
- if hasattr(session, "session_id"):
246
- from lmnr import Laminar
247
-
248
- Laminar.set_trace_session_id(session_id=session.session_id)
249
-
250
  # Clear any stale cancellation flag from a previous run
251
  session.reset_cancel()
252
 
@@ -843,7 +835,6 @@ async def process_submission(session: Session, submission) -> bool:
843
  return True
844
 
845
 
846
- @observe(name="submission_loop")
847
  async def submission_loop(
848
  submission_queue: asyncio.Queue,
849
  event_queue: asyncio.Queue,
 
9
 
10
  from litellm import ChatCompletionMessageToolCall, Message, acompletion
11
  from litellm.exceptions import ContextWindowExceededError
 
12
 
13
  from agent.config import Config
14
  from agent.core.session import Event, OpType, Session
 
232
  logger.info("Abandoned %d pending approval tool(s)", len(tool_calls))
233
 
234
  @staticmethod
 
235
  async def run_agent(
236
  session: Session, text: str, max_iterations: int = 300
237
  ) -> str | None:
 
239
  Handle user input (like user_input_or_turn in codex.rs:1291)
240
  Returns the final assistant response content, if any.
241
  """
 
 
 
 
 
 
242
  # Clear any stale cancellation flag from a previous run
243
  session.reset_cancel()
244
 
 
835
  return True
836
 
837
 
 
838
  async def submission_loop(
839
  submission_queue: asyncio.Queue,
840
  event_queue: asyncio.Queue,
agent/core/tools.py CHANGED
@@ -12,7 +12,6 @@ logger = logging.getLogger(__name__)
12
 
13
  from fastmcp import Client
14
  from fastmcp.exceptions import ToolError
15
- from lmnr import observe
16
  from mcp.types import EmbeddedResource, ImageContent, TextContent
17
 
18
  from agent.config import MCPServerConfig
@@ -226,7 +225,6 @@ class ToolRouter:
226
  await self.mcp_client.__aexit__(exc_type, exc, tb)
227
  self._mcp_initialized = False
228
 
229
- @observe(name="call_tool")
230
  async def call_tool(
231
  self,
232
  tool_name: str,
 
12
 
13
  from fastmcp import Client
14
  from fastmcp.exceptions import ToolError
 
15
  from mcp.types import EmbeddedResource, ImageContent, TextContent
16
 
17
  from agent.config import MCPServerConfig
 
225
  await self.mcp_client.__aexit__(exc_type, exc, tb)
226
  self._mcp_initialized = False
227
 
 
228
  async def call_tool(
229
  self,
230
  tool_name: str,
agent/main.py CHANGED
@@ -10,7 +10,6 @@ from pathlib import Path
10
  from typing import Any, Optional
11
 
12
  import litellm
13
- from lmnr import Laminar, LaminarLiteLLMCallback
14
  from prompt_toolkit import PromptSession
15
 
16
  from agent.config import load_config
@@ -41,15 +40,6 @@ def _safe_get_args(arguments: dict) -> dict:
41
  return args if isinstance(args, dict) else {}
42
 
43
 
44
- lmnr_api_key = os.environ.get("LMNR_API_KEY")
45
- if lmnr_api_key:
46
- try:
47
- Laminar.initialize(project_api_key=lmnr_api_key)
48
- litellm.callbacks = [LaminarLiteLLMCallback()]
49
- print("Laminar initialized")
50
- except Exception as e:
51
- print(f"Failed to initialize Laminar: {e}")
52
-
53
 
54
  @dataclass
55
  class Operation:
 
10
  from typing import Any, Optional
11
 
12
  import litellm
 
13
  from prompt_toolkit import PromptSession
14
 
15
  from agent.config import load_config
 
40
  return args if isinstance(args, dict) else {}
41
 
42
 
 
 
 
 
 
 
 
 
 
43
 
44
  @dataclass
45
  class Operation:
eval/hf_agent_connector.py CHANGED
@@ -5,7 +5,6 @@ import sys
5
  from pathlib import Path
6
  from typing import Any
7
 
8
- from lmnr import observe
9
 
10
  from agent.config import Config, load_config
11
  from agent.core.agent_loop import Handlers
@@ -40,7 +39,6 @@ class AgentResponseGenerator:
40
  """Expose the agent model name for downstream logging."""
41
  return self.config.model_name
42
 
43
- @observe(name="eval_run")
44
  async def run(self, prompt: str) -> str:
45
  """
46
  Execute the agent loop for a single prompt and return the assistant reply.
 
5
  from pathlib import Path
6
  from typing import Any
7
 
 
8
 
9
  from agent.config import Config, load_config
10
  from agent.core.agent_loop import Handlers
 
39
  """Expose the agent model name for downstream logging."""
40
  return self.config.model_name
41
 
 
42
  async def run(self, prompt: str) -> str:
43
  """
44
  Execute the agent loop for a single prompt and return the assistant reply.
eval/solvers.py CHANGED
@@ -14,7 +14,6 @@ import litellm
14
  from inspect_ai.model import ChatMessageAssistant, ModelOutput
15
  from inspect_ai.solver import Solver, solver
16
  from inspect_ai.solver._task_state import TaskState
17
- from lmnr import Laminar, LaminarLiteLLMCallback
18
 
19
  from eval.hf_agent_connector import AgentResponseGenerator
20
 
@@ -39,10 +38,6 @@ def hf_agent(
39
  config_path: str = "agent/config_mcp_example.json",
40
  max_iterations: int = 10,
41
  ) -> Solver:
42
- # init lmnr for observability
43
- Laminar.initialize(project_api_key=os.environ.get("LMNR_API_KEY"))
44
- litellm.callbacks = [LaminarLiteLLMCallback()]
45
- print("✅ Laminar initialized")
46
 
47
  runner = AgentResponseGenerator(
48
  config_path=config_path,
 
14
  from inspect_ai.model import ChatMessageAssistant, ModelOutput
15
  from inspect_ai.solver import Solver, solver
16
  from inspect_ai.solver._task_state import TaskState
 
17
 
18
  from eval.hf_agent_connector import AgentResponseGenerator
19
 
 
38
  config_path: str = "agent/config_mcp_example.json",
39
  max_iterations: int = 10,
40
  ) -> Solver:
 
 
 
 
41
 
42
  runner = AgentResponseGenerator(
43
  config_path=config_path,
pyproject.toml CHANGED
@@ -18,7 +18,6 @@ agent = [
18
  "litellm>=1.0.0",
19
  "huggingface-hub>=1.0.1",
20
  "fastmcp>=2.4.0",
21
- "lmnr>=0.7.23", # Note: Using base package to avoid torch/transformers from [all] extra
22
  "prompt-toolkit>=3.0.0",
23
  "thefuzz>=0.22.1",
24
  "nbconvert>=7.16.6",
 
18
  "litellm>=1.0.0",
19
  "huggingface-hub>=1.0.1",
20
  "fastmcp>=2.4.0",
 
21
  "prompt-toolkit>=3.0.0",
22
  "thefuzz>=0.22.1",
23
  "nbconvert>=7.16.6",