Company Brain: Should You Build, Buy, or Use a Framework?

Build vs buy for a company brain comes down to who runs permissions, freshness, deletion and review. Compare the three paths and the tests that decide.

Sam Bhagwat

Written by

Sam Bhagwat

Nov 18, 2026

·

25 min read

A company brain is a shared store of company and team context that agents read and sometimes write.

If you're comparing the build vs buy decision here, I'm going to assume you already know what retrieval is and how it works so we can skip the basics.

The choice between buying, building, or using a framework like Mastra comes down to who owns the jobs around retrieval and maintenance.

What do build, buy, or using a framework mean for a company brain?

Build, buy and using a framework differ in who runs each job around retrieval.

  • Build means your team writes and runs every part. That covers everything from the connectors that pull in sources to the permission check on each read. You own every decision and every outage.
  • Buy means a vendor runs the brain as a product, from the connectors to the search index. The vendor says it carries your source permissions over. Your team picks the sources and maps identities, matching each person's accounts across tools.
  • Framework means you write the application and take the hard parts from a framework. Here I'll use Mastra, an open-source TypeScript agent framework, as a reference across the piece. The framework supplies building blocks like scopes and search. You still run ingestion (pulling content in) and hosting.

In practice the three overlap. A custom build often calls a library. So ask which building blocks you borrow and which jobs stay yours.

How build, buy, or framework option leaves some jobs to your team

Each of the options will leave you with some part of the task you need to handle while the rest is taken care of by the provider you choose.

ExampleWhat it contributesWhat you still supply
Markdown in gitStorage, history, diffsIngestion, permissions, search, review
A temporal knowledge graph libraryGraph building and querying, marking facts invalid over time, links back to source documentsA graph database, an LLM, an embedder, ingestion, access control
Mastra KnowledgeAccess rules per page group, search, agent tools, pages pinned to every turnIngestion, identity, hosting, upkeep
A hosted company brain productConnectors, crawling, indexing, permission mirroringSource selection, identity mapping, review process

A temporal knowledge graph stores each fact with the dates it held. A build that uses one keeps history by default.

Build, buy and framework differ on the following decisions

Each row below is one decision, and each cell says who carries it under that option.

DecisionBuyFramework (Mastra)Build
Connectors and ingestionThe vendor ships and maintains a connector per supported sourceConnect supplies tools for supported apps; syncing their content into Knowledge remains your responsibilityYour team writes each connector and the store behind it
Read-time permissionsThe vendor mirrors source permissions and refreshes them by crawlKnowledge checks access; alpha scope isolation is not guaranteedYour code mirrors access rules or checks the source on each read
SearchThe vendor runs the index and sets the rankingKeyword search is built in, and you can add search by meaningYou choose, run and tune the search stack
Freshness and deletionThe vendor crawls on its own scheduleYour sync job loads and removes pagesYour code does all of it
Write reviewAsk where agent-proposed facts landRoles separate who adds notes from who edits pagesYou design the review path
Where your content sitsA copy of your content and its index sit with the vendorIn your own databaseIn your own store
Cost you carryVendor fees plus people for identity mapping and reviewYour hosting, model calls and the sync jobHosting, search infrastructure and upkeep of every part
Lock-inDerived summaries and memories may not exportContent sits in your own tablesFiles in git stay portable
Pick it whenNo one on your team will own connectors or identity crawlsYou want to own content and access rules without writing every partContent fits in git and a few people maintain it

How did Ramp and Uber build their own company agents?

Ramp and Uber each built their own agent on company knowledge. Each team had to settle what that agent may read.

Ramp built a data analyst agent that answers in Slack

Ramp, the corporate card and finance software company, built an in-house agent that answers data questions in Slack. Its engineers report that it answered over 1,800 data questions from 300 people after an early-August 2025 launch.

What it reads came down to a couple of early decisions. Domain owners wrote its documents and organized them as files, and the agent was kept away from personally identifiable information.

Uber built an on-call copilot for its Slack support channels

Uber's engineers ask around 45,000 questions a month in internal Slack support channels. Their on-call copilot runs in 154 Slack channels and has answered over 70,000 questions.

A channel answer is visible to everyone there, so Uber's team chose sources widely available to its engineers. It left out data that can't be exposed in a channel.

Both teams decided what the agent may read in their own code

Both teams controlled what the agent reads, and both had the engineers to write every part. Ramp kept personal data out of reach, and Uber left restricted sources out.

Uber's shortcut stops working once the brain holds pages only some people may open. From there, someone has to check each read against the reader, and the choice is who writes that check.

Who enforces company brain permissions at read time?

Permissions come first because they carry the highest risk in this choice. A leaked page is an incident, and a weak ranking is a bug.

