Map token pressure at host wall

This commit is contained in:
Meta Vens 2026-05-19 15:33:45 +01:00
commit d749c50f2d
8 changed files with 35 additions and 20 deletions

View file

@ -19,7 +19,6 @@ use codex_app_server_protocol::ThreadEpiphanyRoleStatus;
use codex_app_server_protocol::ThreadEpiphanyRolesSource;
use codex_app_server_protocol::ThreadEpiphanySceneAction;
use codex_app_server_protocol::ThreadEpiphanyViewCoordinator;
use codex_protocol::protocol::TokenUsageInfo;
use epiphany_core::EpiphanyCoordinatorAction as CoreEpiphanyCoordinatorAction;
use epiphany_core::EpiphanyCoordinatorAutomationAction as CoreEpiphanyCoordinatorAutomationAction;
use epiphany_core::EpiphanyCoordinatorCrrcRecommendation;
@ -45,6 +44,7 @@ use epiphany_core::EpiphanyRoleBoardJob;
use epiphany_core::EpiphanyRoleBoardJobStatus;
use epiphany_core::EpiphanyRoleBoardLane;
use epiphany_core::EpiphanyRoleBoardPlanningSummary;
use epiphany_core::EpiphanyTokenUsageSnapshot;
use epiphany_core::coordinator_automation_action;
use epiphany_core::derive_role_board;
use epiphany_core::recommend_coordinator_action;
@ -390,7 +390,7 @@ pub struct EpiphanyCoordinatorAutomationInput<'a> {
pub state: &'a EpiphanyThreadState,
pub retrieval_override: &'a EpiphanyRetrievalState,
pub watcher_snapshot: EpiphanyFreshnessWatcherSnapshot<'a>,
pub token_usage_info: Option<&'a TokenUsageInfo>,
pub token_usage_info: Option<&'a EpiphanyTokenUsageSnapshot>,
pub runtime_store_path: &'a Path,
pub force_checkpoint_compaction: bool,
}

View file

@ -14,13 +14,13 @@ use codex_app_server_protocol::ThreadEpiphanyRoleId;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField;
use codex_app_server_protocol::ThreadEpiphanyUpdatePatch;
use codex_protocol::error::CodexErr;
use codex_protocol::protocol::TokenUsageInfo as CoreTokenUsageInfo;
use epiphany_core::EpiphanyJobInterruptRequest;
use epiphany_core::EpiphanyJobInterruptResult;
use epiphany_core::EpiphanyJobLaunchRequest;
use epiphany_core::EpiphanyJobLaunchResult;
use epiphany_core::EpiphanyPromotionInput;
use epiphany_core::EpiphanyStateUpdate;
use epiphany_core::EpiphanyTokenUsageSnapshot;
use epiphany_core::RuntimeSpineHeartbeatJobOptions;
use epiphany_core::RuntimeSpineHeartbeatLaunchPlanOptions;
use epiphany_core::apply_epiphany_state_update;
@ -573,7 +573,7 @@ pub async fn launch_thread_epiphany_reorient(
state: Option<&EpiphanyThreadState>,
retrieval_override: Option<&EpiphanyRetrievalState>,
watcher_snapshot: Option<EpiphanyFreshnessWatcherSnapshot<'_>>,
token_usage_info: Option<&CoreTokenUsageInfo>,
token_usage_info: Option<&EpiphanyTokenUsageSnapshot>,
) -> Result<EpiphanyReorientLaunchApplied, CodexErr> {
let (state_revision, retrieval, graph, watcher) =
map_epiphany_freshness(state, retrieval_override, watcher_snapshot);

View file

@ -2,26 +2,21 @@ use codex_app_server_protocol::ThreadEpiphanyPressure;
use codex_app_server_protocol::ThreadEpiphanyPressureBasis;
use codex_app_server_protocol::ThreadEpiphanyPressureLevel;
use codex_app_server_protocol::ThreadEpiphanyPressureStatus;
use codex_protocol::protocol::TokenUsageInfo as CoreTokenUsageInfo;
use epiphany_core::EpiphanyPressure;
use epiphany_core::EpiphanyPressureBasis as CoreEpiphanyPressureBasis;
use epiphany_core::EpiphanyPressureLevel as CoreEpiphanyPressureLevel;
use epiphany_core::EpiphanyPressureStatus as CoreEpiphanyPressureStatus;
use epiphany_core::EpiphanyTokenUsageSnapshot;
pub use epiphany_core::EpiphanyTokenUsageSnapshot;
use epiphany_core::derive_pressure_view;
use crate::launch::epiphany_agent_prompt_with_memory;
use crate::launch::epiphany_specialist_prompt_config;
use crate::launch::pressure_level_label;
pub fn map_epiphany_pressure(info: Option<&CoreTokenUsageInfo>) -> ThreadEpiphanyPressure {
let snapshot = info.map(|info| EpiphanyTokenUsageSnapshot {
total_tokens: info.total_token_usage.total_tokens,
last_turn_tokens: info.last_token_usage.total_tokens,
model_context_window: info.model_context_window,
model_auto_compact_token_limit: info.model_auto_compact_token_limit,
});
map_core_epiphany_pressure(derive_pressure_view(snapshot.as_ref()))
pub fn map_epiphany_pressure(
snapshot: Option<&EpiphanyTokenUsageSnapshot>,
) -> ThreadEpiphanyPressure {
map_core_epiphany_pressure(derive_pressure_view(snapshot))
}
fn map_core_epiphany_pressure(pressure: EpiphanyPressure) -> ThreadEpiphanyPressure {

View file

@ -1,10 +1,10 @@
use std::path::Path;
use codex_app_server_protocol::*;
use codex_protocol::protocol::TokenUsageInfo as CoreTokenUsageInfo;
use epiphany_core::EpiphanyDistillInput;
use epiphany_core::EpiphanyMapProposalInput;
use epiphany_core::EpiphanySceneInput;
use epiphany_core::EpiphanyTokenUsageSnapshot;
use epiphany_core::derive_scene;
use epiphany_core::distill_observation;
use epiphany_core::propose_map_update;
@ -152,7 +152,7 @@ pub struct EpiphanyViewResponseInput<'a> {
pub state: Option<&'a EpiphanyThreadState>,
pub retrieval_override: Option<&'a EpiphanyRetrievalState>,
pub watcher_snapshot: Option<EpiphanyFreshnessWatcherSnapshot<'a>>,
pub token_usage_info: Option<&'a CoreTokenUsageInfo>,
pub token_usage_info: Option<&'a EpiphanyTokenUsageSnapshot>,
pub runtime_store_path: Option<&'a Path>,
}