The Hajar AI journal

Analysis & Opinion

Inside the systems we build with AI.
Notes on agents, retrieval, memory, and evaluation.

Context architecture01

Model swaps are context experiments.

Nikitha's research question is what happens to an agent's context strategy when its base model changes from Claude to GPT or Llama. One architecture repeatedly compresses history into summaries; another preserves files, structured memories, checkpoints, and logs that can be reread. Compression can discard information irreversibly, while external state offers a path to reconstruction.

The proposed experiment holds tasks, tools, and decoding settings fixed, then compares task success, state fidelity, and efficiency across model swaps. PromptBridge appears in the literature review as related work on cross-model prompt transfer. Whether external state proves more robust remains a hypothesis, not a reported result.

The takeaway

Benchmark context portability, not just model quality.

Agentic engineering02

Engineer the loop around the LLM.

Retries, triggers, and cron jobs are familiar software patterns. The difference with an LLM agent is what runs inside that loop: a probabilistic system that can choose tools, manage context, and decide its next action. Repeating execution does not by itself produce reliable autonomy.

Nikitha's focus is on the surrounding engineering: which state survives an iteration, how progress is measured, how results are evaluated, and when the agent should stop. These questions turn a tool-calling demo into a system whose behaviour can be inspected. The important design problem is reliable autonomy around nondeterministic decisions, not a new name for a loop.

The takeaway

Specify persistent state, evaluation, and termination.

Personalization03

Long-term memory can preserve bias, too.

Reflecting on an article about LLM stereotyping, Nikitha asks what happens when an assistant infers attributes the user never explicitly supplied. Assumptions about personality, socioeconomic background, or gender may influence the response, even when the user only asked for help with a task.

Longer-lived memory and richer context make this a systems question, not merely a wording problem. A personalization layer can carry assumptions into future answers alongside genuine preferences. Her central concern is the boundary between understanding a user and treating an inference as fact. More remembered context is not automatically better context.

The takeaway

Distinguish explicit preferences from inferred attributes.

Skills & MCP04

From chat prompts to reusable workflows.

The progression in Nikitha's post is concrete: add context, create reusable skills, connect tools, build workflows, then delegate small responsibilities. A skill file captures recurring instructions about tone, structure, and preferences; it avoids rebuilding the same prompt for every interaction with ChatGPT or Claude.

Connectors and MCP bring email, calendars, files, databases, and browser tools into that workflow. Her examples combine reasoning with action: extract meeting tasks, prepare a briefing, or draft an email and request approval before sending. The useful unit is a bounded workflow with a clear human handoff, not an ambitious agent platform built before a real task exists.

The takeaway

Persist instructions; connect tools; bound the responsibility.

Caching05

Five cache layers before another model call.

Nikitha separates agent caching into five layers: prompt-prefix caching for static instructions and tool definitions; semantic response caching for similar requests; tool-result caching for API outputs; embedding caching; and retrieval caching for repeated RAG searches. Each layer avoids a different kind of repeated work in planning, reflection, tool selection, or memory consolidation.

The exclusions matter just as much: fresh or safety-critical information, shared-cache PII, random outputs, and queries unlikely to recur. Choosing GPT-5, Claude, or Gemini does not remove these architecture decisions. Reuse must be appropriate to the data and request; a semantic match alone is not permission to return an old answer.

The takeaway

Optimize repeated work across the whole agent pipeline.

LLM reliability06

RAG, alignment, and verification are different levers.

Nikitha's research notes connect earlier hallucination work in translation and summarization with three later directions: retrieval-augmented generation, preference alignment, and reasoning verification. The named methods include RAG, RLHF, DPO, self-consistency, and process reward models. They operate at different points rather than forming one interchangeable fix.

RAG supplies external evidence. RLHF and DPO shape output preferences. Self-consistency compares sampled reasoning outcomes, while process supervision evaluates intermediate steps. Her broader theme is moving beyond fluent text toward grounded and checked outputs. These methods should not be presented as proof that hallucinations are solved, or that a particular lab deploys an identical stack.

The takeaway

Separate evidence retrieval, alignment, and reasoning evaluation.

Memory isolation07

The user_id existed. The retrieval filter did not.

In the memory-agent build log, the team reviewed system design, data flow, threat modelling, and decision records before setting two invariants: no cross-user memory leakage and no unnecessary exposure of sensitive information. Retrieved memories must belong to the correct user; unclear identity should fail safely.

The initial assumption was that user isolation required new architecture. Inspecting the baseline revealed that every stored record already carried user_id. Retrieval simply omitted the filtering condition. The lesson is specific: storing identity metadata does not enforce access control. Trace the requirement through the read path before adding new components or redesigning the schema.

The takeaway

An identity field is not an enforced isolation boundary.

