Kit · Code

Code

Small, runnable implementations and templates. Each one is attached to a component on a map and links to the entry that explains it.

All examples live in one public repository, MIT licensed: github.com/stackunseen/examples

bash
git clone https://github.com/stackunseen/examples

Starter kit · Retrieval

RAG starter with hybrid search and recall at k

A complete retrieval loop you can run on a laptop, with no API key. Structure-aware chunks, BM25 and n-gram indexes fused into hybrid search, cited answers, an honest "I could not find this", and a 20-question test set that scores retrieval on its own.

python
@dataclass
class Chunk:
    id: str  # "<document>#<heading>", the citation a reader can follow
    title: str
    heading: str
    text: str
  • Python 3.11+
  • 8-stop tour
  • AI Application · Retrieval

Practice · Agent Orchestration

Keep a supervisor in control

Write the three parts that make a supervisor agent safe to leave running, hand-offs, a turn budget and an approval gate, and check your work against six tests. A scripted model means no API key.

python
  What happened                         Trace entry
  a specialist was called               ("call", name)
  the model named no such specialist    ("unknown", name)
  an approved action ran                ("ran", name)
  an action was refused                 ("denied", name)
  the model answered                    ("answer", "")
  • Python 3.10+
  • No API key
  • 4-stop tour
  • AI Application · Agent

Code example · Agent Orchestration

A supervisor as a LangGraph state graph

The supervisor from the framework-free example, rebuilt as an explicit LangGraph state graph with typed state, a deterministic router and edges you can review. Runs offline, with no API key.

python
class State(TypedDict):
    question: str
    context: list[str]
    answer: str
    next: Literal["retrieve", "answer", "done"]
  • Python 3.11+
  • langgraph
  • No API key
  • 4-stop tour
  • AI Application · Agent

Code example · Agent Orchestration

Multi-agent orchestration without a framework

A supervisor that calls two specialists as tools, in a loop your code owns. Python on the OpenAI SDK, TypeScript over the REST API.

python
def make_client():
    """Azure OpenAI when an endpoint is configured (it reads AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_API_KEY),
    otherwise the OpenAI API (it reads OPENAI_API_KEY)."""
    if os.environ.get("AZURE_OPENAI_ENDPOINT"):
        return AzureOpenAI(api_version=os.environ.get("OPENAI_API_VERSION", "2024-10-21"))
    return OpenAI()
  • 4-stop tour
  • AI Application · Agent

Template · Incidents

Blameless post-mortem template

A Markdown template for writing up an incident, built around how long it took to detect, decide and mitigate, the assumption that was wrong and actions with owners, with a section for incidents that involve an AI system.

markdown
<!-- Blameless: describe what people knew and did at the time, and why it made sense to them then.
     Name systems, changes and decisions, never a person as the cause. If a sentence would make
     someone defensive in the review, rewrite it around the process that let it happen. -->

Syntax highlighting is not available for this language. Showing plain code.

  • 5-stop tour
  • Developer Platforms · Observability

Template · Reviews

Security review pack for an AI feature

A Markdown template a team fills in before a security review. It covers data flows, data owners and freshness, retention and deletion, the identity each call runs as, a tool register, test results and the risks already accepted, and comes with a filled-in example.

markdown
## Data flows

<!-- Trace one request from the user to the answer and list every place data lands on the way.
     Teams most often leave the provider, the logs and the cache off the diagram, so those rows are already here.
     Attach or link the diagram as well. -->

Syntax highlighting is not available for this language. Showing plain code.

  • 5-stop tour
  • Security & Governance · Policy