Check the brain before calling ANY external API. The brain almost always has something. External APIs fill gaps, they don't start from scratch.
Without this: the agent calls Brave Search for someone you've had 12 meetings with. You get a LinkedIn summary instead of your relationship history.
With this: the agent pulls your compiled truth, recent timeline entries, and shared context before doing anything else. External APIs only fill gaps.
lookup(name_or_topic):
// STEP 1: Keyword search (fast, works day one, no embeddings needed)
results = gbrain search "{name_or_topic}"
if results.length > 0:
page = gbrain get {results[0].slug}
return page // done, brain had it
// STEP 2: Hybrid search (needs embeddings, finds semantic matches)
results = gbrain query "what do we know about {name_or_topic}"
if results.length > 0:
page = gbrain get {results[0].slug}
return page
// STEP 3: Direct slug (if you know or can guess the slug)
page = gbrain get "people/{slugify(name_or_topic)}"
if page: return page
// STEP 4: External API (FALLBACK ONLY)
// Only reach here if brain has nothing
return external_search(name_or_topic)
This is mandatory. An agent that calls Brave Search before checking the brain is wasting money and giving worse answers.
The brain has context no external API can provide:
- Relationship history (how you know them, what you discussed)
- Your own assessments (what you think of them, not their LinkedIn bio)
- Meeting transcripts (what was said, what was decided)
- Cross-references (who they know, what companies they're connected to)
- Timeline (what changed recently, what's trending)
A LinkedIn scrape gives you their job title. The brain gives you: "co-founded Brex, you had coffee with him 3 times, last discussed the payments infrastructure thesis, he's interested in your take on AI agents."
-
Try keyword first, then hybrid. Keyword search works without embeddings (day one). Hybrid search needs embeddings but finds semantic matches. Try both in sequence.
-
Fuzzy slug matching.
gbrain getsupports fuzzy matching. If the exact slug doesn't exist, it suggests alternatives. Use this for name variants ("Pedro" → "pedro-franceschi"). -
Don't skip for "simple" questions. Even "what's Acme Corp's address?" should check the brain first. The brain might have it, and the lookup adds no latency (< 100ms for keyword search).
-
Load compiled truth + recent timeline. The compiled truth gives you the state of play in 30 seconds. The timeline gives you what changed recently. Both together = full context.
- Ask about someone in the brain. Verify the agent searched the brain FIRST (check tool call order in the response).
- Ask about someone NOT in the brain. Verify the agent searched the brain, found nothing, THEN fell back to external search.
- Ask the same question twice. Second time should be instant (brain has it).
Part of the GBrain Skillpack. See also: Brain-Agent Loop, Search Modes