Each option puts the permission check in a different place:

1. Bought company brain gives each user the access you set

A bought company brain mirrors the permissions you give each connected user. Say you invite 10 users and make 5 of them viewers, 3 editors and 2 admins.

Every request each of them makes runs with exactly that access, and so do the agents they start. You write no permission code for any of it.

The product keeps its own copy of those permissions, apart from the tools your pages come from. When the copy falls out of step, someone can see a page they shouldn't, so test the two places that happens:

  • Removed access. Take a page away from someone, then check how long they can still see it. The vendor sets that refresh cycle.
  • Hidden fields. Check that a field someone can't see in the source tool never shows up in an answer.

2. Company brain framework checks scopes your server supplies

With Mastra, enforcement moves into your code. Say the deploy runbooks sit in one group of pages that engineers may edit and sales can't open.

Mastra Knowledge groups pages into scopes, and gives each user a role in a scope, from reading to editing.

Your authenticated server sets each run's scopes, and Mastra checks the role on each tool call.

So Mastra writes the check, and your code decides who holds which scope. However, Knowledge’s alpha does not yet guarantee scope isolation; do not rely on it to isolate sensitive user or customer data.

That only works if the scopes come from a source you trust:

  • Logging a caller in doesn't grant data access. An MCP caller is a client that reaches your tools over the Model Context Protocol. Authenticating one does not authorize their data access.
  • Take the tenant from trusted server context. The tenant is the customer account a run serves. Never take it from arguments the model supplies.

3. Custom company brain build makes identity and ACLs your design

If you build, identity and ACLs are yours to design. ACLs, or access control lists, are the rules for who can open what.

You enforce them in one of two ways:

  • Mirror them on a schedule you choose. The refresh interval becomes an exposure window, the time a revoked user can still see a page. You own it and measure it.
  • Authorize against the source at read time. That removes the window. In exchange, each query pays in latency and availability.

LangGraph's long-term memory store shows what the build side looks like in code. Memories sit under namespace tuples, ordered lists of names that often include a user or org ID.

Search across namespaces uses content filters. So tenancy is a naming convention that your code must apply on every call.

How to test whether a revoked user still sees a page

Here's how you can test whether revoking permissions from a user allows them to still see the page, either for a certain amount of time or permanently, depending on how the company brain was designed:

  1. Pick a page with explicit view restrictions. Create one user who can open it and one who can't.
  2. Search for a distinctive phrase from the page as the user who can't open it. Do this through every surface you plan to ship, meaning search, answers, and the agent or MCP path.
  3. Revoke access from the first user in two ways. Edit the page's restrictions, and remove the user from a group. Query again after each change.

If text from the page reaches the user who can't open it, remove that source from the pilot.

Otherwise, record how long each revoked path keeps returning the page. Compare it with the cycle the vendor documents.

That measured delay is your exposure window. You decide whether the content can tolerate it. Under Mastra or a build, the delay comes from your own code, so you can shorten it.

Does company brain search match keywords or meaning?

Company brain search can match keywords, meaning or both depending on how the search functionality is designed.

Each option gives a different party that choice:

  • Buy. The vendor runs the index and sets the ranking. Search works from the first day, and ranking changes are the vendor's to make.
  • Framework. Mastra Knowledge includes keyword search, and adds search by meaning when you supply an embedder.
  • Build. You choose the search stack, run it and tune it.

Mastra Knowledge embeds up to 100 chunks per page. On a long page, text past that point is searchable by keyword only.

Permissions have a test, and answer quality needs one too. It takes three steps under any option:

  1. Write 20 questions your team asked last month, each with the page that answers it.
  2. Run them against each candidate as a user who may read those pages.
  3. Count how often the right page comes back.

Who builds and maintains company brain connectors?

The vendor supplies supported connectors under buy. With Mastra, Connect supplies ready-made tools for supported apps; syncing their content into Knowledge is a separate task.

Each source needs its own connector, and that connector must read the source's permissions as well as its content. The three options split that work differently:

  • Buy. The vendor ships a connector for each source it supports, and fixes it when the source's API changes. This is the strongest reason to buy. A source the vendor doesn't support waits on the vendor's roadmap.
  • Framework. Mastra Knowledge has no built-in importers yet. Connect can help seed it, but ongoing syncing and deletion handling remain your responsibility.
  • Build. Your team writes the same sync jobs. It also writes the page store, the index and the permission check they feed.

Count which sources need live tool access and which need copies kept in Knowledge; three sources do not necessarily mean three custom connectors.

How does a company brain stay fresh, and what happens when a source is deleted?

