Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-3136 [FIX] Skip thinking config for Vertex AI pro models when disabled (#1775)

Praveen Kumar89f7e29ed403
diff --git a/backend/sample.env b/backend/sample.env
index 5413c2c5c..d71af7771 100644
--- a/backend/sample.env
+++ b/backend/sample.env
@@ -89,9 +89,9 @@ PROMPT_STUDIO_FILE_PATH=/app/prompt-studio-data
# Structure Tool Image (Runs prompt studio exported tools)
# https://hub.docker.com/r/unstract/tool-structure
-STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.96"
+STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.97"
STRUCTURE_TOOL_IMAGE_NAME="unstract/tool-structure"
-STRUCTURE_TOOL_IMAGE_TAG="0.0.96"
+STRUCTURE_TOOL_IMAGE_TAG="0.0.97"
# Feature Flags
EVALUATION_SERVER_IP=unstract-flipt
diff --git a/tools/classifier/src/config/properties.json b/tools/classifier/src/config/properties.json
index 59de97a7b..4685282de 100644
--- a/tools/classifier/src/config/properties.json
+++ b/tools/classifier/src/config/properties.json
@@ -2,7 +2,7 @@
"schemaVersion": "0.0.1",
"displayName": "File Classifier",
"functionName": "classify",
- "toolVersion": "0.0.75",
+ "toolVersion": "0.0.76",
"description": "Classifies a file into a bin based on its contents",
"input": {
"description": "File to be classified"
diff --git a/tools/structure/src/config/properties.json b/tools/structure/src/config/properties.json
index f81259ab4..8144c8b64 100644
--- a/tools/structure/src/config/properties.json
+++ b/tools/structure/src/config/properties.json
@@ -2,7 +2,7 @@
"schemaVersion": "0.0.1",
"displayName": "Structure Tool",
"functionName": "structure_tool",
- "toolVersion": "0.0.96",
+ "toolVersion": "0.0.97",
"description": "This is a template tool which can answer set of input prompts designed in the Prompt Studio",
"input": {
"description": "File that needs to be indexed and parsed for answers"
diff --git a/tools/text_extractor/src/config/properties.json b/tools/text_extractor/src/config/properties.json
index e2c9a0b42..1c2c4dafc 100644
--- a/tools/text_extractor/src/config/properties.json
+++ b/tools/text_extractor/src/config/properties.json
@@ -2,7 +2,7 @@
"schemaVersion": "0.0.1",
"displayName": "Text Extractor",
"functionName": "text_extractor",
- "toolVersion": "0.0.71",
+ "toolVersion": "0.0.72",
"description": "The Text Extractor is a powerful tool designed to convert documents to its text form or Extract texts from documents",
"input": {
"description": "Document"
diff --git a/unstract/sdk1/src/unstract/sdk1/adapters/base1.py b/unstract/sdk1/src/unstract/sdk1/adapters/base1.py
index 85cdd4e84..7a578d486 100644
--- a/unstract/sdk1/src/unstract/sdk1/adapters/base1.py
+++ b/unstract/sdk1/src/unstract/sdk1/adapters/base1.py
@@ -321,6 +321,31 @@ class VertexAILLMParameters(BaseChatCompletionParameters):
vertex_project: str
safety_settings: list[dict[str, str]]
+ @staticmethod
+ def _get_thinking_config(
+ metadata: dict[str, "Any"], enable_thinking: bool, has_existing: bool
+ ) -> dict[str, "Any"] | None:
+ """Build thinking configuration for Vertex AI models.
+
+ Returns None if thinking should not be sent (pro models with disabled).
+ """
+ if enable_thinking:
+ if has_existing:
+ return metadata["thinking"]
+ config = {"type": "enabled"}
+ budget = metadata.get("budget_tokens")
+ if budget is not None:
+ config["budget_tokens"] = budget
+ return config
+
+ # Pro models don't allow disabling thinking with budget_tokens=0
+ model_name = metadata.get("model", "").lower()
+ if "pro" in model_name:
+ return None
+
+ # Non-pro models support disabling thinking with budget_tokens=0
+ return {"type": "disabled", "budget_tokens": 0}
+
@staticmethod
def validate(adapter_metadata: dict[str, "Any"]) -> dict[str, "Any"]:
# Make a copy so we don't modify the original
@@ -340,8 +365,7 @@ class VertexAILLMParameters(BaseChatCompletionParameters):
# Handle Vertex AI thinking configuration (for Gemini models)
enable_thinking = metadata_copy.get("enable_thinking", False)
- # If enable_thinking is not explicitly provided but thinking config is present,
- # assume thinking was enabled in a previous validation
+ # If enable_thinking is not explicitly provided but thinking config exists
has_thinking_config = (
"thinking" in metadata_copy and metadata_copy.get("thinking") is not None
)
@@ -351,21 +375,14 @@ class VertexAILLMParameters(BaseChatCompletionParameters):
# Create a copy to avoid mutating the original metadata
result_metadata = metadata_copy.copy()
- if enable_thinking:
- if has_thinking_config:
- # Preserve existing thinking config
- result_metadata["thinking"] = metadata_copy["thinking"]
- else:
- # Create new thinking config for enabled state
- thinking_config = {"type": "enabled"}
- budget_tokens = metadata_copy.get("budget_tokens")
- if budget_tokens is not None:
- thinking_config["budget_tokens"] = budget_tokens
- result_metadata["thinking"] = thinking_config
+ # Get thinking config (may be None for pro models with thinking disabled)
+ thinking_config = VertexAILLMParameters._get_thinking_config(
+ metadata_copy, enable_thinking, has_thinking_config
+ )
+ if thinking_config is not None:
+ result_metadata["thinking"] = thinking_config
+ if enable_thinking and not has_thinking_config:
result_metadata["temperature"] = 1
- else:
- # Vertex AI requires explicit disabled state with budget 0
- result_metadata["thinking"] = {"type": "disabled", "budget_tokens": 0}
# Handle safety settings
ss_dict = result_metadata.get("safety_settings", {})
@@ -423,8 +440,9 @@ class VertexAILLMParameters(BaseChatCompletionParameters):
if field in result_metadata and field not in validated_data:
validated_data[field] = result_metadata[field]
- # Always add thinking config to final result (either enabled or disabled)
- validated_data["thinking"] = result_metadata["thinking"]
+ # Add thinking config only when present (not set for pro models with disabled)
+ if "thinking" in result_metadata:
+ validated_data["thinking"] = result_metadata["thinking"]
return validated_data
diff --git a/unstract/tool-registry/tool_registry_config/public_tools.json b/unstract/tool-registry/tool_registry_config/public_tools.json
index 505fa559d..fbb927513 100644
--- a/unstract/tool-registry/tool_registry_config/public_tools.json
+++ b/unstract/tool-registry/tool_registry_config/public_tools.json
@@ -5,7 +5,7 @@
"schemaVersion": "0.0.1",
"displayName": "File Classifier",
"functionName": "classify",
- "toolVersion": "0.0.75",
+ "toolVersion": "0.0.76",
"description": "Classifies a file into a bin based on its contents",
"input": {
"description": "File to be classified"
@@ -106,9 +106,9 @@
"properties": {}
},
"icon": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n enable-background=\"new 0 0 20 20\"\n height=\"48\"\n viewBox=\"0 0 20 20\"\n width=\"48\"\n fill=\"#000000\"\n version=\"1.1\"\n id=\"svg8109\"\n sodipodi:docname=\"folder_copy_black_48dp.svg\"\n xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <defs\n id=\"defs8113\" />\n <sodipodi:namedview\n id=\"namedview8111\"\n pagecolor=\"#ffffff\"\n bordercolor=\"#000000\"\n borderopacity=\"0.25\"\n inkscape:showpageshadow=\"2\"\n inkscape:pageopacity=\"0.0\"\n inkscape:pagecheckerboard=\"0\"\n inkscape:deskcolor=\"#d1d1d1\"\n showgrid=\"false\" />\n <g\n id=\"g8099\">\n <rect\n fill=\"none\"\n height=\"20\"\n width=\"20\"\n x=\"0\"\n id=\"rect8097\"\n y=\"0\" />\n </g>\n <g\n id=\"g8107\"\n style=\"fill:#ff4d6d;fill-opacity:1\">\n <g\n id=\"g8105\"\n style=\"fill:#ff4d6d;fill-opacity:1\">\n <path\n d=\"M 2.5,5 H 1 V 15.5 C 1,16.33 1.67,17 2.5,17 H 15.68 V 15.5 H 2.5 Z\"\n id=\"path8101\"\n style=\"fill:#ff4d6d;fill-opacity:1\" />\n <path\n d=\"M 16.5,4 H 11 L 9,2 H 5.5 C 4.67,2 4,2.67 4,3.5 v 9 C 4,13.33 4.67,14 5.5,14 h 11 c 0.83,0 1.5,-0.67 1.5,-1.5 v -7 C 18,4.67 17.33,4 16.5,4 Z m 0,8.5 h -11 v -9 h 2.88 l 2,2 h 6.12 z\"\n id=\"path8103\"\n style=\"fill:#ff4d6d;fill-opacity:1\" />\n </g>\n </g>\n</svg>\n",
- "image_url": "docker:unstract/tool-classifier:0.0.75",
+ "image_url": "docker:unstract/tool-classifier:0.0.76",
"image_name": "unstract/tool-classifier",
- "image_tag": "0.0.75"
+ "image_tag": "0.0.76"
},
"text_extractor": {
"tool_uid": "text_extractor",
@@ -116,7 +116,7 @@
"schemaVersion": "0.0.1",
"displayName": "Text Extractor",
"functionName": "text_extractor",
- "toolVersion": "0.0.71",
+ "toolVersion": "0.0.72",
"description": "The Text Extractor is a powerful tool designed to convert documents to its text form or Extract texts from documents",
"input": {
"description": "Document"
@@ -191,8 +191,8 @@
}
},
"icon": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n enable-background=\"new 0 0 20 20\"\n height=\"48\"\n viewBox=\"0 0 20 20\"\n width=\"48\"\n fill=\"#000000\"\n version=\"1.1\"\n id=\"svg8109\"\n sodipodi:docname=\"folder_copy_black_48dp.svg\"\n xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <defs\n id=\"defs8113\" />\n <sodipodi:namedview\n id=\"namedview8111\"\n pagecolor=\"#ffffff\"\n bordercolor=\"#000000\"\n borderopacity=\"0.25\"\n inkscape:showpageshadow=\"2\"\n inkscape:pageopacity=\"0.0\"\n inkscape:pagecheckerboard=\"0\"\n inkscape:deskcolor=\"#d1d1d1\"\n showgrid=\"false\" />\n <g\n id=\"g8099\">\n <rect\n fill=\"none\"\n height=\"20\"\n width=\"20\"\n x=\"0\"\n id=\"rect8097\"\n y=\"0\" />\n </g>\n <g\n id=\"g8107\"\n style=\"fill:#ff4d6d;fill-opacity:1\">\n <g\n id=\"g8105\"\n style=\"fill:#ff4d6d;fill-opacity:1\">\n <path\n d=\"M 2.5,5 H 1 V 15.5 C 1,16.33 1.67,17 2.5,17 H 15.68 V 15.5 H 2.5 Z\"\n id=\"path8101\"\n style=\"fill:#ff4d6d;fill-opacity:1\" />\n <path\n d=\"M 16.5,4 H 11 L 9,2 H 5.5 C 4.67,2 4,2.67 4,3.5 v 9 C 4,13.33 4.67,14 5.5,14 h 11 c 0.83,0 1.5,-0.67 1.5,-1.5 v -7 C 18,4.67 17.33,4 16.5,4 Z m 0,8.5 h -11 v -9 h 2.88 l 2,2 h 6.12 z\"\n id=\"path8103\"\n style=\"fill:#ff4d6d;fill-opacity:1\" />\n </g>\n </g>\n</svg>\n",
- "image_url": "docker:unstract/tool-text-extractor:0.0.71",
+ "image_url": "docker:unstract/tool-text-extractor:0.0.72",
"image_name": "unstract/tool-text-extractor",
- "image_tag": "0.0.71"
+ "image_tag": "0.0.72"
}
}