fix: replace all 'PRODUCTION' references with 'prod' for consistency (#6627)

* fix: replace all 'PRODUCTION' references with 'prod' for consistency

Problem: Codebase had 11 references to 'PRODUCTION' (uppercase) that should
use 'prod' (lowercase) for consistency with the deployment workflows and
environment normalization.

Changes across 8 files:

1. Source files (using settings.environment):
   - letta/functions/function_sets/multi_agent.py
   - letta/services/tool_manager.py
   - letta/services/tool_executor/multi_agent_tool_executor.py
   - letta/services/helpers/agent_manager_helper.py
   All checks changed from: settings.environment == "PRODUCTION"
   To: settings.environment == "prod"

2. OTEL resource configuration:
   - letta/otel/resource.py
     - Updated _normalize_environment_tag() to handle 'prod' directly
     - Removed 'PRODUCTION' -> 'prod' mapping (no longer needed)
     - Updated device.id check from _env != "PRODUCTION" to _env != "prod"

3. Test files:
   - tests/managers/conftest.py
     - Fixture parameter changed from "PRODUCTION" to "prod"
   - tests/managers/test_agent_manager.py (3 occurrences)
   - tests/managers/test_tool_manager.py (2 occurrences)
   All test checks changed to use "prod"

Result: Complete consistency across the codebase:
- All environment checks use "prod" instead of "PRODUCTION"
- Normalization function simplified (no special case for PRODUCTION)
- Tests use correct "prod" value
- Matches deployment workflow configuration from PR #6626

This completes the environment naming standardization effort.

* fix: update settings.py environment description to use 'prod' instead of 'PRODUCTION'

The field description still referenced PRODUCTION as an example value.
Updated to use lowercase 'prod' for consistency with actual usage.

Before: "Application environment (PRODUCTION, DEV, CANARY, etc. - normalized to lowercase for OTEL tags)"
After: "Application environment (prod, dev, canary, etc. - lowercase values used for OTEL tags)"
This commit is contained in:
Kian Jones
2025-12-10 17:16:10 -08:00
committed by Caren Thomas
parent 08ccc8b399
commit fbd89c9360
9 changed files with 22 additions and 22 deletions

View File

@@ -773,7 +773,7 @@ def dummy_successful_response() -> BetaMessageBatchIndividualResponse:
# ======================================================================================================================
@pytest.fixture(params=[None, "PRODUCTION"])
@pytest.fixture(params=[None, "prod"])
def set_letta_environment(request, monkeypatch):
"""Parametrized fixture to test with different environment settings."""
from letta.settings import settings

View File

@@ -256,7 +256,7 @@ async def test_calculate_multi_agent_tools(set_letta_environment):
"""Test that calculate_multi_agent_tools excludes local-only tools in production."""
result = calculate_multi_agent_tools()
if settings.environment == "PRODUCTION":
if settings.environment == "prod":
# Production environment should exclude local-only tools
expected_tools = set(MULTI_AGENT_TOOLS) - set(LOCAL_ONLY_MULTI_AGENT_TOOLS)
assert result == expected_tools, "Production should exclude local-only multi-agent tools"
@@ -283,7 +283,7 @@ async def test_upsert_base_tools_excludes_local_only_in_production(server: SyncS
tools = await server.tool_manager.upsert_base_tools_async(actor=default_user)
tool_names = {tool.name for tool in tools}
if settings.environment == "PRODUCTION":
if settings.environment == "prod":
# Production environment should exclude local-only multi-agent tools
for local_only_tool in LOCAL_ONLY_MULTI_AGENT_TOOLS:
assert local_only_tool not in tool_names, f"Local-only tool '{local_only_tool}' should not be upserted in production"
@@ -306,7 +306,7 @@ async def test_upsert_multi_agent_tools_only(server: SyncServer, default_user, s
tools = await server.tool_manager.upsert_base_tools_async(actor=default_user, allowed_types={ToolType.LETTA_MULTI_AGENT_CORE})
tool_names = {tool.name for tool in tools}
if settings.environment == "PRODUCTION":
if settings.environment == "prod":
# Should only have non-local multi-agent tools
expected_tools = set(MULTI_AGENT_TOOLS) - set(LOCAL_ONLY_MULTI_AGENT_TOOLS)
assert tool_names == expected_tools, "Production multi-agent upsert should exclude local-only tools"

View File

@@ -1278,7 +1278,7 @@ async def test_upsert_base_tools(server: SyncServer, default_user):
tools = await server.tool_manager.upsert_base_tools_async(actor=default_user)
# Calculate expected tools accounting for production filtering
if settings.environment == "PRODUCTION":
if settings.environment == "prod":
expected_tool_names = sorted(LETTA_TOOL_SET - set(LOCAL_ONLY_MULTI_AGENT_TOOLS))
else:
expected_tool_names = sorted(LETTA_TOOL_SET)
@@ -1330,7 +1330,7 @@ async def test_upsert_filtered_base_tools(server: SyncServer, default_user, tool
tool_names = sorted([t.name for t in tools])
# Adjust expected names for multi-agent tools in production
if tool_type == ToolType.LETTA_MULTI_AGENT_CORE and settings.environment == "PRODUCTION":
if tool_type == ToolType.LETTA_MULTI_AGENT_CORE and settings.environment == "prod":
expected_sorted = sorted(set(expected_names) - set(LOCAL_ONLY_MULTI_AGENT_TOOLS))
else:
expected_sorted = sorted(expected_names)