Each option handles freshness and deletion differently:

  • Mastra Knowledge. Seeding runs from your server. Deleting a source document doesn't delete its page.
  • A temporal knowledge graph. A graph that marks changed facts invalid keeps their history instead of deleting them. That suits audit. It conflicts with an erasure request unless you add a purge step.
  • A bought product. The vendor crawls on its own schedule, often with webhooks for live changes and slower backup crawls for anything a webhook missed. Ask for the cycle per connector, and ask how a deletion reaches the summaries the product derived from that source.

So here's a question you can ask when deciding whether it's more secure to build, buy, or use a company brain framework: Which one answers questions about a source document after it disappears, and for how long?

The answer will clarify if the company brain vendor (or framework) handles purging or if you have to do that.

Who can write to the company brain, and who reviews it?

Agents and people both need to be able to write.

Here, agents propose and a human reviews and publishes so there's always traceability and accountability of what goes into the company brain.

When we announced Knowledge, we described a team feeding unanswered support questions back into the knowledge base.

Prukalpa Sankar, co-founder and co-CEO of the data governance company Atlan, wrote in July 2026 that shared context needs an owner and reviewable proposals. Her controlled learning loop sends each proposed improvement to maintainers for approval, in three steps:

  1. As teams use the knowledge base, they flag what's missing or wrong.
  2. An agent drafts a fix for each flag.
  3. The owner of that area reviews the draft and publishes it.

Domain owners write the company brain pages that agents read

Much of what an agent needs is tacit, meaning nobody wrote it down. It lives with the people who own each area, such as the engineer who runs deploys.

So ask those owners to write up their areas, and record who wrote each page and when.

That record is provenance, where a fact came from, and it tells a reader whom to ask when a page looks wrong.

Human and agent edits to a company brain belong in separate records

Allen Pike, co-founder of Forestwalk Labs, wrote in August 2026 about simple steps toward a company brain. He keeps human and agent edits in separate commits.

He warns that agent-written analysis can be wrong without anyone noticing. That makes it worse than no documentation.

Mastra's roles also has the same split: a contributor adds notes, an editor changes pages, and Knowledge checks both roles at write time. A build writes that split itself, as a queue of proposals and an approval step.

A bought company brain should show where agent-proposed facts land

If you buy, check where agent-proposed facts land and who approves them. Some products store summaries and extracted memories next to your sources. So ask three more questions:

  • What does it keep beyond those?
  • How does it decide what to extract?
  • Does it expose the source of each memory?

Is it cheaper to build or buy a company brain?

Neither path is cheaper on price alone, because published prices cover only part of the cost. Each cost line below names who carries it:

  • Hosting and storage. Your database under Mastra or a build, the vendor's under buy. Switching providers means migrating existing data from a purchased company brain vendor.
  • Model calls at ingestion. A temporal knowledge graph makes a graph database, an LLM and an embedder your job.
  • Search infrastructure. On the build path, vector database providers differ in deployment models, filtering and access control. RAG platforms differ on ingestion and access control too.
  • Platform fees. The Mastra platform offers a hosted service along with it's open-source framework for deploying and observing Mastra apps. It starts Free with Starter available at $25 a month. Plans are metered on observability events, compute hours, connections and storage.
  • People. Identity crawls, cleaning up after deleted sources, and review queues. A bought product still needs someone on these, so add their time to the contract price.

People appear on no price list, so count the jobs that need a named owner. Buy leaves your team two, identity mapping and review.

Mastra adds the sync jobs and hosting, which makes four. A build adds the permission check and the search index, which makes six.

What does company brain lock-in look like?

Lock-in is the content and provenance you can't take with you when you leave.

So test for lock-in before you commit:

  1. Export a sample of pages with their authors and timestamps.
  2. Re-import them into a scratch store.

If the export loses authorship or history, the lock-in is in your provenance. The exit cost depends on the option:

  • Framework (Mastra). Your content sits in your own tables, and the framework is open source under the Apache 2.0 license. So the exit cost is rewriting the agent code and access rules written against Mastra's API. The pages stay where they are.
  • Build. The data stays in your own store, and Markdown in git is portable by design.
  • Buy. Ask whether the summaries and extracted memories the product derived can be exported with their provenance. If they can't, estimate the rebuild cost. That means the model calls and the time to re-extract from the sources.

How do you choose to build, buy, or use a framework for a company brain?

Decide by the job your team can't staff. List each source your production agents use for context, then name five things for each one:

  1. its owner
  2. its scope
  3. the agents downstream of it
  4. when it last changed
  5. how you would detect a bad change

A source with no owner or no detection path is a problem whichever option you choose.

