{"id":1762,"date":"2026-08-13T01:48:48","date_gmt":"2026-08-13T01:48:48","guid":{"rendered":"https:\/\/vykhodtsev.dev\/?p=1762"},"modified":"2026-08-13T01:48:48","modified_gmt":"2026-08-13T01:48:48","slug":"%f0%9f%a7%a0-adding-business-rules-to-my-ai-sql-agent","status":"publish","type":"post","link":"https:\/\/vykhodtsev.dev\/?p=1762","title":{"rendered":"\ud83e\udde0 Adding Business Rules to My AI SQL Agent"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Another step in the development of my AI SQL Agent: I\u2019ve added a centralized Business Rules layer that allows me to control how the AI Agent works with the database without hardcoding every instruction into the application logic.<br>Instead of relying only on a large system prompt, I created a dedicated database table where architectural and business rules can be stored, maintained, and provided to the AI Agent as part of its working context.<br>For example, an architecture rule can define standards for creating dimension tables:<br>\u27a1\ufe0f When a user asks the Agent to create a dimension table, it must include:<br>Code \u2014 default length 3<br>Name \u2014 default length 20<br>So instead of simply generating whatever table structure the LLM considers appropriate, the Agent follows the architectural standards defined for the environment.<br>Another example is a business rule for inventory movement.<br>If a user asks:<br>&#8220;Move 10 units of Product A from Warehouse 1 to Warehouse 2.&#8221;<br>the Agent understands that this operation should create two records in the moving_product table:<br>Warehouse 1 \u2192 -10<br>Warehouse 2 \u2192 +10<br>The important idea here is that the AI Agent does not need to &#8220;know&#8221; these organization-specific rules during model training.<br>The rules become part of the data and configuration layer.<br>User Request \u2192 AI Agent \u2192 Relevant Business \/ Architecture Rules \u2192 SQL Generation \u2192 Database<br>This creates an interesting separation of responsibilities:<br>\ud83e\udd16 AI Agent \u2014 understands the user&#8217;s intent and generates the required actions<br>\ud83d\udccb Rules Layer \u2014 defines how those actions must be performed in a specific environment<br>\ud83d\uddc4\ufe0f Database \u2014 executes the controlled SQL operations<br>For me, this is an important step toward moving an AI SQL Agent from a simple natural-language-to-SQL demo toward an assistant that can operate within defined enterprise standards and business processes.<br>It also opens the door to managing rules centrally, activating or deactivating them, adding new rules without changing the Agent&#8217;s core code, and eventually applying different rule sets to different environments or use cases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23ai&amp;origin=HASH_TAG_FROM_FEED\"><strong>#AI<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23aiagents&amp;origin=HASH_TAG_FROM_FEED\"><strong>#AIAgents<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23artificialintelligence&amp;origin=HASH_TAG_FROM_FEED\"><strong>#ArtificialIntelligence<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23generativeai&amp;origin=HASH_TAG_FROM_FEED\"><strong>#GenerativeAI<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23sql&amp;origin=HASH_TAG_FROM_FEED\"><strong>#SQL<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23dataengineering&amp;origin=HASH_TAG_FROM_FEED\"><strong>#DataEngineering<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23solutionarchitecture&amp;origin=HASH_TAG_FROM_FEED\"><strong>#SolutionArchitecture<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23businessrules&amp;origin=HASH_TAG_FROM_FEED\"><strong>#BusinessRules<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23enterpriseai&amp;origin=HASH_TAG_FROM_FEED\"><strong>#EnterpriseAI<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23database&amp;origin=HASH_TAG_FROM_FEED\"><strong>#Database<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23azureopenai&amp;origin=HASH_TAG_FROM_FEED\"><strong>#AzureOpenAI<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23python&amp;origin=HASH_TAG_FROM_FEED\"><strong>#Python<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23fastapi&amp;origin=HASH_TAG_FROM_FEED\"><strong>#FastAPI<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23automation&amp;origin=HASH_TAG_FROM_FEED\"><strong>#Automation<\/strong><\/a><a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23dataarchitecture&amp;origin=HASH_TAG_FROM_FEED\"><strong>#DataArchitecture<\/strong><\/a><\/p>\n\n\n\n<figure data-spectra-id=\"spectra-msquzsb2-sdt13g\" class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1528\" height=\"1021\" src=\"https:\/\/vykhodtsev.dev\/wp-content\/uploads\/2026\/08\/Screenshot-2026-08-12-204622.jpg\" alt=\"screenshot 2026 08 12 204622\" class=\"wp-image-1763\" title=\"\ud83e\udde0 Adding Business Rules to My AI SQL Agent\" srcset=\"https:\/\/vykhodtsev.dev\/wp-content\/uploads\/2026\/08\/Screenshot-2026-08-12-204622.jpg 1528w, https:\/\/vykhodtsev.dev\/wp-content\/uploads\/2026\/08\/Screenshot-2026-08-12-204622-1300x869.jpg 1300w, https:\/\/vykhodtsev.dev\/wp-content\/uploads\/2026\/08\/Screenshot-2026-08-12-204622-768x513.jpg 768w\" sizes=\"auto, (max-width: 1528px) 100vw, 1528px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Another step in the development of my AI SQL Agent: I\u2019ve added a centralized Business Rules layer that allows me to control how the AI Agent works with the database without hardcoding every instruction into the application logic.Instead of relying only on a large system prompt, I created a dedicated database table where architectural and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1762","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"spectra_blocks_featured_image_url":null,"spectra_blocks_author_info":{"display_name":"Aleksei","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/198b25ea575ebb3cbd0934cb05fd942d0f256a65d3ff388a161c857e00b092bf?s=96&d=mm&r=g","author_link":"https:\/\/vykhodtsev.dev\/?author=1","description":""},"_links":{"self":[{"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=\/wp\/v2\/posts\/1762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1762"}],"version-history":[{"count":1,"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=\/wp\/v2\/posts\/1762\/revisions"}],"predecessor-version":[{"id":1764,"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=\/wp\/v2\/posts\/1762\/revisions\/1764"}],"wp:attachment":[{"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vykhodtsev.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}