Structured Prompt Language: Declarative Context Management for LLMs
Wen G. Gong

TL;DR
This paper introduces SPL, a declarative language inspired by SQL, for managing large language models efficiently with explicit resource control, transparency, and integration of retrieval and memory, enabling cost-effective and resilient LLM workflows.
Contribution
SPL provides a novel declarative framework for LLM context management, including resource control, optimization, transparency, and integration of retrieval and memory, with extensions for multilingual translation, model routing, document chunking, and resilient orchestration.
Findings
Reduces prompt boilerplate by 65%
Surfaces a 68x cost spread as a pre-execution signal
Runs scripts at $0.002 on OpenRouter or free locally
Abstract
We present SPL (Structured Prompt Language), a declarative SQL-inspired language that treats large language models as generative knowledge bases and their context windows as constrained resources. SPL provides explicit WITH BUDGET/LIMIT token management, an automatic query optimizer, EXPLAIN transparency analogous to SQL's EXPLAIN ANALYZE, and native integration of retrieval-augmented generation (RAG) and persistent memory in a single declarative framework. SPL-flow extends SPL into resilient agentic pipelines with a three-tier provider fallback strategy (Ollama -> OpenRouter -> self-healing retry) fully transparent to the .spl script. Five extensions demonstrate the paradigm's breadth: (1) Text2SPL (multilingual NL->SPL translation); (2) Mixture-of-Models (MoM) routing that dispatches each PROMPT to a domain-specialist model at runtime; (3) Logical Chunking, an intelligent strategy for…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Database Systems and Queries · Semantic Web and Ontologies · Scientific Computing and Data Management