Then match the option to the job you can't staff.

  • Buy when your sources are SaaS tools with per-user permissions, and no one on your team will own identity crawls. Run the restricted-page test on a pilot connector, including the MCP path. The test should confirm that MCP results respect the signed-in user's permissions. If restricted text appears, drop that connector.
  • Use Mastra when agents must write and your server already knows who the user is. Keep policy in a scope that only a lead role can edit. Give agents an append-only claims scope. Write the role matrix for your organizations. Then run explainAccess against it, which checks the declared rules. Do not rely on the alpha for sensitive-data isolation.
  • Build when your content is text that fits in git, a few people maintain it, and the questions are narrow. Sankar herself notes that small teams may need only explicit files, owners and evaluations for now. Pike's rules apply. Sync text with history, separate maintained pages from source material, and record provenance.

Buy removes the largest share of the work. The vendor then holds the refresh cycle, the ranking and the derived data.

A build keeps all three and makes your team write the permission check, the search and the review path. Mastra supplies those parts with no license fee, and your code still sets every rule.

Start with the permissions test, because it removes options faster than a price comparison.

What does a company brain need (irrespective of the option you choose)?

Whichever option you choose, keep a record of what the agent read before each answer. When an answer is wrong, that record shows whether the page was wrong, search picked the wrong page, or the model misread a good one.

Mastra records every step of an agent run, including which page each knowledge search returned.

Under buy, ask the vendor to show that record for one answer. Under a build, your code has to log it.

Mastra Knowledge is the framework option for a company brain

We built Knowledge for the middle option. It handles the hard parts with no license fee, and every rule stays in your code.

The teams we work with wanted to own their pages and their permissions. They didn't want to write the roles, the search and the agent tools from scratch.

Mastra Knowledge supplies five things.

  1. Scopes and roles checked on every tool call.
  2. Keyword search, with optional search by meaning.
  3. Pinned pages that reach every agent that may read them.
  4. Attributed notes and page versions.
  5. Read and write tools for agents.

The pages sit in your own storage, and your server decides which scopes each run holds. The framework is open source under Apache 2.0 and free to self-host.

Ingestion and retention stay yours, so the sync job is the part you build.

Mastra Knowledge comes in two forms, on either side of the line between framework and buy:

  • The library in Mastra's core package is a framework you run yourself.
  • The standalone service connects to the systems where your company already writes. So it sits closer to buy.

For teams that want the build done with them, our forward-deployed engineers work in your codebase.

They work under an enterprise license that includes Knowledge. If the permissions test and the five-minute audit leave you on the framework path, that's where to start.

FAQs

Enterprise search indexes documents and returns them to a person. A company brain serves agents as well as people. It holds pages that agents can update. It also has to decide, per run, which pages a reader may see. So write review and agent permissions are part of the design.

2. What carries over when I move from a bought index to Knowledge pages?

The source documents carry over, and the index doesn't. A bought product's index is derived from your sources. So a move means re-seeding pages from those sources and rebuilding search in your own store. What you lose is the derived layer:

  • extracted memories
  • summaries
  • any feedback the vendor recorded against answers

Export that layer as plain records before you cancel. Re-seeding brings back the pages, not the vendor's feedback or summaries.

3. Can I run the restricted-page test against a framework build?

Yes, and it's cheaper there than against a vendor. The test checks whether one user can find a page only another user may read:

  1. Put a page in a scope that only one test user's runs can read.
  2. Search for its distinctive phrase as a second user, through the agent path and any MCP server you expose.

Mastra's access check tells you what the declared rules say. The search tells you what the agent can see.

Run both, because a rule that reads right can still be wired to the wrong scopes.

4. How does agent memory relate to a company brain?

Memory holds what one person and one conversation produced. A company brain holds what the organisation shares.

A single agent can carry both, with memory scoped to each user and conversation, and shared knowledge scoped to the organisation or team.

So a user's preference never becomes a team page.

5. What should you check before buying a company brain product?

Run the restricted-page test on a pilot connector, through the agent path and any MCP server the product exposes. Then ask three things: the crawl cycle for each connector, how a deletion reaches derived summaries, and whether derived memories export with their provenance.

6. Who should own the company brain inside the company?

Give it an owner outside the agent team. The agent team owns retrieval quality.

The brain's owner approves what counts as policy. That's the reviewer role in the learning loop.

Without that split, the people who tune the agent end up deciding what the company holds to be true.

Share on X or LinkedIn
Sam Bhagwat

Sam Bhagwat is the founder and CEO of Mastra. He co-founded Gatsby, which was used by hundreds of thousands of developers. A Stanford graduate and veteran of web development, he authored 'Principles of Building AI Agents' (2025).

All articles by Sam Bhagwat →
All posts