Memory design08

Admission, ranking, and isolation need separate rules.

Nikitha's proposed next iteration separates memory admission from later access. Trigger words and repetition could nominate information for storage; sensitivity labels would restrict subsequent use rather than automatically discard every sensitive record. Retrieval would use similarity to narrow candidates and timestamps to distinguish newer relevant memories.

She also proposes moving user-scoping requirements into the database design, reducing reliance on every application query remembering its filter. Memory decay and access auditing complete the design direction. These are proposed controls awaiting implementation in that post, not evidence of an unbreakable system. Admission, ranking, isolation, and auditing each need their own verification.

The takeaway

Enforce user scope structurally, then test the boundary.

Agent evaluation09

Completion over compliance is a failure mode.

Nikitha describes an agent failure pattern in which a model produces a finished-looking answer despite missing tools, ambiguous instructions, or insufficient evidence. She calls attention to the phrase 'completion over compliance': the appearance of task completion can hide that the requested operation was never honestly performed.

The attached Karpathy example illustrates a related issue: an LLM can improve an argument, then persuasively dismantle it when asked to argue the opposite. Neither rhetorical confidence nor a complete response establishes correctness. For builders, this points to evaluating missing-tool behaviour, clarification, and unsupported claims, rather than scoring only whether the output looks finished.

The takeaway

Test honest failure and clarification alongside task success.

Token-space learning10

An agent can adapt without updating weights.

Drawing on Letta's discussion of continual learning in token space, Nikitha treats the agent as more than a foundation model: prompts, memories, retrieved documents, tools, and history also shape behaviour. Updating those persistent inputs differs from fine-tuning or reinforcement learning that changes model weights.

Simply appending conversation logs is not the same as consolidating experience. Token-space memory can be inspected, edited, versioned, and rolled back. The post also considers between-task 'sleep-time compute' for resolving contradictions and extracting reusable lessons. Such context may survive a model upgrade, but its effectiveness with a different model still needs testing.

The takeaway

Treat persistent context as an inspectable adaptation layer.

Enterprise architecture11

MCP connectivity is not a company brain.

Connecting Slack, Notion, Drive, Jira, or Salesforce gives an agent access, not shared understanding. Nikitha identifies failure cases such as retrieving an old proposal as a final decision, confusing similarly named projects, or surfacing information outside a user's permissions.

Her architecture discussion combines knowledge graphs for entity relationships, MCP for tool connectivity, skills for task procedures, and hybrid search for acronyms and semantic queries. Agentic RAG adds source selection, question decomposition, comparison, and further retrieval when evidence is insufficient. The goal is a permission-aware, traceable knowledge system that can resolve conflicting records, not simply search more connected applications.

The takeaway

Separate connectivity, retrieval, relationships, and authority.

Adversarial evaluation12

A memory baseline needs hostile test cases.

The baseline stores a plain list of records containing text, user_id, and an embedding. Retrieval ranks all memories by cosine similarity; the prompt builder adds ranked records until the token budget is exhausted. The answer stage passes that context to an LLM without recency, sensitivity, or user filtering.

Nikitha tests stale preferences, wrong-person facts, sensitive information, token-budget competition, cold starts, and multi-user leakage. These scenarios expose distinct missing controls that a friendly demonstration would hide. A correct-looking response is not sufficient if the retrieved context belongs to another person or silently crowds out the current preference.

The takeaway

Evaluate retrieval safety as well as answer quality.

Memory pipeline13

Embed, rank, pack: an intentionally weak baseline.

The architecture carousel makes both paths explicit. On write, text is embedded and appended to an in-memory list with its user identifier. On read, the query is embedded, candidate memories are compared using cosine similarity, and ranked entries are packed into a bounded prompt before the LLM generates an answer.

There is deliberately no admission intelligence, privacy enforcement, recency handling, conflict resolution, or uncertainty logic. That simplicity makes failure attributable: an incorrect answer can be traced back through storage, retrieval, and context assembly. This is a diagnostic baseline for deciding which controls to add, not an architecture proposed for production deployment.

The takeaway

Use a transparent baseline to expose missing controls.

Retrieval failure14

Cosine similarity cannot resolve whose fact it is.

The memory carousel shows why semantically similar records are not interchangeable evidence. In the example, a question about the user's age retrieves a sister's age. All candidates concern age, but their subject differs. Another example contrasts an older Intel job memory with a newer Agentic AI record.

Embedding similarity ranks topical proximity; it does not establish ownership or which contradictory fact remains current. Packing the highest-ranked records into context leaves that ambiguity for the LLM. Nikitha's diagnosis is that identity, recency, and conflict resolution need explicit treatment around retrieval. A higher score cannot substitute for the missing semantics of the record.

The takeaway

Rank relevance only after preserving identity and time.

