hive-agent: stop writing active_model to the harness state file, nothing reads it
This commit is contained in:
parent
78e063e78c
commit
05c193859f
1 changed files with 13 additions and 38 deletions
|
|
@ -131,7 +131,7 @@ fn write_harness_json(v: &serde_json::Value) {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn read_harness_state() -> (bool, bool, Option<String>) {
|
||||
pub(crate) fn read_harness_state() -> (bool, bool) {
|
||||
// Try the new consolidated file first.
|
||||
if let Ok(raw) = std::fs::read_to_string(harness_json_path())
|
||||
&& let Ok(v) = serde_json::from_str::<serde_json::Value>(&raw)
|
||||
|
|
@ -144,38 +144,25 @@ pub(crate) fn read_harness_state() -> (bool, bool, Option<String>) {
|
|||
.get("needs_login")
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.unwrap_or(false);
|
||||
let active_model = v
|
||||
.get("active_model")
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(str::to_owned);
|
||||
return (rate_limited, needs_login, active_model);
|
||||
return (rate_limited, needs_login);
|
||||
}
|
||||
// Fall back to legacy sentinel files written by older harness builds.
|
||||
let state_dir = crate::paths::state_dir();
|
||||
let rate_limited = state_dir.join("hyperhive-rate-limited").exists();
|
||||
let needs_login = state_dir.join("hyperhive-needs-login").exists();
|
||||
(rate_limited, needs_login, None)
|
||||
(rate_limited, needs_login)
|
||||
}
|
||||
|
||||
/// Write the turn-loop's harness state fields via a read-modify-write so
|
||||
/// any other writer's fields in the consolidated state file survive.
|
||||
/// Pass `active_model: Some(s)` to update the resolved model (surfaced in
|
||||
/// the dashboard badge); `None` leaves the stored value untouched.
|
||||
pub(crate) fn write_harness_state(
|
||||
rate_limited: bool,
|
||||
needs_login: bool,
|
||||
active_model: Option<&str>,
|
||||
) {
|
||||
/// any other field in the consolidated state file survives, including an
|
||||
/// `active_model` an older harness left behind (nothing reads it).
|
||||
pub(crate) fn write_harness_state(rate_limited: bool, needs_login: bool) {
|
||||
let _guard = HARNESS_JSON_LOCK
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||
let mut v = read_harness_json();
|
||||
v["rate_limited"] = rate_limited.into();
|
||||
v["needs_login"] = needs_login.into();
|
||||
if let Some(model) = active_model {
|
||||
v["active_model"] = model.into();
|
||||
}
|
||||
write_harness_json(&v);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue