lang_ex AGENTS.md

Repository instructions for LangEx, an Elixir framework for building multi-step AI workflows with state, routing, checkpoints, and human approval.

In plain words
What is it for?
Use them when developing, testing, formatting, or reviewing LangEx workflow code and its Redis or PostgreSQL integrations.
Why use it?
They explain the project's architecture, required checks, dependencies, and test commands so changes follow its conventions.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/freshaengineering/lang_ex/agents-md
Clone the repo
git clone --depth 1 https://github.com/freshaengineering/lang_ex

Made for: Codex, OpenCode.

Per session 3,305 This file is loaded in full into every session.
When invoked 3,305 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03305 $0.03305
Opus 5 $0.01653 $0.01653
Sonnet 5 $0.00661 $0.00661
Haiku 4.5 $0.00331 $0.00331

Measured 2d ago against content hash 5fb94eb02032, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

lang_ex AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 240 lines

How it starts

The opening of the file, as written. The whole thing — 240 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LangEx

Graph-based agent orchestration for Elixir. Builds stateful, multi-step LLM workflows using nodes, edges, conditional routing, state reducers, human-in-the-loop interrupts, and checkpointing. Inspired by LangGraph, built on BEAM primitives.

  • Version: 0.11.0, Elixir: ~> 1.16
  • Deps: req, jason, telemetry; optional redix, postgrex, ecto_sql, opentelemetry_api, opentelemetry_telemetry
  • Test: ExUnit with mimic for mocking

Commands

mix deps.get                          # Install dependencies
mix compile --warnings-as-errors      # Compile (0 warnings required)
mix test                              # Run all tests (integration excluded)
mix test --include integration        # Also run Redis/Postgres tests (needs docker compose up)
mix test path/to/test.exs:42          # Run specific test
mix format                            # Auto-format
mix format --check-formatted          # Check formatting

Integration tests read LANG_EX_REDIS_URL / LANG_EX_POSTGRES_URL (defaults match docker-compose.yml).

Always run mix compile --warnings-as-errors before considering work done. Zero warnings required.

Architecture

LangEx (facade: invoke/3, stream/3, get_state/2, get_state_history/2, update_state/3, delete_thread/2)
├── Graph                             # Builder: new, add_node (+retry/cache/defer/timeout/on_error), add_edge, compile, to_mermaid
│   ├── Graph.Compiled                # Compiled executable graph
│   ├── Graph.Pregel                  # Super-step execution engine (internal)
│   ├── Graph.RetryPolicy             # Exponential backoff + jitter for retry: nodes
│   ├── Graph.State                   # State management with reducers
│   ├── Graph.NodeCache               # Bounded ETS memoization for cache: nodes
│   └── Graph.Stream                  # Lazy event streaming with modes + emit/1
├── NodeError / NodeTimeoutError      # Structured node failure contract ({:error, %NodeError{}})
├── LLM                               # Behaviour for provider adapters
│   ├── LLM.Anthropic                 # Claude adapter (streaming SSE)
│   │   ├── Anthropic.SSE             # SSE state machine (internal)
│   │   └── Anthropic.Formatter       # Message wire format (internal)
│   ├── LLM.OpenAI                    # GPT adapter
│   ├── LLM.Gemini                    # Gemini adapter
│   ├── LLM.Resilient                 # Retry wrapper with backoff
│   ├── LLM.ChatModel                 # Graph node helper for LLM calls
│   └── LLM.Registry                  # Provider resolution by model string
├── Tool                              # Tool/function definition struct
│   ├── Tool.Node                     # Graph node for parallel tool execution
│   └── Tool.Annotation               # Error recovery guidance for LLM
├── Message                           # Chat message types (Human, AI, System, Tool, RemoveMessage)
├── Middleware                        # Composable agent hooks for Prebuilt.agent
│   ├── Middleware.ModelRequest       # The model call as data, with override/2
│   ├── Middleware.Summarization      # LLM-summarised, persisted context compaction
│   ├── Middleware.ContextEditing     # Clears stale tool-result contents (no LLM)
│   ├── Middleware.TodoList           # write_todos planning tool + :todos state
│   ├── Middleware.ToolSelector       # LLM tool pre-selection for large tool sets
│   ├── Middleware.ToolApproval       # Human review of guarded tool calls (HITL)
│   ├── Middleware.ToolRetry          # Retries transient tool failures in place
│   ├── Middleware.CallBudget         # Caps model calls / tokens per run
│   ├── Middleware.ModelFallback      # Retries a failed call on fallback models
│   ├── Middleware.Subagent           # Delegation to nested agents as tools
│   ├── Middleware.Filesystem         # Sandboxed file tools
│   └── Middleware.Rubric             # Completion gate scoring the final answer
├── Checkpoint / Checkpointer         # Pause/resume with Memory, Redis, or Postgres
├── Store                             # Long-term memory (ETS / Postgres backends)
├── Migration                         # Versioned Postgres migrations (V1, V2)
├── Prebuilt                          # Ready-made agent graph constructor
├── Command / Send / Interrupt        # Graph control flow primitives
├── Config                            # Layered config resolution
├── ContextCompaction                 # Context window budget enforcement
└── Telemetry                         # Telemetry event definitions (+ Runs, OTel bridge)

Read the full file on GitHub · 240 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 240 lines · 3,305 tokens per session scan A 5fb94eb02032

Subscribe to this mod's changes

lang_ex AGENTS.md is an instructions file published in the GitHub repository freshaengineering/lang_ex (40 stars, last pushed 5d ago), licensed MIT. It adds 3,305 tokens to every session, about $0.0165 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.