Coding agents that retrieve the relevant file, not the similar one
Ask a coding agent to fix auth and it will happily read the three files named auth. The bug is in the middleware that calls them, which is named nothing like auth.
The mixture
- 01 · Persistent memory
- Uses
- 02 · Current context
- Uses
- 03 · Traceable decisions
- Light
- 04 · Shared context
- Uses
- 05 · Scoped retrieval
- Leads
Similar is not relevant
Coding agents are fast. Most of their wasted time is spent confidently reading the wrong files.
- 01
Names beat structure
Similarity ranks files by what they are called and what they say. The file that actually matters, the one that imports and wraps them, scores lower.
- 02
Decisions live outside the repo
Why the retry logic looks strange is explained in a PR discussion and a design doc. The agent reads the code, "fixes" the strangeness and reintroduces the bug.
- 03
Every session relearns the codebase
The agent rediscovers the same conventions every session: the test command, the lint rules, the directory nobody is allowed to touch.
Mostly scoped retrieval. Then three others.
Every application on Alchemyst is a different mixture of the same five jobs. That mixture is what makes this a different piece of software from the one next to it, even though the API underneath is identical.
The nearest match stops winning
Repository context is scoped by service and layer, and design docs and PRs are stored alongside the code they explain. Intersection narrows to the service being changed, subtraction removes generated and deprecated code, and ranking decides what the agent reads first.
- The relevant file beats the similarly named one.
- Design decisions travel with the code.
- Generated and vendored code stays out.
Uses · Persistent memory
Conventions, remembered
Test commands, lint rules and team conventions persist across sessions.
Uses · Shared context
Every agent, same map
Review, coding and docs agents read the same repository context.
Uses · Current context
The code on main today
Removed modules and merged branches are subtracted after merge.
That is four of the five. The fifth, traceable decisions (every answer carries the exact context it was served, and why), is what leads in Customer support, IT & incident response and Compliance & audit instead. Same API, different mixture.
The sources you already have
Connect through the Alchemyst MCP server in Cursor, VS Code or Claude Desktop, the OpenCode plugin, or index the repository directly with the SDK.
01 · Ingest
Scope what you ingest
Every document lands with a groupName: the sets it belongs to. Those sets are what retrieval intersects later, so the structure you choose here is the precision you get there.
context.addimport AlchemystAI from "@alchemystai/sdk";const client = new AlchemystAI(); // reads ALCHEMYST_AI_API_KEYawait client.v1.context.add({ context_type: "resource", scope: "internal", source: "github", documents: [{ content: "withSession() wraps every authenticated route. Token refresh happens here, not in auth/refresh.ts.", }], metadata: { fileName: "services/api/middleware/session.ts", groupName: ["codebase", "api", "middleware"], // the sets this belongs to },});02 · Write
Store the decision next to the code
The reason code looks strange is usually in a PR thread. Store it in the same scope as the file it explains, so the agent reads the why before it changes the what.
context.addawait client.v1.context.add({ context_type: "resource", scope: "internal", source: "github-prs", documents: [{ content: "PR #1184: retry refresh once, with jitter. Immediate retry caused a thundering herd on token expiry. Do not remove the delay.", }], metadata: { fileName: "pr-1184-session-retry.md", groupName: ["codebase", "api", "middleware"], lastModified: "2026-07-22T00:00:00Z", },});03 · Search
Search before editing
Search intersects the scopes, subtracts superseded and duplicate content, and ranks what survives. Only that reaches the model, and the whole decision is recorded as a Context Trace.
context.searchconst { contexts } = await client.v1.context.search({ query: "Users are logged out after token refresh", scope: "internal", similarity_threshold: 0.8, minimum_similarity_threshold: 0.5, metadata: { groupName: ["codebase", "api", "middleware"] }, // ∩ narrow scope});// − superseded, deduplicated → ranked → into the window// Every search is recorded as a Context Trace.const reply = await llm.respond(message, { context: contexts });
npm install @alchemystai/sdk or pip install alchemystai, both ship the same client. Full reference in the docs.
Source code is the crown jewels
Your repository, its history and its design docs are the most sensitive IP most software companies hold. Scope them per team and repository, and self-host the context layer when code cannot leave your network.
Security & complianceManaged cloud
Encrypted in transit and at rest, isolated per organization, and scoped at write time.
Dedicated infrastructure
EnterpriseSingle-tenant, with VPC peering when your data cannot share a network boundary.
Self-hosted
On-premiseRun the context layer on your own infrastructure, with OpenTelemetry for observability.
The same API, a different mixture
Each of these leads with a different job, pulls from a different set of sources and needs a different call. All of them, by job.
Bring the bug it fixed in the wrong file.
The one where the agent was confident, fast and in the wrong place.