Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/single_app/config.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,7 +95,7 @@
EXECUTOR_TYPE = 'thread'
EXECUTOR_MAX_WORKERS = 30
SESSION_TYPE = 'filesystem'
VERSION = "0.242.066"
VERSION = "0.242.068"

SESSION_COOKIE_SAMESITE = os.getenv('SESSION_COOKIE_SAMESITE', 'Lax')
SESSION_COOKIE_HTTPONLY = os.getenv('SESSION_COOKIE_HTTPONLY', 'true').lower() != 'false'
Expand Down
31 changes: 28 additions & 3 deletions application/single_app/route_backend_chats.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,7 @@
import queue
import re
import requests
import time
import traceback
from urllib.parse import urlparse
import threading
Expand DownExpand Up@@ -1098,6 +1099,8 @@ def _strip_agent_citation_artifact_refs(agent_citations):
TABULAR_RELATED_DOCUMENT_MAX_MATCHES_PER_ROW = 3
TABULAR_RELATED_DOCUMENT_MAX_SUMMARY_ROWS = 8
TABULAR_RELATED_DOCUMENT_MAX_EXCERPT_CHARS = 500
TABULAR_SK_ANALYSIS_MAX_CHARS = 100000
TABULAR_COMPUTED_RESULTS_HANDOFF_MAX_CHARS = 100000
TABULAR_GENERATED_OUTPUT_INTERNAL_ROW_FIELDS = {
'_matched_columns',
'_matched_values',
Expand DownExpand Up@@ -3661,8 +3664,13 @@ def build_tabular_related_document_evidence_summary(invocations):
def build_tabular_computed_results_system_message(source_label, tabular_analysis, related_document_evidence_summary=''):
"""Build the outer-model handoff message for successful tabular analysis."""
rendered_analysis = str(tabular_analysis or '').strip()
max_handoff_chars = 24000
max_handoff_chars = TABULAR_COMPUTED_RESULTS_HANDOFF_MAX_CHARS
if len(rendered_analysis) > max_handoff_chars:
original_length = len(rendered_analysis)
log_event(
f"[Tabular SK Analysis] Computed results handoff truncated from {original_length} to {max_handoff_chars} chars",
level=logging.WARNING,
)
rendered_analysis = (
rendered_analysis[:max_handoff_chars]
+ "\n[Computed results handoff truncated for prompt budget.]"
Expand DownExpand Up@@ -9376,6 +9384,7 @@ def build_system_prompt(force_tool_use=False, tool_error_messages=None,
return None

for attempt_number in range(1, 4):
attempt_started_at = time.monotonic()
force_tool_use = attempt_number > 1 or (attempt_number == 1 and analysis_requires_immediate_tool_choice)
if callable(thought_callback) and attempt_number > 1:
await emit_tabular_analysis_lifecycle_thought(
Expand DownExpand Up@@ -9494,13 +9503,24 @@ def build_system_prompt(force_tool_use=False, tool_error_messages=None,

if result and result[0].content:
analysis = result[0].content.strip()
if len(analysis) > 20000:
analysis = analysis[:20000] + "\n[Analysis truncated]"
if len(analysis) > TABULAR_SK_ANALYSIS_MAX_CHARS:
original_analysis_length = len(analysis)
log_event(
f"[Tabular SK Analysis] Attempt {attempt_number} analysis text truncated from {original_analysis_length} to {TABULAR_SK_ANALYSIS_MAX_CHARS} chars",
level=logging.WARNING,
)
analysis = analysis[:TABULAR_SK_ANALYSIS_MAX_CHARS] + "\n[Analysis truncated]"
attempt_elapsed_ms = int((time.monotonic() - attempt_started_at) * 1000)

if schema_summary_mode:
if successful_schema_summary_invocations:
log_event(
f"[Tabular SK Analysis] Schema summary complete via {len(successful_schema_summary_invocations)} workbook tool call(s) on attempt {attempt_number}",
extra={
'attempt_number': attempt_number,
'elapsed_ms': attempt_elapsed_ms,
'analysis_length': len(analysis),
},
level=logging.INFO,
)
return analysis
Expand DownExpand Up@@ -9601,6 +9621,11 @@ def build_system_prompt(force_tool_use=False, tool_error_messages=None,
previous_execution_gap_messages = []
log_event(
f"[Tabular SK Analysis] Analysis complete via {len(successful_analytical_invocations)} analytical tool call(s) on attempt {attempt_number}",
extra={
'attempt_number': attempt_number,
'elapsed_ms': attempt_elapsed_ms,
'analysis_length': len(analysis),
},
level=logging.INFO
)
return analysis
Expand Down
Loading
Loading