diff --git a/ddtrace/llmobs/_integrations/langchain.py b/ddtrace/llmobs/_integrations/langchain.py index d327304a8fb..de970144082 100644 --- a/ddtrace/llmobs/_integrations/langchain.py +++ b/ddtrace/llmobs/_integrations/langchain.py @@ -916,7 +916,6 @@ def handle_prompt_template_invoke(self, instance, result, args: List[Any], kwarg "template": template, "chat_template": chat_template, "id": prompt_id if prompt_id is not None else "unknown", - "version": "0.0.0", "rag_context_variables": [], "rag_query_variables": [], "tags": tags, diff --git a/releasenotes/notes/fix-langchain-auto-prompt-version-983dd20c5f070f9f.yaml b/releasenotes/notes/fix-langchain-auto-prompt-version-983dd20c5f070f9f.yaml new file mode 100644 index 00000000000..c96a1fe2106 --- /dev/null +++ b/releasenotes/notes/fix-langchain-auto-prompt-version-983dd20c5f070f9f.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + langchain: This fix resolves an issue where auto instrumented prompt templates incorrectly included a + ``version`` field. The version field is now omitted unless explicitly set by the user. diff --git a/tests/contrib/langchain/test_langchain_llmobs.py b/tests/contrib/langchain/test_langchain_llmobs.py index 80de493af35..970457d690f 100644 --- a/tests/contrib/langchain/test_langchain_llmobs.py +++ b/tests/contrib/langchain/test_langchain_llmobs.py @@ -414,7 +414,6 @@ def test_llmobs_chain(langchain_core, langchain_openai, openai_url, llmobs_event {"content": "{input}", "role": "user"}, ], "variables": {"input": "Can you explain what an LLM chain is?"}, - "version": "0.0.0", "_dd_context_variable_keys": ["context"], "_dd_query_variable_keys": ["question"], }, @@ -456,7 +455,6 @@ def test_llmobs_chain_nested(langchain_core, langchain_openai, openai_url, llmob "id": "langchain.unknown_prompt_template", "chat_template": [{"content": "what is the city {person} is from?", "role": "user"}], "variables": {"person": "Spongebob Squarepants", "language": "Spanish"}, - "version": "0.0.0", "_dd_context_variable_keys": ["context"], "_dd_query_variable_keys": ["question"], }, @@ -469,7 +467,6 @@ def test_llmobs_chain_nested(langchain_core, langchain_openai, openai_url, llmob "id": "test_langchain_llmobs.prompt2", "chat_template": [{"content": "what country is the city {city} in? respond in {language}", "role": "user"}], "variables": {"city": mock.ANY, "language": "Spanish"}, - "version": "0.0.0", "_dd_context_variable_keys": ["context"], "_dd_query_variable_keys": ["question"], }, @@ -505,7 +502,6 @@ def test_llmobs_chain_batch(langchain_core, langchain_openai, llmobs_events, tra "id": "langchain.unknown_prompt_template", "chat_template": [{"content": "Tell me a short joke about {topic}", "role": "user"}], "variables": {"topic": "chickens"}, - "version": "0.0.0", "_dd_context_variable_keys": ["context"], "_dd_query_variable_keys": ["question"], }, @@ -519,7 +515,6 @@ def test_llmobs_chain_batch(langchain_core, langchain_openai, llmobs_events, tra "id": "langchain.unknown_prompt_template", "chat_template": [{"content": "Tell me a short joke about {topic}", "role": "user"}], "variables": {"topic": "pigs"}, - "version": "0.0.0", "_dd_context_variable_keys": ["context"], "_dd_query_variable_keys": ["question"], }, @@ -534,7 +529,6 @@ def test_llmobs_chain_batch(langchain_core, langchain_openai, llmobs_events, tra "id": "langchain.unknown_prompt_template", "chat_template": [{"content": "Tell me a short joke about {topic}", "role": "user"}], "variables": {"topic": "chickens"}, - "version": "0.0.0", "_dd_context_variable_keys": ["context"], "_dd_query_variable_keys": ["question"], }, @@ -548,7 +542,6 @@ def test_llmobs_chain_batch(langchain_core, langchain_openai, llmobs_events, tra "id": "langchain.unknown_prompt_template", "chat_template": [{"content": "Tell me a short joke about {topic}", "role": "user"}], "variables": {"topic": "pigs"}, - "version": "0.0.0", "_dd_context_variable_keys": ["context"], "_dd_query_variable_keys": ["question"], },