Skip to content

Commit

Permalink
Revert "add logs for verify whether llm_metrics record cost successfu…
Browse files Browse the repository at this point in the history
…lly"

This reverts commit 28e6c27.
  • Loading branch information
Tingxi Lin committed Feb 20, 2025
1 parent 732d63d commit 1188d95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
34 changes: 14 additions & 20 deletions openhands/agenthub/codeact_agent/function_calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
FunctionCallNotExistsError,
FunctionCallValidationError,
)
from openhands.core.logger import openhands_logger as logger
from openhands.events.action import (
Action,
AgentDelegateAction,
Expand Down Expand Up @@ -541,26 +540,27 @@ def response_to_actions(response: ModelResponse) -> list[Action]:
raise FunctionCallValidationError(
f'Missing required argument "path" in tool call {tool_call.function.name}'
)
path = arguments['path']
command = arguments['command']
other_kwargs = {
k: v for k, v in arguments.items() if k not in ['command', 'path']
}

# We implement this in agent_skills, which can be used via Jupyter
# convert tool_call.function.arguments to kwargs that can be passed to file_editor
code = f'print(file_editor(**{arguments}))'
logger.debug(
f'TOOL CALL: str_replace_editor -> file_editor with code: {code}'
)

if arguments['command'] == 'view':
if command == 'view':
action = FileReadAction(
path=arguments['path'],
translated_ipython_code=code,
path=path,
impl_source=FileReadSource.OH_ACI,
view_range=other_kwargs.get('view_range', None),
)
else:
if 'view_range' in other_kwargs:
# Remove view_range from other_kwargs since it is not needed for FileEditAction
other_kwargs.pop('view_range')
action = FileEditAction(
path=arguments['path'],
content='', # dummy value -- we don't need it
translated_ipython_code=code,
path=path,
command=command,
impl_source=FileEditSource.OH_ACI,
**other_kwargs,
)
elif tool_call.function.name == 'browser':
if 'code' not in arguments:
Expand Down Expand Up @@ -590,12 +590,6 @@ def response_to_actions(response: ModelResponse) -> list[Action]:
total_calls_in_response=len(assistant_msg.tool_calls),
)
actions.append(action)

# Add logging for each created action
for action in actions:
accumulated_cost = action.llm_metrics.accumulated_cost if action.llm_metrics else None
logger.info(f"Action created - Accumulated Cost: {accumulated_cost}")
logger.info(f"Action type: {type(action)}")
else:
actions.append(
MessageAction(content=assistant_msg.content, wait_for_response=True)
Expand Down
4 changes: 0 additions & 4 deletions openhands/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ def update_state_before_step(self):
async def update_state_after_step(self):
# update metrics especially for cost. Use deepcopy to avoid it being modified by agent._reset()
self.state.local_metrics = copy.deepcopy(self.agent.llm.metrics)

# Add logging for metrics update
accumulated_cost = self.state.local_metrics.accumulated_cost if self.state.local_metrics else None
logger.info(f"After update_state_after_step - State Local Metrics Accumulated Cost: {accumulated_cost}")

async def _react_to_exception(
self,
Expand Down
4 changes: 0 additions & 4 deletions openhands/events/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ def unsubscribe(self, subscriber_id: EventStreamSubscriber, callback_id: str):
self._clean_up_subscriber(subscriber_id, callback_id)

def add_event(self, event: Event, source: EventSource):
# Add logs for accumulated cost debugging.
accumulated_cost = event.llm_metrics.accumulated_cost if event.llm_metrics else None
logger.info(f"Adding event to stream - Accumulated Cost: {accumulated_cost}")

if hasattr(event, '_id') and event.id is not None:
raise ValueError(
f'Event already has an ID:{event.id}. It was probably added back to the EventStream from inside a handler, triggering a loop.'
Expand Down

0 comments on commit 1188d95

Please sign in to comment.