Inspiration

Everyone has investment theses, like "humanoid robots are coming to every home" or "AI will strain the power grid." Turning a hunch into a portfolio takes hours of research, and letting an AI do it end to end is reckless. LLMs hallucinate numbers, and they shouldn't be deciding how much money goes where. We wanted to find out whether an AI workforce could do the research grunt work while structure keeps the judgment safe, and that structure had to come from code and humans, not prompts.

What it does

BrainTake turns a natural-language take into a sourced, sized portfolio.

  • Thesis agent breaks the take into themes and falsifiable hypotheses. It confirms US-listed tickers and gives each a 1~5 relevance score. If the take is vague ("tech will win"), it asks a clarifying question instead of guessing.
  • Research agent builds a fact sheet per ticker. Every figure is {value, unit, sourceUrl, asOf}, and a validator rejects any number without a source.
  • Portfolio agent passes the candidates to our broker, which computes everything with deterministic code:
    • eligibility, scoring, and weights (capped water-fill that sums to exactly 100%);
    • fractional-share orders;
    • hard limits: 25% max weight, $2.5k per buy, a daily buy cap, and exchange allowlisting.
  • A human approves through an admin CLI. No agent tool can approve. Execution is idempotent and all-or-nothing, and limits, expiry, portfolio version, and the kill switch are re-checked inside the write transaction.
  • Reporter agent writes the user report. A drift-band check (±5 pp or 25% relative) proposes a rebalance back to the executed targets.

The rule behind all of it: the LLM decides what and why, and code plus a human decide how much, when, and whether.

How we built it

  • Brainbase is the control plane: four agents with instructions, playbooks, secrets, and a directed orchestration. Each edge has a JSON-schema payload, and five model-judge evals score every turn.
  • practice-broker is a TypeScript MCP server: Streamable HTTP, bearer auth, 12 tools, and an SQLite ledger on node:sqlite. It's split into a pure domain layer, market-data adapters, the broker services, and an admin CLI that only a human on the host can run.
  • Market data: we use keyless SEC EDGAR (shares outstanding, 10-K revenue) plus Yahoo daily closes. For tests and demos we use a synthetic fixture set cited as fixture://, so fake numbers can never pass as real citations.
  • Process: an independent "CTO review" of the original plan came first, then TDD on the domain core. We ran a separate code-review pass, and a cloudflared tunnel exposed the local broker to hosted Brainbase.

Challenges we ran into

  • Approval could be forged. The first design had the agent pass approved=true itself. We moved approval completely out of band.
  • The limits contradicted each other. A 3-position minimum under a 25% cap can never add up to 100%. A $6k daily cap paired with all-or-nothing execution meant the initial $10k build could never execute.
  • Review found real races. The kill switch was checked outside the transaction, and concurrent idempotent creates could race. Per-order caps on sells could also trap a winning position. We fixed each one and added a regression test for it.
  • An eval false negative. Our Thesis agent asked for clarification correctly, through Brainbase's native request_user_input tool, but the judge only looked for a chat reply and failed it. We rewrote the criteria and confirmed a pass live.

Accomplishments that we're proud of

  • Safety holds by design, not by prompt. The MCP server simply has no approve tool, and a test asserts it.
  • A true end-to-end live run on Brainbase. Four agents handed off automatically. The Portfolio agent created a proposal and stopped at pending, and it executed only after a human approved.
  • Every eval passed live except one, and that one failure was a real behavior gap the eval was designed to catch.
  • Deterministic invariants: weights always sum to 10,000 bps, cash never goes negative, and every fill traces back to an approved proposal.

What we learned

  • Put determinism where the money is. LLMs are great at decomposition and explanation, and they should never output sizes.
  • Evals need testing too. A judge that misunderstands the platform's interaction model will fail correct behavior.
  • An independent review, both of the plan and of the code, caught flaws the author was blind to, including in the reviewer's own proposals.
  • "One testable task per agent" and schema'd handoffs make multi-agent systems debuggable.

What's next for BrainTake

  • A persistent deployment instead of a quick tunnel, then turning on the weekday rebalance schedule.
  • Live SEC and Yahoo data in the hosted run.
  • A multi-user ledger, and chat, Slack, and SMS entry points.
  • Securities-counsel review before anything leaves Practice Mode. Real money stays out of scope until then.

Built With

Share this project:

Updates

Submission history