fix: stop migrations from resetting ai_agents model_name, default to vllm/AxionML/Qwen3.5-9B-NVFP4
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-2 Pipeline was successful
ci/woodpecker/push/build-1 Pipeline was successful
ci/woodpecker/push/build-3 Pipeline was successful
ci/woodpecker/push/finalize Pipeline was successful
Build and Push / lint-and-test (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.adapters.broker_adapter name:broker-adapter]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.aggregation.worker name:aggregation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.extractor.worker name:extractor]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.ingestion.worker name:ingestion]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.lake_publisher.worker name:lake-publisher]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.parser.worker name:parser]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.recommendation.worker name:recommendation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.scheduler.app name:scheduler]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.api.app:app --host 0.0.0.0 --port 8000 name:query-api]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.risk.app:app --host 0.0.0.0 --port 8000 name:risk]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.symbol_registry.app:app --host 0.0.0.0 --port 8000 name:symbol-registry]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.trading.app:app --host 0.0.0.0 --port 8000 name:trading-engine]) (push) Has been cancelled
Build and Push / build-dashboard (push) Has been cancelled
Build and Push / build-superset (push) Has been cancelled
Build and Push / integration-test (push) Has been cancelled
Build and Push / beta-gate (push) Has been cancelled

This commit is contained in:
Celes Renata
2026-04-28 18:58:13 +00:00
parent 4954318f7b
commit 23f2134754
3 changed files with 25 additions and 8 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS ai_agents (
name VARCHAR(100) NOT NULL UNIQUE,
slug VARCHAR(100) NOT NULL UNIQUE,
purpose TEXT NOT NULL DEFAULT '',
model_provider VARCHAR(50) NOT NULL DEFAULT 'ollama',
model_provider VARCHAR(50) NOT NULL DEFAULT 'vllm',
model_name VARCHAR(200) NOT NULL DEFAULT 'qwen3.5:9b',
system_prompt TEXT NOT NULL DEFAULT '',
user_prompt_template TEXT NOT NULL DEFAULT '',
+8 -7
View File
@@ -1,22 +1,23 @@
-- Sync ai_agents system_prompt and model_name to match code defaults.
-- The original 026 seed used abbreviated prompts and the base model name;
-- this migration brings them in line with the authoritative prompts defined
-- in the Python service code and the actual deployed model tag.
-- Sync ai_agents system_prompt to match code defaults.
-- The original 026 seed used abbreviated prompts; this migration brings
-- them in line with the authoritative prompts defined in the Python
-- service code.
--
-- NOTE: model_name and model_provider are NOT overwritten here.
-- They are configured per-environment via the API or direct DB update
-- and should not be reset by migrations.
UPDATE ai_agents
SET system_prompt = E'You are a financial document analyst. Extract structured data as JSON. Return ONLY a single JSON object. No markdown fences, no explanation, no text before or after the JSON. Every field in the schema is required. Use "other" for catalyst_type if unsure. Keep evidence_spans short (under 20 words each). Keep key_facts to 3-5 items max.',
model_name = 'qwen3.5:9b-fast',
updated_at = NOW()
WHERE slug = 'document-extractor';
UPDATE ai_agents
SET system_prompt = E'You classify MACRO-LEVEL global news into structured event JSON. Return ONLY a single JSON object. No markdown, no explanation. Every field is required. Keep key_facts to 3-5 items. Keep summary under 3 sentences.\n\nCRITICAL: Only classify articles about MACRO events that affect entire markets, sectors, or economies. Examples: trade wars, interest rate changes, commodity supply disruptions, regulatory changes, geopolitical conflicts, natural disasters.\n\nDO NOT classify as macro events: individual company earnings, lawsuits against a single company, single-company management changes, individual stock analysis, company-specific debt or bankruptcy, product launches by one company. For these, set severity to "low", confidence below 0.3, and leave affected_regions, affected_sectors, and affected_commodities as empty arrays.',
model_name = 'qwen3.5:9b-fast',
updated_at = NOW()
WHERE slug = 'event-classifier';
UPDATE ai_agents
SET system_prompt = E'You are a concise financial analyst. You rewrite structured trade thesis summaries into clear, professional prose suitable for an internal research note.\n\nSTRICT RULES:\n1. Do NOT add any information that is not present in the input.\n2. Do NOT fabricate numbers, dates, company names, or analyst opinions.\n3. Keep the rewrite under 150 words.\n4. Preserve all factual claims, risk notes, and evidence counts from the input.\n5. Use a neutral, professional tone. Avoid hype or marketing language.\n6. Return ONLY the rewritten thesis text. No JSON, no markdown, no commentary.',
model_name = 'qwen3.5:9b-fast',
updated_at = NOW()
WHERE slug = 'thesis-rewriter';
@@ -0,0 +1,16 @@
-- Stop hardcoding agent model_name in migrations.
--
-- Migration 029 previously forced model_name='qwen3.5:9b-fast' on every
-- deploy, overwriting per-environment model configuration. That migration
-- has been fixed to only sync system_prompt (not model_name).
--
-- This migration updates agents still on the old ollama provider/model
-- to use vllm with the default VLLM model. Agents already configured
-- with a different model (e.g. via the API) are left untouched.
UPDATE ai_agents
SET model_provider = 'vllm',
model_name = 'AxionML/Qwen3.5-9B-NVFP4',
updated_at = NOW()
WHERE model_name IN ('qwen3.5:9b-fast', 'qwen3.5:9b')
AND source = 'system';