Sunday, November 29, 2026

Small Agentic Glossary


Techniques

RAGAS
RAG Assessment where RAG is Retrieval-Augmented Generation

Chunking
Breaking down documents into lexical or semantically coherent sections so we don't waste the context window. Bad chunking strategies can seriously degrade RAG performance.

Distilled models
Where a large model 'teaches' a much smaller one so it can learn as much of its teachers weight distribution as it can. The smaller model may start with random weights or a large model with (say) half its layers removed.

Abliteration
This technique can remove censorship. By comparing activations for acceptable versus unacceptable input, the part of the LLM that is responsible for censorship can be neutralized.

Classification

Zero-shot Classification
A type of classification that classifies on the fly and does not require training examples.

Brier Score
Simple equation for measuring how confidently right or wrong an answer is.

GLiClass
Generalist and Lightweight Model for Text Classification. Zero-shot, ultra lightweight and forward pass only.

Perplexity
A mathematical formula based on cross-entropy for showing how confident a model is when choosing words. Note, it does not measure intelligence but verbal fluency.

Terminology

Joint Vector Space
Also called a shared embedding, it is a mathematical space where conceptually similar vectors live together (eg "I lost my credit card" and "billing and payment").

LSP
Language Server Protocol is a standardized communication protocol created by Microsoft that defines how a code-parsing plugin talks to an editor or an AI harness.

Model Context Protocol
Open standard that allows LLMs to talk to external services.

A2A
This is a protocol that came out of Google allowing agents to discover and talk to each other. If an agent discovers another specializes in something, the first can delegate to the second.

Agent
The agent makes decisions. It is non-deterministic as it relies on an LLM.

Harness
If the agent needs data, the harness gets it. It manages memory and context. It loops until the job is done. It is deterministic in that it just makes calls.

Agents vs Harnesses
The agent is what the model wants to do but the harness is what allows it actually safely do it.

Runtime

Prompt Processing (aka Prefill Phase)
This is the conversion of the text to KV attention matrices. It determins the TTFT (time to first token). TTFT obviously increases the longer the context becomes.

Pipeline Parallelism
For huge LLMs, it makes sense for layers to live on different GPUs simply to fit into VRAM. This opens up the opportunity of parallelising work loads. 

Reward Hacking
This is a pathological case where the LLM learns to do the wrong thing to minimize its loss function. Imagine a junior developer who fixes the build by deleting the failing tests.

Implementations

Agent Harnesses
While Claude etc are the agent models, Claude Code is the agent harness. Open source alternatives to Claude Code are Pi, DeepSeek Harness and OpenCode.

Jev
A closed source, System One descision model. It is not generative but gives a probability distribution over its classifications. System One refers to Daniel Kahneman's two types of thinking. Open source competitors exist including Kev, Laya, NanoJev, Von and SemIf.

TokenWing
This has some really clever ideas that allow an LLM larger than a machine's VRAM to be processed. These techniques include caching 'hot' parts of the LLM and running some computation in RAM rather than VRAM. The major downside is that this won't work for dense models but rather mixture-of-expert models.

Sunday, November 22, 2026

Polaris and KeyCloak

Some more notes on the architecture of Spark, Polaris and KeyCloak.

Polaris/KeyCloak

Polaris is configured with the property quarkus.oidc.auth-server-url pointing at the KeyCloak server it's going to use for OIDC. You could have the Iceberg client use another OAuth2 server by setting spark.sql.catalog.CATALOG.oauth2-server-uri to something else but its token will not be signed with the private key of the KeyCloak given to Polaris at startup and so its public keys available for Polaris at the OIDC provider's standard endpoint will not decode it.

You don't need to set oauth2-server-uri in your Spark config if you're using an OIDC token. Its iss property will define that. You only need it if you are using spark.sql.catalog.WAREHOUSE.credential rather than a .token.

