Skip to content

[Integration] Optional /review verdict between Risk Manager and Execution agent #39

Description

@babyblueviper1

TL;DR

The current 4-agent pipeline (Director → Quant → Risk Manager → Execution) is well-structured, but the Risk Manager's verdict is graded by the same LLM family that wrote the original thesis in the Director step. The agent-coding community has been converging on constitutional governance as the response to that gap — a cross-family check on irreversible action that's blind to the original chain-of-thought (Spec Kit's constitution mechanism, BMAD's implementation-readiness gate, Farrag's 2026 review puts both at the top of the governance spectrum). I've been building a Lightning-paid endpoint (/review/external) that does exactly this for trade decisions: takes the proposal as an artifact, returns a structured verdict (approve | approve_with_concerns | reject) before any irreversible action.

The use case

After the Risk Management Agent sizes the position but before the Execution Agent fires on Solana, run the proposal through /review/external — a different model (Sentinel) reads the sized proposal with no access to the Director's original reasoning. That's the constitutional layer Spec Kit/BMAD describe: independent, blind, structured, mandatory. It's not a smarter Risk Manager; it's a different governance tier on top.

This complements the existing 4-agent flow, doesn't replace any agent. Same shape as adding a constitution to a Claude Code project — a meta-check that lives above the per-step logic.

How it works

  • Endpoint: POST https://api.babyblueviper.com/review/external
  • Auth: Bearer token (free /register) or L402 pay-per-call
  • Pricing: ~390 sats per call for a typical risk-proposal-sized artifact; rate-limited 5 reviews/min; max artifact 20,000 chars
  • Returns: structured {verdict, confidence, issues} JSON
  • MIT-compatible, no telemetry, no required signup
import os, requests

def invinoveritas_review(decision_artifact: str, context: str, concerns: str) -> dict:
    """Second-opinion verdict on the Risk Manager's sized proposal.

    Returns: {"verdict": "approve|approve_with_concerns|reject",
              "confidence": 0.0..1.0,
              "issues": [{"severity": ..., "summary": ...}, ...]}
    """
    r = requests.post(
        "https://api.babyblueviper.com/review/external",
        headers={"Authorization": f"Bearer {os.environ['INVINOVERITAS_KEY']}"},
        json={
            "artifact": decision_artifact,
            "artifact_type": "agent_output",
            "context": context,
            "concerns": concerns,
        },
        timeout=30,
    )
    r.raise_for_status()
    return r.json()


# Slots between RiskManagement.run() and ExecutionAgent.run()
def review_before_execute(proposal: dict) -> bool:
    v = invinoveritas_review(
        decision_artifact=str(proposal),
        context="AutoHedge risk-sized proposal before Solana execution",
        concerns="sizing, leverage, exit conditions, market depth",
    )
    if v["verdict"] == "reject":
        return False
    if v["verdict"] == "approve_with_concerns" and v["confidence"] < 0.6:
        return False
    return True

Cost shape (honest)

POST /register is free and returns 250 non-withdrawable starter sats — enough for a couple /reason calls (~100 sats each) but NOT enough for a single /review/external call. To evaluate /review/external against a live trade, top up ~1k sats via Lightning (POST /topup returns a bolt11 invoice). Single call is bounded at ~390 sats for a typical risk-proposal-sized artifact.

Why post here

The pipeline shape is the cleanest 4-agent split I've seen for crypto trading, and the Risk Manager → Execution boundary is exactly the irreversible-action gate this kind of tool was designed for. If there's interest, happy to open a PR adding it as an optional tools/ integration behind a feature flag, alongside the existing OpenAI/Anthropic provider config — keep it off by default, opt-in via env var.

Quick questions back to the maintainers

  1. Is the Risk Manager → Execution handoff the right insertion point, or would a verdict at a different boundary (e.g., after Director, before Quant) be more useful?
  2. How do you currently handle cases where the Risk Manager wants to block but Execution proceeds anyway? Is there an explicit veto channel?
  3. Anyone running AutoHedge paper-trading right now who'd want to feed historical proposals through and compare verdicts before/after a /review gate?

Happy to take feedback either way.


References:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions