pub struct AgentTask<T> { /* private fields */ }Expand description
One call of an AgentRole, answering with the T of the role.
The role locks its persona, tools, permission mode, MCP config and output type: none of them has a setter here, and each of these calls does not compile.
The name and cost cap of the role are locked too: no setter of the task changes or removes them, so every task of the role is charged to its counter.
The system prompt is locked:
let _ = Reviewer.task("diff".to_string()).system_prompt("x");The persona is locked:
let _ = Reviewer.task("diff".to_string()).append_system_prompt("x");The tools are locked:
let _ = Reviewer.task("diff".to_string()).allow_tool(Tool::Bash);The permission mode is locked:
let _ = Reviewer
.task("diff".to_string())
.permission_mode(PermissionMode::BypassPermissions);The MCP config is locked:
let _ = Reviewer.task("diff".to_string()).mcp_config("{}");The output type is locked:
let _ = Reviewer.task("diff".to_string()).output::<Other>();The role name is locked:
let _ = Reviewer.task("diff".to_string()).role("x");Taking the raw config with AgentStep::into_config and editing it loses
the typed answer (ctx.agent then returns a StepOutput), so there is no
silent override.
A call-site override changes the step config, so it changes the hash of the
RecordReplayProvider fixture: a fixture recorded for the role defaults
does not match an overridden task.
§Examples
let task = Reviewer.task("diff".to_string()).model("haiku").allow_failure();
let config = task.into_config();
assert_eq!(config.model, "haiku");
assert!(config.allow_failure);Implementations§
Source§impl<T> AgentTask<T>
impl<T> AgentTask<T>
Sourcepub fn model(self, model: &str) -> Self
pub fn model(self, model: &str) -> Self
Override the model of the role for this call.
§Examples
let config = Reviewer.task("diff".to_string()).model("haiku").into_config();
assert_eq!(config.model, "haiku");Sourcepub fn max_budget_usd(self, budget: f64) -> Self
pub fn max_budget_usd(self, budget: f64) -> Self
Override the budget of the role for this call.
§Examples
let config = Reviewer.task("diff".to_string()).max_budget_usd(0.10).into_config();
assert_eq!(config.max_budget_usd, Some(0.10));Sourcepub fn max_turns(self, turns: u32) -> Self
pub fn max_turns(self, turns: u32) -> Self
Override the turn limit of the role for this call.
§Examples
let config = Reviewer.task("diff".to_string()).max_turns(6).into_config();
assert_eq!(config.max_turns, Some(6));Sourcepub fn effort(self, effort: Effort) -> Self
pub fn effort(self, effort: Effort) -> Self
Override the effort of the role for this call.
§Examples
let config = Reviewer.task("diff".to_string()).effort(Effort::High).into_config();
assert!(matches!(config.effort, Some(Effort::High)));Sourcepub fn working_dir(self, dir: &str) -> Self
pub fn working_dir(self, dir: &str) -> Self
Set the working directory of the call.
§Examples
let config = Reviewer.task("diff".to_string()).working_dir("/repo").into_config();
assert_eq!(config.working_dir.as_deref(), Some("/repo"));Sourcepub fn resume(self, session_id: &str) -> Self
pub fn resume(self, session_id: &str) -> Self
Resume a Claude Code session.
§Examples
let config = Reviewer.task("diff".to_string()).resume("sess").into_config();
assert_eq!(config.resume_session_id.as_deref(), Some("sess"));Sourcepub fn session_id(self, session_id: &str) -> Self
pub fn session_id(self, session_id: &str) -> Self
Pin the session id of the call.
§Examples
let config = Reviewer.task("diff".to_string()).session_id("sid").into_config();
assert_eq!(config.session_id.as_deref(), Some("sid"));Sourcepub fn resume_prompt(self, prompt: &str) -> Self
pub fn resume_prompt(self, prompt: &str) -> Self
Set the prompt sent when the step is resumed after a lost lease.
§Examples
let config = Reviewer.task("diff".to_string()).resume_prompt("go on").into_config();
assert_eq!(config.resume_prompt.as_deref(), Some("go on"));Sourcepub fn resume_environment(self, environment_id: &str) -> Self
pub fn resume_environment(self, environment_id: &str) -> Self
Resume the environment handed out by an earlier step.
§Examples
let config = Reviewer.task("diff".to_string()).resume_environment("env-1").into_config();
assert_eq!(config.resume_environment_id.as_deref(), Some("env-1"));Sourcepub fn retry_policy(self, policy: RetryPolicy) -> Self
pub fn retry_policy(self, policy: RetryPolicy) -> Self
Set the retry policy of the step.
§Examples
let config = Reviewer.task("diff".to_string()).retry_policy(RetryPolicy::new(2)).into_config();
assert_eq!(config.retry.map(|r| r.max_retries()), Some(2));Sourcepub fn allow_failure(self) -> Self
pub fn allow_failure(self) -> Self
Let the run go on when this step fails.
§Examples
let config = Reviewer.task("diff".to_string()).allow_failure().into_config();
assert!(config.allow_failure);Sourcepub fn verbose(self, enabled: bool) -> Self
pub fn verbose(self, enabled: bool) -> Self
Record the agent conversation of the call.
§Examples
let config = Reviewer.task("diff".to_string()).verbose(true).into_config();
assert!(config.verbose);Sourcepub fn pod_label(self, key: &str, value: &str) -> Self
pub fn pod_label(self, key: &str, value: &str) -> Self
Add a label to the pod running the call.
§Examples
let config = Reviewer.task("diff".to_string()).pod_label("team", "qa").into_config();
assert_eq!(config.pod_labels.get("team").map(String::as_str), Some("qa"));Sourcepub fn pod_labels(self, labels: BTreeMap<String, String>) -> Self
pub fn pod_labels(self, labels: BTreeMap<String, String>) -> Self
Set the labels of the pod running the call.
§Examples
let labels = BTreeMap::from([("team".to_string(), "qa".to_string())]);
let config = Reviewer.task("diff".to_string()).pod_labels(labels.clone()).into_config();
assert_eq!(config.pod_labels, labels);