# Building a Agentic AI Trading Heartbeat That Works <!-- ref: @content/youtube/all-about-ai/building-a-agentic-ai-trading-heartbeat-that-works tags: [AI agents, sub-agents, heartbeat loop, context and token cost, goal setting, hedging, Codex, model routing] version: 2 updated_at: 2026-11-24T05:22:19.255Z --> **[Watch on YouTube](https://www.youtube.com/watch?v=LNjrRJRCY_g)** # Building a Agentic AI Trading Heartbeat That Works *Synthesized from All About AI, 2026-06-01; speakers are not named in the source.* A single presenter, identified only by the channel, walks through a live demo of an agent setup built in OpenAI's Codex. The video is an initial take that the presenter expects to refine. ## Core Thesis The presenter argues that an agent acting on a live, changing position needs a "heartbeat": a periodic loop that re-reads current state and decides again. Their setup splits the work between a cheap, fast sub-agent that compacts raw data into a structured digest and a stronger main agent that makes the decision, so the expensive model sees only the digest and not the raw feed. ## Key Insights - **Two-tier agent split.** A read-only "trade data reporter" sub-agent runs on GPT-5.4 mini and reads the live websocket feed. The main Codex agent runs on GPT-5.5 at high reasoning and consumes only the sub-agent's JSON digest, which the presenter describes as a way to save tokens. - **Fixed heartbeat interval.** The main agent sleeps for 30 seconds, pulls the digest, and makes a hold, hedge, or exit decision on each pass. - **Goal as decision input.** The presenter sets a target profit with a time limit, using Codex's `/goal` command, so the agent can scale its risk to the goal. A $1 target in 30 minutes implies lower risk than a $10 target on the same $50 margin. Codex asked for a maximum acceptable loss, which the presenter set at $100, and then computed entry parameters. - **Setup shown.** A $50 margin, 10x leverage short on the S&P 500 on Hyperliquid, with a 30-minute time stop, one live leg, and the option of adding hedges. - **Hedge and scale-up on signal.** On a simulated hedge signal, the agent chose a long NVIDIA position at about a 25% hedge ratio (5x) instead of shorting the index further. On a later strong signal, it closed the hedge and added a $50 same-side short with an add-to-position flag, bringing margin to $98. - **Cost argument.** The presenter says the sub-agent is needed because raw market data is too large to feed to the main model on every loop. - **Stated limits.** The presenter calls the hedge scenario unrealistic and says the setup is an initial take with more work ahead. The video also previews a later look at `/goal` for long-running work across turns. ## Actionable Takeaways 1. Put a small model in front of a high-volume data feed to produce a structured digest, and give the main agent only that digest. 2. Run the main decision loop on a fixed interval (the presenter uses 30 seconds) rather than on every data event. 3. Set an explicit goal, a maximum loss, and a time stop before the agent acts, so it can size risk against them. 4. Check each decision against the stated goal and the current position before the agent acts on it. ## Notable Quotes > "we really want to save tokens when we feed that into kind of let's say our main model here" — the unnamed presenter, All About AI > "monitor this and feed this into our Codex agent, our main agent." — the unnamed presenter, All About AI > "we want the system to have something to aim for, right?" — the unnamed presenter, All About AI --- *Related: `@content/youtube/dan-martell/you-only-need-6-months-to-change-your-life` · `@content/youtube/yifan-bth/i-reverse-engineered-claude-code-learn-these-agent-tricks` · `@content/youtube/david-ondrej/fine-tune-the-biggest-open-source-models-even-with-a-bad-pc` · `@content/youtube/david-ondrej/tailscale-clearly-explained-beginners-guide` · `@content/youtube/nate-herk/how-anthropic-engineers-actually-prompt-fable-5`* --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*