{"slug": "semiotique", "title": "Semiotique", "summary": "An independent developer has published Semiotique, an early-stage framework that proposes \"inverting the agentic loop\" by writing agentic applications mostly in deterministic code and invoking LLMs selectively through a global singleton called S, with a runtime handling context curation behind the scenes. The project's README argues that today's agentic-loop frameworks delegate too much responsibility to the LLM, which it says is non-deterministic, prone to sycophancy and poor at iteration, and it includes demo examples plus a personal note-taking app in a notetaker directory. The author describes Semiotique as \"very early stage\" and rough around the edges, and is seeking collaborators to improve it and potentially turn it into a commercial venture.", "body_md": "**Disclaimer:** This project is still at a *very early stage*, and very rough around the edges.\n\nI am actively looking for collaborators to improve it and potentially turn it into a commercial venture. If you are interested, feel free to contact me at [vivek.claver@gmail.com](mailto:vivek.claver@gmail.com) :)\n\n## TLDR\n\nSemiotique is a framework which proposes a new paradigm for building agentic applications. It is based upon two core ideas:\n\n- LLM calls should be “first-class citizens” of the language syntax ; programming constructs should allow to seamlessly mesh LLM usage with “plain old code”\n- The actual LLM calls should be managed by a runtime responsible for improving their performance and correctness, especially by doing context curation behind the scenes\n\nThe hypothesis is that this paradigm will be an enabler for more sophisticated agentic applications, which will selectively leverage LLMs for tasks at which they are good at while relying on regular, deterministic code for the bulk of the application.\n\nThis README will provide an overview of the design philosophy, core concepts, and next steps.\n\nThere are short demo examples in the demo/ directory showcasing the basic syntax, and a more advanced example - a personal note-taking app - in the notetaker/ directory (refer to notetaker/README.md for more information about it)\n\n## Design Philosophy\n\nToday, most frameworks for building agentic applications rely on the concept of the “agentic loop” : an LLM enriched with tools & skills is used as the main driver of the application. A prompt is given as input, and the agentic loop then runs autonomously, leveraging the tools & skills in order to produce a final output.\n\nI believe that this paradigm is the wrong approach, as LLMs have the following limitations:\n\n- LLMs can make errors, and its outputs are non-deterministic and non-replicable\n- LLMs have no judgment / taste, are prone to sycophancy, and often make questionable assumptions in its reasoning.\n- LLMs are just bad at certain tasks, such as iterations.\n\nThe agentic loop delegates too much responsibility to the LLM : formulating a plan of actions, deciding which tools / skills to use, generating the result, etc. As a consequence, the agentic loop can be brittle.\n\nIn addition, current frameworks embracing the agentic loop are not very elegant to program with : none of the tediousness of configuring and executing calls to an LLM is hidden, and some frameworks even require you to manually define a state machine for more complex workflows (e.g. LangGraph).\n\nThe Semiotique framework aims to solve all of the above by **“inverting the agentic loop”** : instead of having an LLM “black-box” to which we provide tools & skills and which we then let execute autonomously on a user input, we should instead develop applications *mostly* written in regular, deterministic code, with LLM evaluations selectively sprinkled in where they would be actually be useful (for tasks such as understanding natural language, outputting text, closed-ended reasoning, etc.), but always within the guardrails of regular code.\n\nIn addition, the tediousness of configuring and using LLMs should be hidden from the programmer, so that he can focus on building application features.\n\nThis leads to the two core ideas already stated in the TLDR above, namely that :\n\n- LLM calls should be “first-class citizens” of the language syntax ; programming constructs should allow to seamlessly mesh LLM usage with “plain old code”\n- The actual LLM calls should be managed by a runtime responsible for improving their performance and correctness, especially by doing context curation behind the scenes\n\nFinally, the framework should also provide a standard library of “agentic building blocks”, in order to further facilitate building agentic applications.\n\n## Core concepts\n\n### The S singleton\n\nSemiotique is a “runtime” which allows to evaluate LLM-expressions from anywhere in your code, via the global singleton `S`\n\nFor instance, you can use `S` to interact with an LLM :\n\n```\nprint(S(\"Hello! Who are you?\"))\n```\n\nYou can of course save the result of an LLM-expression to a variable\n\n```\ncapital = S(\"What is the capital of France?\") # Prints \"Paris\"\n```\n\nYou can use LLM-expressions anywhere, for example in a lambda mapping over a list :\n\n```\ncountries = [\"France\", \"Italy\", \"Spain\"]\ncapitals = list(map(lambda country: S(f\"What is the capital of {country}?\"), countries))\nprint(capitals) # Prints ['Paris', 'Rome', 'Madrid']\n```\n\nThe default return type is `str`, but you can specify any type, including custom types\n\n```\nprint(S(\"Is Paris the capital of France?\", output_type=bool)) # Prints true\npersian_cat = S(\"Fill in the Animal characteristics for a persian cat\", output_type=Animal) # Structured output of Animal object\n```\n\nThis allows you to use LLM-expressions in conditional structures\n\n```\nanswer = input(\"What's the capital of France?\")\n\nif S(f\"Is {answer} the capital of France?\", output_type=bool):\n  print(\"Correct\")\nelse:\n  print(\"Incorrect\")\n```\n\nAnd\n\n```\nanimal = input(\"What kind of animal do you have? \")\nanimal_type = S(\n    f\"Classify the type of animal {animal}?\",\n    output_type=Literal[\n        \"mammal\", \"bird\", \"fish\", \"reptile\", \"amphibian\", \"invertebrate\", \"other\"\n    ],\n)\n\nmatch animal_type:\n  case \"mammal\": ...\n```\n\nYou can pass in tools to LLM-expressions to aid in their task\n\n``` python\ndef get_weather(city: str):\n  return \"rainy\" if \"Paris\" else \"sunny\"\n\nprint(S(\"What is the weather like in Paris?\", tools=[get_weather])) # Prints \"rainy\"\n```\n\nYou can also specify an enclosing context which will get re-used for nested LLM-expressions within the lexical scope\n\n```\nwith S.with_context(\"Your name is Bob, and you are helpful coding assistant\"):\n    print(S(\"Hello! What's your name\")) # Will print Bob\n    print(S(\"What are you?\")) # Will print \"helpful coding assistant\"\n```\n\nContexts can be nested\n\n```\nwith S.with_context(\"Your name is Bob, and you are helpful coding assistant\"):\n    with S.with_context(\"Your first task is to present Semiotique to a new user\"):\n        print(S(\"Help me!\"))\n```\n\nFinally, you can also activate memory for nested LLM-expressions within a lexical scope\n\n```\nwith S.with_memory():\n    print(S(\"My name is Bob, and I am 30 years old. What is your name?\"))\n    print(S(\"What is my name?\")) # Prints Bob\n    print(S(\"What is my age?\")) # Prints 30\n```\n\n### The Agent base class\n\nSemiotique provides an abstract class called Agent, which is meant to serve as the base class for defining “agentic” classes.\n\nConceptually, agentic classes are meant to be the building blocks for agentic applications. They are meant satisfy the paradigm of object-oriented programming : each agent class satisfies a “contract”, implementing some behavior in a specific scope. An agentic application should then be built “constructively” through a “tangled hierarchy” of agents : top-level agents relying on lower-level agents, themselves relying on even lower-level agents, but sometimes relying on each other as well, etc.\n\nA class which inherits from Agent will automatically participate in the context engineering of any LLM-expression evaluations made from within agentic classes.\n\nBasically, the Runtime keeps track of the “call stack” of the methods of agentic classes. Whenever code execution enters an agentic class’ method, the Runtime pushes to the call-stack the docstring of that agentic class and of the called method (provided these docstrings are defined).\n\nIf an agentic class A’s method happens to call an agentic class B’s method, then the call stack will contain both the docstrings of agent A and agent B, along with their methods involved.\n\nThen, whenever the Runtime evaluates an LLM-expression, it synthesizes the current agent call stack into a system prompt which it provides when calling the LLM, giving the full context for the call.\n\n```\n+---------+                 +---------+                 +-----+\n| Agent A | -- method 1 --> | Agent B | -- method 2 --> | S() |\n+---------+                 +---------+                 +-----+\n                                                           |\n                                  System Prompt contains [A, 1, B, 2] docstrings\n```\n\nThis architecture for defining agentic application enables defining **modular** and **re-usable** agentic components.\n\nFirstly, the context to be provided for steering the behavior of an LLM can be split into the docstrings of various classes and methods, close to the “regular code” with which they are associated, and can then be “re-assembled” via the context call stack in many different configurations.\n\nSecondly, since the LLM-expression evaluation inherits the whole call stack, you can define “generic” agents exhibiting flexible behavior which can then be re-used in different contexts (as the calling agent will automatically provide more context in the call stack, “narrowing” the behavior of the “generic” agent which gets called)\n\nFinally, an agent class which inherits from Agent also needs to redefine its `__call__(self, prompt: str, **kwargs)` method, which should define the agent’s default behavior when called on an arbitrary prompt.\n\nA basic agent loop can then be easily defined in a few lines :\n\n```\nmy_agent = MyAgent()\nwhile (True):\n    prompt = input(\"Input your instructions\")\n    my_agent(prompt)\n```\n\n### The Runtime\n\nThe Runtime is the entity actually responsible for evaluating all the LLM-expressions. Its responsibilities are threefold :\n\n- It should allow for the configuration and monitoring of LLM-expression evaluation\n- It should implement optimizations to improve the performance of LLM-expression evaluations\n- It should implement context curation strategies in order to improve the correctness LLM-expression evaluations\n\nAs of now, the implementation of the runtime is very rudimentary :\n\n- There is no “control panel” or “monitoring dashboard”\n- It currently does not do implement any performance optimizations\n- It provides basic context curation via the agent call stack, by serializing its contents into a system prompt which it includes in LLM-expression evaluations\n\nThe next section will delve deeper into future improvements for the Runtime\n\n## Next steps and ideas\n\nThe next steps involve developing features in three main areas :\n\n- Improving the Runtime\n- Adding new syntax / language constructs\n- Creating a “standard library” of agentic components\n\n### Improving the Runtime\n\nThe Runtime is currently rudimentary, and there are many features to be implemented:\n\n- Configuration & Monitoring\n  - Add a configuration panel allowing you to configure the details of LLM-expression evaluations (api key used, model used, reasoning mode, etc.)\n  - Add a monitoring dashboard allowing you to trace (and debug) LLM-expression evaluations\n  - Add a monitoring dashboard allowing you to trace (and debug) the agent call stack and how it translates into system prompts\n  - Allow to dump / restore state\n- Performance improvements\n  - Batching LLM calls (especially for similar operations, such as for a map operation)\n  - Async-ification of LLM calls\n  - Parallelization of LLM calls\n  - Dynamic switching between models depending on the task complexity\n    - Especially dynamic switching between “generic” and “decision” models depending on the output type (switch to decision if it’s enum-like)\n  - Better handling of LLM calls : retries, output validation, error handling, failure recovery, etc.\n  - Caching of prompts\n    - Especially agent call stack system prompts\n- Context curation improvements\n  - Implement different strategies for synthesizing the agent call stack\n    - For instance, using an LLM to synthesize the agent call stack into a system prompt, instead of serializing the context call stack\n- Implement different strategies for synthesizing the agent call stack\n\n### Adding new syntax / language constructs\n\nAs of now, Semiotique is a Python library. However, the ambition is greater : to fully “enmesh” LLM-expression evaluation into regular code.\n\nThe current implementation is still very verbose, and feels “forced” at times. It would be nice, for instance to have :\n\n- Automatic type inference of LLM-expression outputs, instead of having to specify output_type\n- Easy constructs for typical tasks, such as routing or classification\n- Automated “compilation” of prompts, from more concise instructions, from placeholders, or perhaps from the surrounding code itself.\n\nA future implementation should thus provide more constructs for making it even more intuitive to blend regular code and LLM-expression evaluation.\n\nThis might require defining a superset of Python, switch to another programming language, or create a new programming language more adapted to this paradigm altogether.\n\n### Creating a standard library of agentic components\n\nFinally, Semiotique should provide a standard library of common agentic components (TBD) in order to aid in building agentic applications", "url": "https://wpnews.pro/news/semiotique", "canonical_source": "https://vkcr.dev/projects/semiotique/", "published_at": "2026-11-15 23:00:00+00:00", "updated_at": "2026-11-18 20:13:26.943570+00:00", "lang": "en", "topics": ["ai-agents", "large-language-models", "ai-tools", "developer-tools"], "entities": ["Semiotique", "LangGraph"], "also_reported_by": [], "takeaway": "Semiotique exposes LLM calls as a global S singleton evaluated from ordinary code, letting a runtime curate context while deterministic code drives the application instead of an autonomous agentic loop.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/semiotique", "markdown": "https://wpnews.pro/news/semiotique.md", "text": "https://wpnews.pro/news/semiotique.txt", "jsonld": "https://wpnews.pro/news/semiotique.jsonld"}}