Spaces:
Paused
Backend Summary
This is the backend handoff for the frontend team.
Plain-English State Model
There are five different layers of state:
world.latent_stateBackend truth. Rewards and simulation logic use this.world.latent_eventsCanonical hidden event chain. News, actions, asset damage, and oversight now create or update these events.world.actor_stateLagged/public summary of the world.observations[agent_id]What each entity actually sees. This can be partial, delayed, contradictory, and low-confidence.belief_state[agent_id]What each entity currently believes across turns. This is persistent memory, not just the current observation. It now uses doctrine-specific priors, slow false-belief decay, and contradiction-driven revision.
The frontend should not treat those layers as interchangeable.
Real Model Behavior
Each entity has a model_bindings[agent_id] object.
That tells you:
- which provider is configured
- which model is configured
- whether the binding is ready for inference
- which tools/actions the entity is allowed to use
- whether the entity is currently on real provider execution or heuristic fallback
Current behavior:
- if a provider binding is ready, the backend tries real provider inference first
- if that fails or returns an invalid action, the backend falls back explicitly to heuristic policy
- action metadata records whether the action came from
provider_inferenceorheuristic_fallback
Supported provider names now include:
openaianthropicopenrouterhuggingfaceollamavllmcustom
Hugging Face notes:
huggingfaceuses the HF router chat-completions endpoint- if
api_key_envis not set, the backend defaults toHF_TOKEN - if
TRENCHES_HF_ROUTING_POLICYis set tofastest,cheapest, orpreferred, the backend appends that routing suffix to HF model names that do not already include one - the recommended deployment pattern is to store
HF_TOKENas a secret, not in repo files
Main Endpoints
Server file:
Health And Capabilities
GET /healthzReturns{ "status": "ok" }GET /capabilitiesReturns:- session/OpenEnv capability flags
- CORS settings
- per-entity
model_bindings
Use this once at app startup.
Session Lifecycle
POST /sessionsCreates a session.POST /sessions/{session_id}/resetResets an existing session.GET /sessions/{session_id}Returns the latestSessionState.POST /sessions/{session_id}/stepAdvances one turn.
Request body:
actions: Record<agentId, AgentAction>external_signals: ExternalSignal[]
Response:
StepSessionResponsesessionoversightdone
Live News And Reaction Timeline
POST /sessions/{session_id}/newsInjects public/news signals, lets the backend resolve entity reactions, steps the world, and returns the structured reaction entry for that news event.
Request body:
signals: ExternalSignal[]agent_ids?: string[]
Notes:
- if
agent_idsis omitted, all entities react - if
agent_idsis provided, only those entities are auto-resolved for that news event - this still goes through the same env step path, so it stays aligned with OpenEnv behavior
Response:
IngestNewsResponsesessionoversightreactiondone
GET /sessions/{session_id}/reactionsReturns the rollingreaction_log.
Use these two endpoints for:
- incoming-news timeline
- “who reacted to what” UI
- live world-monitoring panels
Provider Diagnostics
GET /sessions/{session_id}/providers/diagnosticsReturns per-entity provider runtime health and recent inference telemetry.
Important fields per entity:
statusrequest_countsuccess_counterror_countconsecutive_failureslast_latency_msavg_latency_mslast_success_atlast_error_atlast_error
Use this for:
- provider health badges
- fallback warnings
- “model is unhealthy” operator panels
- debugging why an entity is on heuristic fallback
Live Source Controls
POST /sessions/{session_id}/liveEnables or disables live mode.POST /sessions/{session_id}/sources/refreshForces source refresh and rebuilds observations.GET /sessions/{session_id}/sources/monitorReturns source-health and delivery status per entity.
Scenarios And Benchmarks
GET /scenariosReturns seeded scenarios.POST /benchmarks/runRuns scenario benchmarks and returns scorecards.
OpenEnv
Legacy tuple-style endpoints:
POST /resetPOST /stepGET /state
If openenv-core is installed, native OpenEnv is mounted at:
/openenv
OpenEnv file:
Main Schemas
Schema file:
SessionState
Main top-level object for the frontend.
Important fields:
session_idworldobservationsbelief_staterewardsmodel_bindingsrecent_tracesaction_logreaction_logliveepisode
WorldState
Important fields:
latent_statelatent_eventsactor_stateactive_eventsasset_statecoalition_graphrisk_scoreslast_actions
Important distinction:
latent_eventsare canonical hidden eventsactive_eventsare the public-facing projection of those latent events
AgentObservation
Main entity-facing view.
Important fields:
decision_promptbelief_briefbelief_topicsavailable_actionsavailable_data_sourcesstrategic_statestrategic_assetsasset_alertssource_packetstraining_source_packetslive_source_packetsprojection
ObservationProjection
This explains how messy the entity’s current view is.
Important fields:
modeworldview_reliabilitydelayed_source_countcontested_source_countcontradiction_packet_countcontradiction_topicsobscured_metric_countnotes
Frontend rule:
Show this clearly. Do not present entity observations as perfect truth.
EntityModelBinding
Per-entity provider/runtime config.
Important fields:
providermodel_nameconfiguredready_for_inferencedecision_modesupports_tool_callssupports_structured_outputaction_toolsobservation_toolsnotes
ProviderAgentDiagnostics
Per-entity runtime telemetry for provider-backed execution.
Important fields:
agent_idprovidermodel_nameconfiguredready_for_inferencedecision_modestatusrequest_countsuccess_counterror_countconsecutive_failureslast_latency_msavg_latency_mslast_success_atlast_error_atlast_error
ActionLogEntry
Per-action activity feed row.
Important fields:
turnactoraction_typesummarytargetreward_totalmetadata
Use this for the entity activity log.
ReactionLogEntry
Structured “public release -> entity reaction” object.
Important fields:
event_idturnsourcelatent_event_idssignalsactor_outcomesoversight_triggeredtension_beforetension_aftermarket_stress_afteroil_pressure_after
This is the easiest object for a live news feed.
AgentBeliefState
Persistent per-entity memory.
Important fields:
agent_iddominant_topicsbeliefslast_revision_turn
AgentBeliefEntry
One remembered belief/hypothesis for an entity.
Important fields:
belief_idtopicsummaryconfidencestatussourcesuspected_agentsrelated_event_idsconfirmation_countcontradiction_countlast_confirmed_turnlast_updated_turn
Belief behavior:
- entities do not weight all topics equally
- beliefs decay gradually when no new confirmation arrives
- contradictory evidence usually downgrades a belief first before fully disconfirming it
- two entities can see the same event and end up with different confidence because doctrine priors differ
Latent Events
The backend now treats event flow as first-class, not just metric movement.
Main schema:
LatentEvent
Key fields:
event_idtopicstatusseverityvisibilityreliabilityoriginaffected_agentsaffected_assetsstarted_at_turnlast_updated_turndecay_ratelinked_event_idsnarratives
What this means:
- scenarios can seed hidden events
- incoming news creates or updates hidden events
- entity actions create hidden events
- linked spillover events can be spawned
- public event feeds are projected from latent events
- source contradictions now key off latent events, not only metric heuristics
ReactionActorOutcome
One entity’s response to one news event.
Important fields:
agent_idactionreward_totaldecision_mode
What Is Good To Go
Backend pieces that are ready for frontend integration:
- session lifecycle
- live source monitoring
- latent truth vs public state split
- latent event engine and event-driven public projection
- persistent belief state per entity
- doctrine-specific belief revision and false-belief persistence
- contradiction-aware observation projection
- per-entity rewards
- per-entity action logging
- structured reaction logging for public/news events
- seeded scenarios
- benchmark runs
- provider bindings
- real provider execution with explicit fallback
- provider runtime diagnostics
- OpenEnv-compatible environment flow
What Is Still Left
Backend
Persist replay history.
recent_traces,action_log,reaction_log, and latent event evolution are still rolling in-memory state, not durable history.Deepen the latent event graph. The event engine now exists, but it can still be improved with stronger causal chains, event merging, event resolution rules, and richer cross-front propagation.
Add event-delta summaries. A compact backend-generated turn delta would make replay/debug views much easier to build.
Keep hardening provider execution. Retries and diagnostics now exist. The next step is richer classification for rate limits, timeout classes, and provider-specific retry traces.
Add a durable event archive or export path. There is still no persistent event timeline outside in-memory session state.
Frontend
Build the app shell around:
/capabilities/scenarios/sessions/sessions/{id}/sessions/{id}/step/sessions/{id}/news/sessions/{id}/reactions/sessions/{id}/providers/diagnostics/sessions/{id}/live/sessions/{id}/sources/monitor
Add entity cards that show:
- projected state
- persistent belief topics / belief memory
- reward total
- provider readiness
- provider health/latency
- latest action
- uncertainty/projection info
Add a live news/reaction timeline. Use
/sessions/{id}/newsfor ingestion andreaction_logor/sessions/{id}/reactionsfor history.Add latent event visibility to operator surfaces. Show:
- key latent event topics
- event severity
- event visibility
- linked spillovers
Add a source-health panel. Use
/sessions/{id}/sources/monitor.Add replay panels. Use
recent_traces,action_log,reaction_log, andworld.latent_events.Make uncertainty visible. Show reliability, contradiction topics, delayed sources, and contested-source counts.
Rule Of Thumb For Frontend
If the UI means:
- “what the entity believes” -> use
session.observations[agent_id] - “what the entity currently remembers/believes across turns” -> use
session.belief_state[agent_id] - “what the operator/debugger sees” -> use
session.world - “what hidden developments are driving the sim” -> use
session.world.latent_events - “what the backend can execute” -> use
session.model_bindings - “what just happened on a turn” -> use
session.action_logandsession.recent_traces - “what public news triggered reactions” -> use
session.reaction_log