pub struct AgentContext {Show 30 fields
pub task_description: String,
pub round_number: u32,
pub total_rounds: u32,
pub phase: DeliberationPhase,
pub target_proposal: Option<Proposal>,
pub competitor_summaries: Vec<String>,
pub previous_round_matrix: Option<String>,
pub previous_own_proposal: Option<Proposal>,
pub previous_own_score: Option<f32>,
pub previous_critiques: Vec<String>,
pub scratchpad: Option<String>,
pub store: Option<Arc<dyn PersistenceStore>>,
pub candidates: Vec<CandidateProposal>,
pub user_injections: Vec<UserInjection>,
pub user_tools: Vec<UserToolDefinition>,
pub phase_budget_remaining_secs: f64,
pub session_id: Option<String>,
pub conversation_id: Option<String>,
pub new_turn: Option<String>,
pub structured_feedback: Option<StructuredFeedback>,
pub forced_proposal_schema: Option<Value>,
pub working_dir_override: Option<PathBuf>,
pub user_tool_handler: Option<Arc<dyn UserToolHandlerTrait>>,
pub role: Option<String>,
pub role_context: Option<String>,
pub agent_id: String,
pub task_publish_ts: Option<i64>,
pub telemetry: Option<TelemetryEmitterMux>,
pub submission_validator: Option<Arc<dyn SubmissionValidator>>,
pub event_store: Option<AgentEventStore>,
}Fields§
§task_description: String§round_number: u32§total_rounds: u32§phase: DeliberationPhase§target_proposal: Option<Proposal>§competitor_summaries: Vec<String>§previous_round_matrix: Option<String>§previous_own_proposal: Option<Proposal>§previous_own_score: Option<f32>§previous_critiques: Vec<String>§scratchpad: Option<String>§store: Option<Arc<dyn PersistenceStore>>§candidates: Vec<CandidateProposal>§user_injections: Vec<UserInjection>§user_tools: Vec<UserToolDefinition>User-defined tool definitions for this job. Empty if none registered.
phase_budget_remaining_secs: f64Remaining phase budget in seconds at the time the task was published. The agent uses this as the upper bound for user tool call wait times.
session_id: Option<String>The session/job ID for NATS subject construction within the agent worker.
conversation_id: Option<String>Stable conversation key for the claude-CLI session, when a job belongs to
a longer-lived thread whose session_id/room_id is minted fresh per turn
(the OpenAI-compat path). The deterministic claude session UUID is keyed on
this so successive turns of one thread --resume the same transcript.
None falls back to session_id (the thread-TUI path, where the room is
the stable thread id).
new_turn: Option<String>The new turn only (this job’s incremental user message), when the thread’s
prior turns already live in the resumed claude session. Used as the delta
prompt’s task on a resumed session so we don’t re-send the whole flattened
task_description (which the session already holds). None → the delta
falls back to task_description (fresh session / non-thread paths).
structured_feedback: Option<StructuredFeedback>Structured feedback from previous round’s evaluations (Phase 2 context pipeline).
forced_proposal_schema: Option<Value>A JSON schema a before_prompt middleware declared for the proposal
submission. When set, the propose tool’s parameters are constrained to
it and the terminal tool call is forced (tool_choice: required) — the
model must return a schema-valid structured proposal. Runtime-only.
working_dir_override: Option<PathBuf>A per-task working directory a before_prompt middleware declared (via the
agent_working_dir key on its content). When set, the agent subprocess runs
with cwd = this dir instead of the process launch dir, so relative reads/writes
land where the middleware prepared them. Overrides the agent’s static
working_dir. Runtime-only.
user_tool_handler: Option<Arc<dyn UserToolHandlerTrait>>Runtime-only: handler for user tool calls (injected by agent worker, not serialized).
The concrete type is supplied via UserToolHandlerFactory;
this field holds an opaque Arc wrapper.
role: Option<String>Role assigned to this agent by the broker (from policy-based scheduling).
None for static agent list mode or legacy payloads.
role_context: Option<String>Per-role private context content (not visible to other agents).
Populated from the role’s context files by the orchestrator.
agent_id: StringIdentity of the agent processing this task. Populated by the
dispatcher (orchestrator at construction time, worker after
deserialize) so the agent and any downstream helpers
(e.g. AgentContext::telemetry_for) don’t need to thread
the same id through every call site. #[serde(default)] on
the field tolerates payloads serialized before the field
existed; populated paths keep the value end-to-end.
task_publish_ts: Option<i64>Unix ms the orchestrator stamped at publish time; None on
pre-stamping payloads, synthetic contexts, and resurrected
envelopes. Paired with task_received to compute
TaskAccepted.job_age_at_accept_ms.
telemetry: Option<TelemetryEmitterMux>Runtime-only: per-task telemetry mux populated by the agent
worker. Agents pass context.telemetry.as_ref() into
generate_structured_output / react_loop so LLM, tool,
retry, and prompt-exposure events fan out across every
configured endpoint under the same (agent_id, job_id, round, phase) envelope as the worker’s task-lifecycle
events. Mirrors the store / user_tool_handler
runtime-only pattern: skipped by serde, excluded from
generated schemas.
submission_validator: Option<Arc<dyn SubmissionValidator>>Runtime-only: validates a submit_proposal submission inside the react
loop. Injected by the agent worker from the provider_response middleware
so a reviewer block (e.g. patch-deliberation “applied ZERO changes”) feeds
the reason back through the SAME retry that handles parse failures — no
separate retry budget. Mirrors the user_tool_handler runtime-only pattern.
event_store: Option<AgentEventStore>Runtime-only: the agent’s own NATS event log. Injected by the worker so
the react loop can record tool-call start/finish for the operator
dashboard’s 24h history. Mirrors the telemetry runtime-only pattern:
skipped by serde, excluded from generated schemas.
Implementations§
Source§impl AgentContext
impl AgentContext
Sourcepub fn claude_session_key(&self) -> Option<&str>
pub fn claude_session_key(&self) -> Option<&str>
The key the deterministic claude-CLI session UUID is derived from:
conversation_id (a thread stable across turns) when set, else
session_id (the per-job/room id). This is what makes successive turns
of one thread resume the same transcript.
Sourcepub fn delta_task(&self) -> &str
pub fn delta_task(&self) -> &str
The task text a resumed session’s delta prompt should carry: the new
turn only when set (the prior turns already live in the session), else the
full task_description (fresh session / non-thread paths). This is what
stops a resumed thread from re-sending its whole flattened history.
Sourcepub fn telemetry_for(&self) -> TelemetryContext
pub fn telemetry_for(&self) -> TelemetryContext
Build a TelemetryContext
for telemetry events emitted while processing this task.
Uses the context’s own agent_id, session_id,
round_number, and phase. Pair with [emit_for!] at the
call site:
emit_for!(context, ToolCallExecuted {
tool_name: name, latency_ms: 42, success: true,
});§Panics
session_id is a dispatch-time invariant: the orchestrator
populates it on every published task. Emitting telemetry
from a context with no session is a programmer error,
typically a test that constructed an AgentContext literal
without setting session_id. Panics with a helpful message
rather than synthesising a fake job_id that would silently
break trace correlation across the catalog.
Trait Implementations§
Source§impl Clone for AgentContext
impl Clone for AgentContext
Source§fn clone(&self) -> AgentContext
fn clone(&self) -> AgentContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposeSchema for AgentContext
impl ComposeSchema for AgentContext
Source§impl Debug for AgentContext
impl Debug for AgentContext
Source§impl Default for AgentContext
impl Default for AgentContext
Source§fn default() -> AgentContext
fn default() -> AgentContext
Source§impl<'de> Deserialize<'de> for AgentContext
impl<'de> Deserialize<'de> for AgentContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for AgentContext
impl JsonSchema for AgentContext
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Serialize for AgentContext
impl Serialize for AgentContext
Auto Trait Implementations§
impl !RefUnwindSafe for AgentContext
impl !UnwindSafe for AgentContext
impl Freeze for AgentContext
impl Send for AgentContext
impl Sync for AgentContext
impl Unpin for AgentContext
impl UnsafeUnpin for AgentContext
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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 moreSource§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more