The Spark setting spark.sql.catalog.WAREHOUSE.scope is a request for access. Unknown scopes get an invalid_scope response but openid is always accepted and is the means for getting an OIDC token. Scope PRINCIPAL_ROLE:ALL is a Polaris convention and is only used when Polaris is in internal mode (polaris.authentication.type=internal), that is, issuing the tokens itself.

Note that both KeyCloak and Polaris have an entity called a 'realm'. These are conceptually the same in that the isolate users, roles, principals etc but are orthoganol. That is, they don't map to each other except through standard mechanisms of OIDC tenants and server URLS - neither of which are Polaris/KeyCloak specific, unlike realms.

The Token

In the OIDC token there is the header, the payload and the signature.

The payload will contain something like this:

  "iss": "https://YOUR_OAUTH2_DOMAIN/realms/polaris",
...
  "aud": "account",

Here, account is the default for KeyCloak. It only matters if Polaris is configured with quarkus.oidc.token.audience and then only tokens that have that audience are allowed. 

The Flow
                                  
With no KeyCloak cookie, oauth2-proxy forwards the browser to Keycloak for MFA. It adds X-Forwarded-Email to the requests it passes on. Only Guacamole reads that header. It trusts the header, so Guacamole only accepts connections from the oauth2-proxy pods. Without that rule, anything that could reach Guacamole directly could send a fake header and act as any user. But it's needed to distinguish one session from the other.

The user now arrives at the hub without a hub session, so the hub redirects your browser to KeyCloak's authorization endpoint. But KeyCloak sees its own session cookie from the MFA login a moment earlier, so it doesn't ask you anything. It sends the browser back to /hub/oauth_callback with a short-lived and single-use authorization code.

The reason the authorization code is short lived is because it can leak into logs, browser history etc. If we used the OIDC_TOKEN, well that's designed to live for potentially hours. 

The hub sends that code, together with its client secret  (OAUTH_CLIENT_SECRET), to KeyCloak's token endpoint. This secret never leaves the cluster, unlike the authorization code for security reasons. This call to KeyCloak is a direct server-to-server call. KeyCloak only accepts it if the redirect URI matches one that is registered. KeyCloak returns the access token and the ID token, and the browser never sees either.

Monday, November 9, 2026

Spark authorization using KeyCloak

Spark is great but how do you stop users seeing data they should not if you are building your own on-prem solution?

KeyCloak

KeyCloak is an Identity and Access Management (IAM) solution. It implements both OAuth2 (authorization - that is, what you can do) and OIDC (authentication - who is doing it). OIDC extends OAuth2 by, for example, adding standardized endpoints.

Because of this, a lot of the terminology in these standards applies to KeyCloak. But, in addition, KeyCloak has some of its own - Realms for example. (Incidentally, KeyCloak can serve its own login page for your protected application. This would live under /realms/YOUR_REALM)

Clients are for machines and processes, users are humans. Clients have secrets, users have passwords. They are totally orthoganol concepts. A client and a user that have the same name are not related. However, a client must act as the gateway for a user who wants a token.

The grant_type describes the flow - that is, what's happening. This could be a user logging in via MFA (authorization_code issued by the IdP when the browser redirects to it) or back end servers talking to each other using service accounts (client_credentials) or an interactive session (password).

One such flow is Direct Grant Flow, where an app fronts the login page that is sent to KeyCloak that then mints the token. It is heavily discouraged as it circumvents MFA. 

The standard flow is the usual "log in with a username/password and then use MFA". This is the default, built-in flow although you can add your own custom flows.

When Spark is configured to use the OIDC token (that is, with spark.sql.catalog.<catalog_name>.token as Spark configuration), it sends it directly to Polaris with the HTTP header Authorization: Bearer <token>. Polaris then validates this with KeyCloak rather than using a grant_type.

Claims are properties of a token. There are some reserved ones but you can define your own.

Spark

So, when Spark is configured to read an Iceberg table using Polaris, it differs to Iceberg code's OAuth2Manager. It's this that makes the call to Polaris with the relevant grant_type.