Context retrieval15

Keyword search and embeddings fail differently.

Nikitha compares three attempts at persistent personalization. Pasting an entire tone document into each chat eventually adds irrelevant context. Keyword matching misses related expressions such as 'snappy' and 'punchy'. Semantic search improves matching but can retrieve both a soft-tone preference and a conflicting rigorous-tone preference.

The missing information is not just meaning: it is when a preference was recorded, whether it applies now, and which user it belongs to. The proposed system needs timestamps, selective context packing, sensitive-information screening, and user isolation. More retrieval alone does not solve the contradiction introduced by keeping an outdated preference.

The takeaway

Combine semantic relevance with freshness and scoped context.

Memory schema16

Design the record before the memory pipeline.

The two-slide memory model distinguishes six subsystems: capture, storage, retrieval, evaluation, decay, and governance. The first three make a working demo visible; the others address stale preferences, unverifiable facts, and information that should not have been retained or reused.

Importance, confidence, and source are the record fields emphasized in Nikitha's post and carousel. They give later decisions something to inspect: whether information is useful, how certain it is, and where it came from. Without that structure, retrieval can return text while the system remains poorly equipped to evaluate, age, or audit what it remembers.

The takeaway

Make trust metadata available to downstream decisions.

Hybrid retrieval17

Choose retrieval from a query set, not a default.

Nikitha's retrieval experiments compare exact keyword matching, dense semantic search, image-oriented queries, and finding the relevant passage within a longer document. A single retrieval method did not serve all of those needs: exact wording and loosely described concepts produce different failure modes.

Her practical habit is to write five or six representative queries and define a good answer before choosing the retrieval setup. The post discusses experimenting with Pinecone, filtering, and reranking to test combinations. The architectural lesson is to validate retrieval against the actual query distribution instead of assuming a vector index is sufficient for every RAG workload.

The takeaway

Build a query set before choosing your retrieval strategy.

RAG build log18

DatasheetIQ: chunking is a faithfulness decision.

DatasheetIQ answers semiconductor-datasheet questions with page references. Nikitha tested four configurations using RAGAS. Splitting electrical-characteristics tables could separate headers from values; preserving tables improved a reported faithfulness comparison from 0.77 to 0.92. Exact part numbers such as TPS7A4001 motivated BM25 plus dense retrieval rather than semantic matching alone.

The reported stack includes pdfplumber, BAAI/bge embeddings, Pinecone, FlashRank CrossEncoder, LangChain, LangGraph, Nebius, RAGAS, and LangSmith. A second grounding check caught an out-of-corpus chip that passed a confidence gate. These are project observations, not universal benchmark results; chunking thresholds also behaved differently across document domains.

The takeaway

Preserve tables, retrieve identifiers, and verify grounding.

RAG observability19

Measure generation, retrieval, and cache hits separately.

In Nikitha's RAG build log, adding instrumentation revealed a reported response-time split of roughly 60% generation and 40% retrieval. The observed cost was $0.002 per question. A repeated query returned from cache in 5 ms without another model charge; those measurements describe her experiment, not a service guarantee.

The important change was visibility into latency, cost, and failure instead of adding another user-facing feature. Dependency changes, an installer targeting the wrong location, and an unavailable model also interrupted the build. Without that visibility, both optimization and debugging would have been driven by guesses rather than the stage that actually failed.

The takeaway

Profile each pipeline stage before choosing an optimization.

Coding agents20

Claude Code puts context budgets in focus.

Nikitha's reading notes on a Claude Code architecture analysis focus on the infrastructure around the model: permission checks, recovery, context compaction, deferred tool schemas, capped tool outputs, and lazy loading of CLAUDE.md instructions. Subagents returning summaries rather than complete transcripts are another way to limit parent-context growth.

These notes describe an external analysis, not a verified inventory of the current product. The enduring engineering question is how to coordinate tool use and delegated work within a finite context window while retaining meaningful oversight. Repeated approval prompts and generated code that users do not understand can undermine the apparent productivity gain.

The takeaway

Budget context and preserve reviewability across delegation.

Context engineering21

BM25, rank fusion, then a reranker.

Nikitha's first RAG assistant produced confident answers with citations but fabricated numbers. Her diagnosis was poor retrieved context, not simply weak instructions: the relevant information was not reaching the model. Rewriting the prompt would not repair that upstream failure.

She added keyword retrieval alongside semantic search, combined ranked results with Reciprocal Rank Fusion, and used a reranker to evaluate the question against each candidate chunk. The change improved the information supplied for generation. The lesson from her discussion of Karpathy's context engineering is concrete: inspect retrieval, ranking, and context assembly before treating every wrong answer as a prompting problem.

The takeaway

Fix the evidence pipeline before polishing the prompt.