diff --git a/apptrace/src/monocle_apptrace/instrumentation/metamodel/openai/_helper.py b/apptrace/src/monocle_apptrace/instrumentation/metamodel/openai/_helper.py index 91f45d5d0..30a5508d8 100644 --- a/apptrace/src/monocle_apptrace/instrumentation/metamodel/openai/_helper.py +++ b/apptrace/src/monocle_apptrace/instrumentation/metamodel/openai/_helper.py @@ -19,7 +19,7 @@ map_openai_finish_reason_to_finish_type, OPENAI_FINISH_REASON_MAPPING ) -from monocle_apptrace.instrumentation.common.constants import AGENT_PREFIX_KEY, INFERENCE_AGENT_DELEGATION, INFERENCE_TURN_END, INFERENCE_TOOL_CALL +from monocle_apptrace.instrumentation.common.constants import AGENT_PREFIX_KEY, INFERENCE_AGENT_DELEGATION, INFERENCE_TURN_END, INFERENCE_TOOL_CALL, TOOL_TYPE from contextlib import suppress logger = logging.getLogger(__name__) @@ -427,7 +427,7 @@ def extract_tool_type(arguments): tool_call = _get_first_tool_call(response) if tool_call: # Return generic tool type for OpenAI tools - return "tool.openai" + return TOOL_TYPE except Exception as e: logger.warning("Warning: Error occurred in extract_tool_type: %s", str(e)) diff --git a/apptrace/tests/integration/test_openai_finish_reason_integration.py b/apptrace/tests/integration/test_openai_finish_reason_integration.py index ac25ba068..3c2fb322d 100644 --- a/apptrace/tests/integration/test_openai_finish_reason_integration.py +++ b/apptrace/tests/integration/test_openai_finish_reason_integration.py @@ -174,7 +174,7 @@ def test_finish_reason_function_call(setup): assert "entity.3.name" in span_attributes, "entity.3.name should be present when finish_type is tool_call" assert "entity.3.type" in span_attributes, "entity.3.type should be present when finish_type is tool_call" assert span_attributes["entity.3.name"] == "get_current_weather", f"Expected tool name 'get_current_weather', got '{span_attributes.get('entity.3.name')}'" - assert span_attributes["entity.3.type"] == "tool.openai", f"Expected tool type 'tool.openai', got '{span_attributes.get('entity.3.type')}'" + assert span_attributes["entity.3.type"] == "tool.function", f"Expected tool type 'tool.function', got '{span_attributes.get('entity.3.type')}'" if __name__ == "__main__":