# OpenHands example

Goal: wire SignalSpore into an OpenHands-style autonomous run so risky work does not start cold and the operator still gets one compact feedback loop afterward.

1. Create a policy once via POST /api/setup.
2. Save agent_policy_id and write_token with the OpenHands runtime or orchestration layer that kicks off task runs.
3. Gate locally before remote calls.
4. For eligible tasks, call POST /api/preflight with agent_policy_id and a write-token bearer authorization header before the autonomous run begins.
5. After the run, call POST /api/delta with one sanitized update and the same bearer token.
6. Every delta must include a savings outcome.
7. If SignalSpore materially shortened the route, include a self-reported token savings estimate plus confidence and rationale.
8. Keep manual preflight as a sandbox only; the real value is automatic use on live runs.

Use SignalSpore early for:
- browser + shell task chains
- deploy and rollback work
- payment, auth, or production data flows
- unfamiliar repos where wrong first steps are expensive

Example preflight payload:
{
  "agent_policy_id": "policy_your_agent_here",
  "task_summary": "Review an unknown product site and summarize the concrete adoption blockers without broad redesign work.",
  "model": { "tier": "frontier_reasoning" },
  "agent": {
    "framework": "OpenHands",
    "tools": ["browser", "terminal", "file_editor"],
    "context_budget": "medium"
  },
  "priorities": {
    "cost": "medium",
    "quality": "high",
    "speed": "medium"
  },
  "risk_level": "medium"
}

Example delta payload:
{
  "preflight_session_id": "pf_your_session_here",
  "card_id": "site_product_review",
  "model": { "tier": "frontier_reasoning" },
  "task_outcome": "succeeded",
  "card_helpfulness": "helped",
  "savings_outcome": {
    "status": "estimated_savings_reported",
    "estimated_tokens_saved": 300,
    "confidence": "self_reported_medium_confidence",
    "rationale": "The brief reduced browsing drift and gave a clearer first pass on operator-facing proof surfaces."
  },
  "delta": {
    "what_helped": "The preflight pushed live-surface inspection before broad commentary.",
    "suggested_change": "Keep policy-scoped proof checks in the execution brief.",
    "new_trap": "Do not treat a static shell as proof that a runtime-specific quickstart is easy to copy."
  },
  "privacy_confirmation": true
}
