Skip to content

[Bug] Getting tsquery error when texting a table to agent #3737

@lyzhang0113

Description

@lyzhang0113

Contact Information

No response

MaxKB Version

v1.10.8-lts (build at 2025-05-22T22:33, commit: decd339)

Problem Description

An error "tsquery stack too small" was returned when I send a table to a simple chat agent that is using:
Embedded: gemini-embedding-exp-03-07
LLM: Azure OpenAI gpt-4.1-mini

Steps to Reproduce

The following table is sent to a simple chat agent and got "tsquery stack too small".

| Application Name       | Version             | Product GUID                          |
|-----------------------|---------------------|-------------------------------------|
| ***Redacted***     | ***Redacted*** (older version) | {bd2908bb-***Redacted***-193adb38cd63} |
| ***Redacted***   | ***Redacted***               | {0F961540-***Redacted***-7C25504E54D6} |
| ***Redacted***     | ***Redacted*** (latest)   | {0BBD3CC1-6***Redacted***-6A3BA40DDD0A} |

The expected correct result

No response

Related log output

172.17.0.1 [25/Jul/2025:10:09:42 +0800] 0.701905s "POST /api/application/chat_message/6cc0d56e-68fc-11f0-9899-9641ae7c4924 HTTP/1.0" 200 67
2025-07-25 10:10:09 [handle_exception ERROR] tsquery stack too small
:Traceback (most recent call last):
  File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.InternalError_: tsquery stack too small


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/py3/lib/python3.11/site-packages/rest_framework/views.py", line 512, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/common/auth/authentication.py", line 93, in run
    return func(view, request, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/application/views/chat_views.py", line 155, in post
    ).chat()
      ^^^^^^
  File "/opt/maxkb/app/apps/application/serializers/chat_message_serializers.py", line 416, in chat
    return self.chat_simple(chat_info, base_to_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/application/serializers/chat_message_serializers.py", line 361, in chat_simple
    pipeline_message.run(params)
  File "/opt/maxkb/app/apps/application/chat_pipeline/pipeline_manage.py", line 33, in run
    step.run(self)
  File "/opt/maxkb/app/apps/application/chat_pipeline/I_base_chat_pipeline.py", line 143, in run
    self._run(manage)
  File "/opt/maxkb/app/apps/application/chat_pipeline/step/search_dataset_step/i_search_dataset_step.py", line 54, in _run
    paragraph_list = self.execute(**self.context['step_args'])
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/application/chat_pipeline/step/search_dataset_step/impl/base_search_dataset_step.py", line 63, in execute
    embedding_list = vector.query(exec_problem_text, embedding_value, dataset_id_list, exclude_document_id_list,
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/embedding/vector/pg_vector.py", line 111, in query
    return search_handle.handle(query_set, query_text, query_embedding, top_n, similarity, search_mode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/embedding/vector/pg_vector.py", line 214, in handle
    embedding_model = select_list(exec_sql,
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/common/db/sql_execute.py", line 51, in select_list
    result_list = sql_execute(sql, params)
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb/app/apps/common/db/sql_execute.py", line 22, in sql_execute
    cursor.execute(sql, params)
  File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/opt/py3/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.InternalError: tsquery stack too small


172.17.0.1 [25/Jul/2025:10:10:09 +0800] 0.965211s "POST /api/application/chat_message/6cc0d56e-68fc-11f0-9899-9641ae7c4924 HTTP/1.0" 200 67

Additional Information

Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions