pub struct WorkerState {
pub id: AgentId,
pub history: ActionHistory,
pub cache: LocalCache,
pub pending_tasks: HashSet<TaskId>,
pub escalation: Option<Escalation>,
pub consecutive_failures: u32,
pub last_output: Option<String>,
/* private fields */
}Expand description
Worker の永続状態(Tick間で保持される)
WorkerStateDelta 経由で更新される。
Fields§
§id: AgentIdAgent ID(内部識別用)
history: ActionHistory行動履歴
cache: LocalCacheローカルキャッシュ
pending_tasks: HashSet<TaskId>保留中の非同期Task(HashSet で O(1) 検索)
escalation: Option<Escalation>Escalation 情報(Worker が設定、Manager が読み取り)
consecutive_failures: u32連続失敗カウント
last_output: Option<String>最新アクションの出力(Environment からの結果)
Implementations§
Source§impl WorkerState
impl WorkerState
pub fn new(id: AgentId) -> Self
Sourcepub fn raise_escalation(&mut self, escalation: Escalation)
pub fn raise_escalation(&mut self, escalation: Escalation)
Escalation を発生させる
Sourcepub fn clear_escalation(&mut self)
pub fn clear_escalation(&mut self)
Escalation をクリア
Sourcepub fn record_failure(&mut self, tick: u64, threshold: u32) -> bool
pub fn record_failure(&mut self, tick: u64, threshold: u32) -> bool
失敗を記録し、閾値を超えたら Escalation
Sourcepub fn record_success(&mut self)
pub fn record_success(&mut self)
成功を記録(連続失敗をリセット)
Sourcepub fn get_state_mut<T: Any + Send + Sync + 'static>(
&mut self,
) -> Option<&mut T>
pub fn get_state_mut<T: Any + Send + Sync + 'static>( &mut self, ) -> Option<&mut T>
内部状態を可変で取得
Sourcepub fn add_pending_task(&mut self, task_id: TaskId)
pub fn add_pending_task(&mut self, task_id: TaskId)
非同期タスクを追加(O(1))
Sourcepub fn complete_task(&mut self, task_id: TaskId)
pub fn complete_task(&mut self, task_id: TaskId)
完了したタスクを削除(O(1))
Auto Trait Implementations§
impl Freeze for WorkerState
impl !RefUnwindSafe for WorkerState
impl Send for WorkerState
impl Sync for WorkerState
impl Unpin for WorkerState
impl !UnwindSafe for WorkerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more