Commit Graph
20 Commits
Author SHA1 Message Date
Davide Silvestri f5bc919473 feat(celery): make every task work on a threads worker, and use one in dev (#6926)
* chore(dev): run one threads Celery worker with beat in dev

The Docker and native dev stacks start a single Celery worker for every
queue, with redbeat embedded, instead of a worker, an export worker and a
beat process. It uses a new ThreadsPool that sends worker_process_init, so
telemetry and the lazy import check still run under the threads pool.

* fix(ws): stop closing every event loop's Redis pools after a broadcast

send_messages_to_channel_group called channel_layer.close_pools(), which
closes the pools of every event loop, including the ones other worker
threads are still sending with. Under the threads pool about a third of
broadcasts failed with "attached to a different loop" and some hung.
channels_redis now closes a loop's pools itself when that loop closes.

* fix(telemetry): keep Celery trace context per thread on threads workers

The Celery instrumentation keys a running task's span, context token and start
time by the task's id. A task replaced with self.replace(), like every
automation node, keeps its id, and on a threads worker the replacement can
start in another thread before the original ends. The original then ended the
replacement's span and detached its context from the wrong thread, logging
"Failed to detach context" and leaving its own context on the thread. That
state is now kept per thread.

* feat(celery): enforce soft and hard time limits in ThreadsPool

Celery's own threads pool ignores soft_time_limit and time_limit, so on a
threads worker tasks that rely on them would run on. ThreadsPool now raises
the limit in the task's thread, only while that task runs, so a limit never
reaches the next task of the thread. EMAIL_TIMEOUT stops a silent SMTP server
from blocking a worker thread forever.

* fix(chat-runs): cancel a run that keeps going after its deadline

The deadline only asks a run to stop. A run whose tools or provider call
ignore that request now gets 60 more seconds, is then cancelled, and is saved
as timed out. Celery's limit moves after that, so the run's own stop always
comes first. On a threads worker this is the only way to end it, because a
time limit can't reach a thread waiting inside async_to_sync.

* fix(premium): share one capped thread pool across AI field generations

Each generation started its own pool of
BASEROW_AI_FIELD_MAX_CONCURRENT_GENERATIONS threads, so a threads worker
running several jobs multiplied the threads and model calls. All generations
in a process now share one pool of that size. A prefork process runs one job
at a time, so nothing changes there.

* feat(celery): cancel queries at the hard limit and report overdue tasks

ThreadsPool checks every running task's time limits from one watchdog thread,
like the prefork pool's timeout handler, instead of starting timer threads
for each task. At the hard limit it also cancels the query the task's thread
is running, which the limit's exception can't interrupt.

A thread can't be killed, so a task still running 60 seconds after its hard
limit is reported to Sentry instead. Every limit reached is counted in
baserow.celery.task.time_limit, per task and limit.

* fix(airtable): time out requests to Airtable

Two Airtable import requests had no timeout, so a server that stopped
answering held the import, and on a threads worker its thread, forever. All
Airtable requests now use the same 3 minute read timeout.

* fix(celery): load sentry_sdk only when reporting an overdue task

The overdue report imported sentry_sdk at the top of baserow.config.celery,
which every process imports, so it was loaded even with Sentry off.

* chore: add a changelog entry for the Celery task timeouts

* fix(celery): raise threads pool time limits at the task's next query

An exception raised into a thread from outside can land right after a lock
is taken and before the code that releases it, leaving the lock held for
every thread of the worker. The pool now marks a reached limit and the
task's own next query raises it, once, through a connection execute
wrapper. The hard limit still cancels the running query, and raises
TimeLimitExceeded whatever the soft limit is. Limits end before Celery's
success callback runs. Savepoint queries are never interrupted, through
a helper shared with the periodic field update deadline.

* fix(celery): apply the worker default time limits on the threads pool

Celery passes CELERY_TASK_SOFT_TIME_LIMIT and CELERY_TASK_TIME_LIMIT to the pool and None per task when a task sets no limit. The prefork pool falls back to the pool's values; the threads pool now does too.

* fix(celery): keep threads pool time limits until running tasks end

The watchdog stopped before on_stop waited for the running tasks, so a task passing its limit during a warm shutdown was never stopped or reported.

* chore: name the emails the SMTP timeout covers in the changelog

EMAIL_TIMEOUT applies to the instance's own emails only. Automation and builder SMTP steps already time out after 30 seconds.

* chore(dev): drop dev.sh tabs for the removed Celery workers

The export and beat services are disabled, so attaching to them made the script exit before opening the remaining tabs.

* test(celery): cover thread time limits and savepoint rollback

* fix(ai): use one generation slot for nonpositive limits

* fix(chat): warn that an action may finish after a reply times out

* docs(celery): explain which timeout guarantees require prefork

* docs(celery): record the threads pool decision and task contract

* fix(chat): keep the worker slot until started tools finish

* fix(chat): warn visitors about repeating a timed-out request

* docs(chat): clarify when the stop grace period begins
2026-12-03 09:39:52 +01:00
Davide Silvestri 9eabe6b06b feat(core): add Redis-backed background chat runs (#6382)
* feat(core): add Redis-backed background chat runs

Run AI work once in Celery and follow bounded Redis Streams over HTTP. Keep
lifecycle, Stop, leases and final outcomes in Postgres without per-token writes.
Include the shared frontend follower, adapter registry, recovery API, migration,
queue/deployment wiring and adapter guide. No product uses it yet.

Part of #6346

* Remove unused chat run response header exposure

* Extract shared async streaming HTTP router

* Simplify chat run follower and group engine constants

- Check read access once when a stream opens; read run state from Postgres
  only after 5 s without output or on run.finished.
- Split follow_run into small steps around _OutputReader.
- Turn event kinds, error codes and stop reasons into StrEnums; the
  Kuma-only model_unavailable code moves to Kuma.
- Document ChatRunType hooks with param, return and raises fields.
- Add BASEROW_ASGI_HTTP_MAX_CONCURRENT_STREAMS and size the follower Redis
  pool by it.
- Give handler publish/recover calls their own event loop, so cleanup
  cannot close pools shared by HTTP followers.
- Update ADR 010 and the background chat runs docs.

* Clean up chat run interfaces and test setup

* Prune chat runs once after 7 days and skip overdue claims

- Delete each expired page with one statement. Incomplete runs get one more
  ensure_interruption_warning call first, and are deleted even if it fails,
  so run metadata never accumulates. The hook now returns None.
- Keep runs for 7 days instead of 30.
- Never claim a queued run older than NOT_STARTED_AFTER; the sweeper ends it.

* Retry brief Redis failures in chat run followers

- A connection error, or a buffer that does not exist yet, is retried with
  the same cursor, sending heartbeats meanwhile.
- run.replay_unavailable is only sent once the follower stops reading, so
  the browser can treat it as final.

* Let finished chat run output expire with the active TTL

Nothing reads a buffer once its run has finished: followers return the saved
outcome first and recovery only reads running runs. Drop finish() and the
24 h TTL, so a finished buffer expires an hour after its last append.
_publish_terminal now reuses _publish.

* Run the chat run scale tests on fakeredis

Build the buffer's real read and write pools on fakeredis connections, so
these tests always run and backend CI needs no Redis service. The Kuma e2e
tests cover a real Redis.

* Address the remaining chat run review comments

- Serialize the saved outcome after the transaction, so only a failed save
  is logged as one.
- Make the primary-pin test transactional; inside the test transaction the
  router always used the primary, so it could not fail.
- Cover the race past the per-user lock, a lost run after Stop and an old
  writer appending to a recreated buffer.
- End the admission test's request with a disconnect, so a regression fails
  instead of looping.
- Document that one worker process runs AI replies one at a time.

* Move the chat run migration after develop's core 0130

* Log only the class of an outcome serialization error

* Test that the run deadline asks a run to stop

* Keep a run's status when a resumed follower rebuilds its output

* Note that slow DNS lookups turn off a run's live output
2026-10-21 14:52:59 +02:00
Jonathan Adeline 57031e305e feat: arrange widgets on a responsive grid (#5882) 2026-09-23 14:38:14 +02:00
Davide Silvestri 0bb39e36c6 [1/4] feat: AI assistant eval platform on self-hosted Phoenix (#5958)
* feat: add Phoenix LLM tracing service to the dev stack (ai profile)

* chore(deps): add openinference pydantic-ai instrumentation (dev)

* feat: export assistant traces to Phoenix when BASEROW_ASSISTANT_PHOENIX_URL is set

* fix: harden Phoenix tracing setup after review

* feat: Phoenix postgres storage, ai-evals profile and auth support

* docs: ADR 007 and assistant tracing/evals guides

* feat: assistant eval platform core (types, registries, scenarios)

* feat: eval harness with shared assistant factory

* feat: phoenix dataset sync for assistant evals

* feat: assistant eval experiments via phoenix client + CLI

* feat: migrate core, database and docs evals to the platform

Ports the 42 kuma-core/kuma-database/kuma-docs pytest evals into
declarative EvalCase/EvalScenario registrations, plus structure-level
tests asserting dataset counts, ids, and scenario wiring.

* feat: migrate builder and automation evals to the platform

Ports the 12 builder + 2 proactive + 2 user-source cases into
evals/datasets/builder.py (kuma-builder, 16 cases) and the 7 automation
cases into evals/datasets/automation.py (kuma-automation), following the
Task 5 pattern established in core.py/database.py. Extends
eval_platform/test_datasets.py with counts, id lists, a mode-per-case
assertion, and pre_state snapshot checks for the two cases that need one.

* fix: link traces and final counts for single-case eval runs

* fix: root spans for single-case eval runs use the assistant tracer provider

* feat: assistant eval runner service with run page

Adds the assistant_eval_runner management command (migrate -> instrumentation
-> dataset sync -> single worker thread -> wsgiref server) and its
runner.py module: a stdlib WSGI app serving a plain server-rendered page
(GET /, POST /run, GET /healthz) backed by a bounded in-memory run history
and one background worker draining a queue.Queue via run.run_experiment_for.

Wires the assistant-eval-runner compose service (ai-evals profile, own
baserow_evals DB), renames phoenix-db-init to ai-evals-db-init and extends
it to also create baserow_evals, and adds BASEROW_EVAL_RUNNER_PORT to both
env example files and the dev docs.

* fix: eval runner integration fixes

assistant-eval-runner needs its own SECRET_KEY/DATABASE_*/REDIS_* env vars:
dev-overlay compose services don't inherit docker-compose.yml's
x-backend-variables anchor (that's file-scoped YAML), so the container was
starting without a Django SECRET_KEY and without a Redis password, crashing
on auth. Also links to finished experiments pointed at the container-internal
BASEROW_ASSISTANT_PHOENIX_URL (http://phoenix:6006), unreachable from the
developer's browser.

Adds BASEROW_ASSISTANT_PHOENIX_PUBLIC_URL (defaulting to
http://localhost:${BASEROW_PHOENIX_PORT:-6060}) and has runner.py build the
Phoenix link from it, deep-linking straight to the finished run's experiment
compare view when its dataset_id/experiment_id are known, falling back to
the datasets list otherwise.

* refactor: retire the pytest eval harness

All 65 eval cases now live in baserow_enterprise.assistant.evals.datasets;
delete the legacy pytest-based suite and its `eval` markers.

* docs: rewrite assistant evals guide for the Phoenix platform

* feat: docs judge, prompt sync, git stamping and UI-contributed eval examples

- answer_quality LLM-as-judge evaluator for kuma-docs (BASEROW_EVAL_JUDGE_MODEL)
- Kuma prompts versioned into Phoenix on sync; experiments stamped with
  prompt hashes, git branch/commit and judge model
- sync preserves UI-added dataset examples with prompt-match adoption;
  eval-export emits paste-ready docs.py snippets
- final-review fixes: skip-safe scoring, runner CSRF/bind hardening,
  doc corrections

* feat: eval runner UI round — tabs, fan-out, reference answers, 64-case docs dataset

- Runner page: dataset tabs with selection badges, per-dataset and global
  all/none, cross-dataset fan-out (one experiment per dataset), 5s
  auto-refresh of runs, persistent run history across restarts, per-dataset
  Phoenix links, in-page Help tab rendering the repo docs via /docs.json.
- Reference answers for kuma-docs: EvalCase.reference_answer, judge grades
  against it, sync preserves UI-curated ones, eval-export round-trips them.
- kuma-docs grown to 64 cases: reference answers for all, PostHog-mined
  frequent questions, and cannot-do guardrail cases.
- Gemini (google:gemini-3.6-flash) in the eval model list.

* feat: runnable UI examples, prompt overrides, eval baseline and results view

- UI-added Phoenix examples now execute: docs questions get the standard
  docs checks + judge; tool cases declare scenario/expected_tools/
  answer_contains in metadata (empty-workspace default scenario). They are
  tickable per dataset on the runner page and run in whole-dataset
  experiments too.
- Prompt overrides: run any experiment with a prompt's latest Phoenix
  version instead of the code constant (runner checkbox panel with soft
  per-tab ordering, or --override-prompt). Agent singletons keep their
  dynamic instructions; effective hashes + override list stamped on the
  experiment.
- Committed baseline snapshot (evals/baseline.json, 111 cases) with
  just b eval-baseline capture/import; the runner imports it on startup so
  every Phoenix instance gets a baseline experiment per dataset,
  idempotent by content hash and run count.
- Results tab: all datasets in one view for a named experiment, with
  baseline deltas and a case-weighted overall row, via Phoenix experiment
  annotation summaries.
- New evaluation guide (docs/testing/ai-assistant-eval-analysis.md) served
  in the Help tab; layout uses horizontal space better (single tab row,
  fluid case columns).

* feat: time and cost in eval results, frozen into the baseline snapshot

- Results tab gains time (sum of run latencies) and cost/token columns per
  dataset and summed overall, with lower-is-better baseline deltas.
- eval-baseline capture freezes each dataset's time/cost/token totals into
  baseline.json; import stamps them as metadata so imported baselines
  (which carry no traces to price) still show time and cost.
- Importing a new baseline supersedes the previously imported one instead
  of accumulating duplicates.
- Changelog entry for the eval platform.

* fix: OpenInference attributes on subset-run task root spans

Bare wrapper spans rendered as kind 'unknown' with Unset status and empty
input/output in Phoenix. The Task root span now carries the CHAIN kind, the
case prompt as input, the run result as JSON output, and an explicit OK
status.

* polish; minor fixes

* fix: address eval platform review feedback

Apply production model settings and retries, isolate automation checks, and fix runner configuration, links, and result status.

Defer GPT-5.6 compatibility and baseline comparisons to #6034.

* fix: preserve model profiles in rebased eval harness

Use an explicit model profile for evals and share concrete models with tools. Manage model clients through the existing lifecycle helper and preserve regression coverage from the retired harness.

* fix: harden eval persistence and Phoenix access
2026-09-09 17:06:07 +02:00
Peter EvansandJeremie Pardou b70bc968db chore: (1/2) implement the graph system in the builder backend (#4706)
Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-06-25 10:09:24 +01:00
Jérémie Pardou a1b92d682d task: add multiple instances support (#5541) 2026-06-22 17:43:59 +02:00
dimmur-brw 193e3a3f44 fix(backend): Remove upsert_env (#5540) 2026-06-17 08:31:37 +00:00
Peter Evans 3fb540a20d translations recipe partially broken for premium/enterprise dirs (#5510) 2026-06-15 13:47:17 +01:00
Jérémie Pardou b3aa83514b feat: add code service (#5425) 2026-06-09 15:41:31 +00:00
alamin-br 3fd9fdc09e chore: add zed config for debugging (#5441) 2026-06-02 09:05:27 +02:00
alamin-br 40b8371c68 chore: improve pre commit performance (#5406)
* chore: improve pre-commit hook trigger and make sure only applies to
staged/unstaged changes.

* docs: update code-quality doc

* docs: improve doc
2026-05-21 15:05:32 +00:00
alamin-br 4373a68e35 chore: integrate pre-commit hooks (#5392)
* chore: integrate pre-commit hooks for backend and frontend code quality enforcement

* fix: uv.lock

* refactor: consolidate pre-commit hooks to use just recipes and add a pre-commit-uninstall command

* docs: document pre-commit branch linting and update pre-commit configuration to increase file size limits and remove serial execution requirements.
2026-05-21 14:16:38 +02:00
Davide Silvestri b65c7e77cb chore refactor (AI Assistant): context offloading; better telemetry data; add google and anthropic models compatibility (#4951)
* chore(deps): replace udspy with pydantic-ai and opentelemetry-sdk

Replace the udspy dependency with pydantic-ai-slim (with openai, groq,
anthropic, bedrock providers) and opentelemetry-sdk for structured
telemetry collection.

* fix(sentry): exclude pydantic_ai from auto-enabling integrations

sentry-sdk's pydantic_ai integration patches ToolManager._call_tool
which was removed in pydantic-ai >= 1.x (now execute_tool_call),
causing import-time errors.

* feat(settings): add dev log file mirroring and allow embeddings URL in tests

- Add BASEROW_LOG_FILE support in dev settings to mirror logs (including
  loguru output) to a file, useful for AI-assisted debugging.
- Allow BASEROW_EMBEDDINGS_API_URL to be overridden via env in test
  settings for search_user_docs eval tests.

* feat(assistant): add message_history field to AssistantChat

Add a BinaryField to store serialized pydantic-ai message history
(JSON bytes) for multi-turn conversation context, replacing the
previous udspy-based conversation state.

* refactor(assistant): port to pydantic-ai agent framework

Replace udspy with pydantic-ai as the agent framework for the AI
assistant. Key changes:

- Add Agent definitions with typed deps (AssistantDeps) and dynamic
  toolsets for runtime tool loading
- Add deps module with AssistantDeps, ToolHelpers, and EventBus for
  streaming events to the UI
- Add history module for serializing/deserializing pydantic-ai message
  history to the database
- Add model_profiles for provider-specific configuration (Anthropic,
  OpenAI, Groq, Bedrock)
- Add toolset module with ToolGroup base class replacing the udspy
  tool registry pattern
- Add shared/ with formula_utils and sub-agent helpers
- Add tool_types.py per tool module for pydantic-ai ToolDefinition
- Port all tool modules (core, database, navigation, automation,
  search_user_docs) from udspy decorators to pydantic-ai Tool instances
- Port assistant orchestrator, handler, and prompts
- Remove signatures.py (replaced by pydantic-ai output types)

* refactor(assistant): update telemetry for pydantic-ai

Rework telemetry collection to use pydantic-ai's message history
format and OpenTelemetry SDK for structured span/event recording,
replacing the previous udspy-based telemetry hooks.

* test(assistant): update unit tests for pydantic-ai port

Rewrite assistant unit tests to use pydantic-ai's testing utilities
(TestModel, FunctionModel) instead of udspy mocks. Add new test files
for core tools, navigation tools, and search docs tools. Remove
obsolete skip file.

* test(assistant): add LLM eval test suite

Add end-to-end eval tests that run the real agent against a live LLM
to verify tool selection, schema compatibility, and output quality.

Includes evals for: navigation, core builders, database tables/rows,
sample rows, automation workflows, search_user_docs, and cross-cutting
structured output validation.

Tests are marked with @pytest.mark.eval and skipped by default.
Configure via EVAL_LLM_MODEL or EVAL_LLM_MODELS env vars.

* docs: add eval guide and update AI assistant installation docs

- Add docs/development/ai-assistant-evals.md with instructions for
  running the eval suite, configuring models, and writing new evals.
- Update docs/installation/ai-assistant.md to reflect pydantic-ai
  provider configuration replacing the previous udspy setup.

* fix(assistant): fix test patch paths, optional filter args, and eval marker

- Fix mock patch paths from `assistant.agent` to `assistant.agents`
- Make ListTablesFilterArg fields optional to prevent LLM validation errors
- Surface field_errors in create_fields tool result
- Simplify EvalToolTracker to use message history inspection
- Register `eval` pytest marker and skip evals by default

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: move testing docs to docs/testing/ and add PR test plan

Move ai-assistant-evals.md from docs/development/ to docs/testing/,
add ai-assistant-test-plan.md with manual and automated test steps
for the pydantic-ai port PR.

* refactor(assistant): extract row models to types/rows.py, rename utils to helpers

- Move FieldDefinition, row model builders, and get_link_row_hints to
  new types/rows.py module with dict-of-callables dispatch replacing
  match/case
- Simplify update model: fields are optional (omit = don't change),
  removing the __NO_CHANGE__ sentinel
- Move get_table_rows_tools into tools.py as _build_row_tools since it
  builds pydantic-ai Tool objects
- Rename utils.py to helpers.py for clarity, remove dead list_tables
- Add docstrings with :param/:returns to all public functions, add
  proper type annotations throughout

* refactor(assistant): flatten field/view/filter types into single models

- Replace per-type config classes in fields.py with a single flat
  FieldItemCreate model using optional type-specific fields and a
  model_validator for type aliases
- Simplify view_filters.py and views.py type hierarchies similarly
- Update table.py types and corresponding tests

* fix(assistant): improve telemetry span processor and minor tweaks

- Replace SpanExporter with SpanProcessor for real-time span handling
- Remap child tool spans past 'running tools' grouping span
- Parse JSON string arguments in tool call parts
- Add data_brief parameter to sample rows prompt
- Disable reasoning_effort for groq models temporarily
- Rename _fix_formula to _fix_formula_field in helpers

* refactor(assistant): use ISO strings for dates and add dateutil fallback

Replace Date/Datetime Pydantic model objects with compact ISO 8601
strings. Add lenient parsing via dateutil.parser fallback when
fromisoformat fails.

* feat(assistant): add DO/EXPLAIN agent modes with switch_mode tool

Introduce AgentMode enum (DO/EXPLAIN) and ModeAwareToolset that filters
available tools based on mode. DO mode (default) exposes all action
tools except search_user_docs. EXPLAIN mode exposes only read-only
tools (list_*, navigate) plus search_user_docs for answering Baserow
feature questions. The switch_mode tool allows bidirectional switching.

* refactor(assistant): flatten automation node types and add $formula: convention

Replace 13+ per-type action node classes (RouterNodeCreate, SendEmailActionCreate,
etc.) with a single flat ActionNodeCreate model using @model_validator for per-type
validation and dict-dispatched functions for ORM conversion and formula generation.

Add $formula: prefix convention — values prefixed with '$formula:' are sent to the
LLM formula generator, plain values become literal formulas. Also detect raw formula
expressions (get(), concat(), etc.) written inline.

Add trigger validation: periodic triggers now require periodic_interval (with
automatic folding of flat fields), row triggers require rows_triggers_settings.

* build: bump pydantic-ai-slim to 0.1.66 and anthropic to 0.84.0

* feat(assistant): add RetryingModel for transient provider error recovery

Wraps pydantic-ai model instances to automatically retry on transient
errors (rate limits, timeouts, server errors) with exponential backoff.
Handles both streaming and non-streaming calls.

* feat(assistant): add AgentMode system with ModeAwareToolset and switch_mode

Introduce domain modes (DATABASE, APPLICATION, AUTOMATION, EXPLAIN) that
control which tools are visible to the agent. ModeAwareToolset filters
the combined toolset per-mode, registries generate per-mode manifests,
and switch_mode lets the agent transition between domains. Each mode
gets a cross-mode summary so the agent knows what other modes offer.

* refactor(assistant): integrate RetryingModel, event-based streaming, and JSON retry

Replace direct model usage with RetryingModel for resilience. Rewrite
streaming to use run_stream_events for proper text/reasoning/tool event
handling. Add JSON-tool-call-as-text detection with automatic retry.
Auto-detect starting mode from UI context. Update model_profiles with
max_tokens settings.

* refactor(assistant): improve shared formula utils and add formula language reference

Add RAW_FORMULA_RE for detecting raw formula expressions, needs_formula()
for $formula: prefix and raw formula detection, literal_or_placeholder()
for ORM value creation, and a shared formula language prompt. Improve
formula generator to track remaining unresolved fields across retries.

* refactor(assistant): improve database tools with routing rules and type fixes

Add per-module routing rules via get_routing_rules(). Extract ToolInputError
to helpers. Fix field type validators, improve row model handling, and
refine view filter types. Update agents and prompts for better tool
guidance.

* refactor(assistant): improve automation tools with routing rules and formula handling

Add per-module routing rules for automation. Improve node type handling
with better formula context support. Refine automation agents and prompts.

* fix(assistant): improve telemetry span processor with real-time remapping

Enhance SpanProcessor with JSON arg parsing, real-time span remapping,
and improved trace output handling. Update tests to cover new behavior.

* test(assistant): update tests for mode system, retry logic, and type refactors

Add tests for switch_mode, mode-aware manifests, JSON retry logic.
Add test_assistant_automation_node_tools and test_assistant_database_field_tools.
Update existing database/automation/core tests for refactored types and
new tool signatures. Update eval_utils for new deps structure.

* fix: lint

* chore(frontend): ignore .claude dir in vite watcher and fix Nitro EMFILE

- Add .claude/ to vite server watch ignore list alongside node_modules
  and .git to avoid unnecessary file watching in worktrees.
- Configure Nitro devStorage to use fs-lite driver to prevent chokidar
  from watching the entire repo root, which causes EMFILE on macOS in
  large monorepos.

* fix(tests): fix test settings and seat usage test isolation with xdist

- Ensure pytest always finds backend/pytest.ini by passing -c pytest.ini
  explicitly, fixing DJANGO_SETTINGS_MODULE=dev when running from root
- Preserve existing TEST dict keys when setting MIGRATE in test settings
- Add transaction=True to seat usage tests to prevent data leaking from
  TransactionTestCase tests running on the same xdist worker

* fix(assistant): fix field types, formula regex, validator guard, and consolidate evals

Fix multiple_select returning None instead of [], link_row description
typo, formula regex missing greater_than_or_equal/less_than_or_equal
variants, and guard against overwriting original validators on repeated
prepare_tools calls. Consolidate sample rows and navigation evals into
the database tables eval file and remove the meta tool-call history test.

* fix(assistant): improve tool return types, filter aliases, and eval infrastructure

- Return consistent dict types from all tools instead of plain strings
- Add operator aliases for view filters so LLMs can use natural names
- Fix boolean filter operator (is → equal)
- Remove reasoning format from UTILITY model profiles (pollutes structured output)
- Add ModelRetry for workflow creation and formula agent errors
- Add EvalChecklist for soft assertions with pass/fail scoring
- Add EVAL_RETRIES support for flake detection in eval tests
- Suppress loguru DEBUG noise during evals

* refactor(assistant): extract table creation helpers and remove unused model profile

- Extract _create_empty_tables and _create_table_fields from create_tables
- Filter out duplicate primary field in field creation to avoid model mistakes
- Remove unused gpt-oss-20b model profile
- Always attempt sample rows regardless of field errors

* fix(assistant): strip <think> tags and unify streaming as reasoning chunks

Models like MiniMax-M2.5 emit <think>...</think> tags inline. Handle
ThinkingPart/ThinkingPartDelta events from pydantic-ai and extract
inline thinking from text parts as a fallback. Stream all content as
AiReasoningChunk during the agent run; the final answer is emitted
as AiMessageChunk by _emit_answer.

* fix(assistant): simplify streaming and add collapsible reasoning UI

Replace _accumulate_text/_extract_thinking with a single _get_content_delta
helper that forwards text/thinking deltas. Accumulate reasoning_so_far and
strip <think> tags before sending to frontend (which replaces content on
each chunk). Add collapsible reasoning bubble (max 250px with fade mask
and chevron toggle).

* fix(assistant): bridge legacy UDSPY_LM_* env vars to pydantic-ai config

* docs(assistant): improve ai-assistant.md and add AWS_REGION_NAME backward compat

- Add both Bedrock auth methods (boto3 creds + bearer token)
- Add section 6 with pydantic-ai model overview link and provider list
- Restructure migration table: unchanged / bridged / new variables
- Fix AWS_BEARER_TOKEN_BEDROCK incorrectly listed as removed
- Bridge AWS_REGION_NAME to AWS_DEFAULT_REGION in settings for backward compat

* minor doc/evals fixes

* fix(assistant): strip unclosed <think> tags during streaming

Models behind Groq emit <think> tags as text content rather than using
the native thinking protocol. During streaming, the closing </think>
tag may not have arrived yet, causing raw thinking content to leak to
the frontend. Also strip think tags from tool thought fields and reset
reasoning on tool results.

* docs(assistant): use provider:model format and refresh eval docs

- Update all docs to use pydantic-ai provider:model format (colon separator)
- Fix mixed-up provider descriptions in configuration.md
- Refresh eval docs: replace assert_no_tool_errors with EvalChecklist pattern
- Add embeddings URL for local vs Docker in ai-assistant-evals.md
- Skip KB sync post_migrate signal during tests
- Fix temperature type in model_profiles.py
- Refactor justfile PYTHONPATH for test recipe

* fix(assistant): clean up navigation and improve tool types

- Remove unused WorkspaceNavigationRequestType
- Narrow exception catch in navigate tool to ObjectDoesNotExist
- Guard id field in CreateRowModel.from_django_orm
- Use id__in for batch filtering in ListTablesFilterArg

* Revert "chore(frontend): ignore .claude dir in vite watcher and fix Nitro EMFILE"

This reverts commit 4be1be19d2.

* fix: ai-assistant-test-plan.md tool smoke test prompt for list_builders

* fix: Posthog env var names in docs/testing/ai-assistant-test-plan.md

* fix: wrong doc reference
2026-03-20 10:53:17 +00:00
Jérémie PardouandTsering Paljor 33a6d46e62 fix: workflow runner race conditions (#4953)
* Ensure running workflow histories aren't deleted.

* Fix race conditions

* Fix simulation

* Fix simulation error for big dispatch delay

---------

Co-authored-by: Tsering Paljor <tsering@baserow.io>
2026-03-16 17:27:13 +01:00
Davide Silvestri 1797a5214b fix: n+1 issue in send_unread_notifications_by_email_to_users_matching_filters (#4802) 2026-02-18 16:17:33 +01:00
Davide Silvestri 6e7450eda0 chore: fix run commands from saas (#4745)
* Fix commands run from saas

* Remove frontend warnings

* Adapted Caddyfile for additional saas backend routes

* removed config settings
2026-02-17 11:10:47 +01:00
Davide SilvestriandCopilot d89f474df5 chore (deps): upgrade base image to trixie and python 3.14 (#4718)
* trixie and python 3.13

* Fix backend tests

* Fix various references to previous python 3.11

* Upgrade to python 3.14

* Use official version of caddy

* Update backend/Dockerfile

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix dev build

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-11 15:15:24 +01:00
Davide Silvestri 8e05debbfb fix (CI): add missing docs folder to docker images (#4559) 2026-01-20 09:03:13 +01:00
Davide Silvestri f161790387 chore: switch to ruff (#4387)
* Switch to ruff

* Fix flaky test

* Remove frontend-lint changes

* Fix all-in-one image creation in CI

* Update saas target

* Add changelog entry

* Fix PYTHONPATH for lint-migrations

* Run check-migrations in the CI
2026-01-16 11:34:19 +01:00
Davide Silvestri e25988ea0d chore: switch to uv and justfile (#4369)
* create backend justfile; switch to uv

* Add deploy and dc-deploy recipes to build images

* Add uv.lock for reproducible builds

* CI fixes + improvements

* Reduce build time

* improve CI caching

* Improve exit early conditions

* Set requires_python==3.11.*; add backend/media to gitignore

* Fix all-in-one Dockerfiles and some other fixes

* Introduce frontend justfile + some other useful recipes

* Fix permissions issue with dev containers

* Improve dockerfiles and docs on how to use the dev env

* Fix mjml-email-compiler service

* Update docs + address feedback

* Fix containers healthchecks

* Fix yarn test in dev container

* Minor fixes to docs and justfile attach command

* Address Petr's feedback

* Address additional feedback

* Add changelog entry

* Address feedback: Petr and Przemek

* address feedback + prepare for saas PR

* minor fixes

* Address Bram's feedback 2
2026-01-15 11:22:22 +01:00