pub struct Task {
pub id: Option<String>,
pub instruction: String,
pub attachments: Vec<Attachment>,
pub metadata: MetadataMap,
}Expand description
Pure data description of a task. No behaviour, no closures. Success predicates
live in TaskEvaluator.
Fields§
§id: Option<String>§instruction: String§attachments: Vec<Attachment>§metadata: MetadataMapReverse-DNS-namespaced keys. Unknown keys round-trip.
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(instruction: impl Into<String>) -> Self
pub fn new(instruction: impl Into<String>) -> Self
Examples found in repository?
examples/gen_v1_fixture.rs (line 25)
13fn main() {
14 let run_id = RunId::new();
15 let capabilities = LlmCapabilities {
16 streaming: true,
17 prompt_caching: true,
18 parallel_tool_use: true,
19 vision: true,
20 thinking: true,
21 structured_output: false,
22 max_context_tokens: 200_000,
23 max_output_tokens: 8192,
24 };
25 let task = Task::new("inspect the repo").with_id("smoke-1");
26
27 let events = vec![
28 Event::new(
29 0,
30 run_id,
31 "run-0",
32 EventKind::Meta(MetaPayload {
33 schema_version: SchemaVersion::CURRENT,
34 harness_version: "0.1.0".into(),
35 task_snapshot: task.clone(),
36 llm_capabilities: capabilities.clone(),
37 }),
38 ),
39 Event::new(
40 1,
41 run_id,
42 "run-0",
43 EventKind::RunStarted(RunStartedPayload {
44 extra: MetadataMap::new(),
45 }),
46 ),
47 Event::new(
48 2,
49 run_id,
50 "turn-0",
51 EventKind::TurnStarted(TurnPayload { turn_index: 0 }),
52 ),
53 Event::new(
54 3,
55 run_id,
56 "llm-0",
57 EventKind::LlmRequest(LlmRequestPayload {
58 request: CompletionRequest {
59 messages: vec![Message::user_text("inspect the repo")],
60 tools: vec![],
61 system: Some("You are an agent.".into()),
62 max_tokens: Some(1024),
63 temperature: None,
64 stop_sequences: vec![],
65 cache_hints: Default::default(),
66 extensions: MetadataMap::new(),
67 },
68 provider: Some("anthropic".into()),
69 }),
70 ),
71 Event::new(
72 4,
73 run_id,
74 "llm-0",
75 EventKind::LlmResponse(LlmResponsePayload {
76 response: CompletionResponse {
77 id: "msg_01".into(),
78 model: ModelId::new("claude-sonnet-4-5"),
79 content: vec![
80 Content::text("Let me check."),
81 Content::ToolUse {
82 id: "tu_1".into(),
83 name: "fs_list".into(),
84 input: serde_json::json!({"path": "."}),
85 },
86 ],
87 stop_reason: StopReason::ToolUse,
88 usage: Usage {
89 tokens_input: 42,
90 tokens_output: 18,
91 ..Default::default()
92 },
93 },
94 }),
95 ),
96 Event::new(
97 5,
98 run_id,
99 "tool-0",
100 EventKind::ToolCallStarted(ToolCallStartedPayload {
101 tool_name: "fs_list".into(),
102 tool_use_id: "tu_1".into(),
103 input: serde_json::json!({"path": "."}),
104 }),
105 ),
106 Event::new(
107 6,
108 run_id,
109 "tool-0",
110 EventKind::ToolCallFinished(ToolCallFinishedPayload {
111 tool_name: "fs_list".into(),
112 tool_use_id: "tu_1".into(),
113 output: serde_json::json!([{"type": "text", "text": "Cargo.toml\nsrc/"}]),
114 truncated: false,
115 }),
116 ),
117 Event::new(
118 7,
119 run_id,
120 "turn-0",
121 EventKind::TurnFinished(TurnFinishedPayload {
122 turn_index: 0,
123 stop_reason: StopReason::ToolUse,
124 usage: Usage {
125 tokens_input: 42,
126 tokens_output: 18,
127 ..Default::default()
128 },
129 tool_calls: 1,
130 }),
131 ),
132 // Second turn: llm.failed path, for coverage.
133 Event::new(
134 8,
135 run_id,
136 "turn-1",
137 EventKind::TurnStarted(TurnPayload { turn_index: 1 }),
138 ),
139 Event::new(
140 9,
141 run_id,
142 "llm-1",
143 EventKind::LlmFailed(LlmFailedPayload {
144 reason: "rate limited".into(),
145 }),
146 ),
147 Event::new(
148 10,
149 run_id,
150 "run-0",
151 EventKind::RunFinished(RunFinishedPayload {
152 termination: "Completed { reason: EndTurn }".into(),
153 turns: 1,
154 tool_calls: 1,
155 extra: MetadataMap::new(),
156 }),
157 ),
158 ];
159
160 let path = "crates/oharness-core/testdata/trajectories/v1.0/smoke.jsonl";
161 let mut file = File::create(path).unwrap();
162 for event in events {
163 let line = serde_json::to_vec(&event).unwrap();
164 file.write_all(&line).unwrap();
165 file.write_all(b"\n").unwrap();
166 }
167 println!("wrote {path}");
168}Sourcepub fn with_id(self, id: impl Into<String>) -> Self
pub fn with_id(self, id: impl Into<String>) -> Self
Examples found in repository?
examples/gen_v1_fixture.rs (line 25)
13fn main() {
14 let run_id = RunId::new();
15 let capabilities = LlmCapabilities {
16 streaming: true,
17 prompt_caching: true,
18 parallel_tool_use: true,
19 vision: true,
20 thinking: true,
21 structured_output: false,
22 max_context_tokens: 200_000,
23 max_output_tokens: 8192,
24 };
25 let task = Task::new("inspect the repo").with_id("smoke-1");
26
27 let events = vec![
28 Event::new(
29 0,
30 run_id,
31 "run-0",
32 EventKind::Meta(MetaPayload {
33 schema_version: SchemaVersion::CURRENT,
34 harness_version: "0.1.0".into(),
35 task_snapshot: task.clone(),
36 llm_capabilities: capabilities.clone(),
37 }),
38 ),
39 Event::new(
40 1,
41 run_id,
42 "run-0",
43 EventKind::RunStarted(RunStartedPayload {
44 extra: MetadataMap::new(),
45 }),
46 ),
47 Event::new(
48 2,
49 run_id,
50 "turn-0",
51 EventKind::TurnStarted(TurnPayload { turn_index: 0 }),
52 ),
53 Event::new(
54 3,
55 run_id,
56 "llm-0",
57 EventKind::LlmRequest(LlmRequestPayload {
58 request: CompletionRequest {
59 messages: vec![Message::user_text("inspect the repo")],
60 tools: vec![],
61 system: Some("You are an agent.".into()),
62 max_tokens: Some(1024),
63 temperature: None,
64 stop_sequences: vec![],
65 cache_hints: Default::default(),
66 extensions: MetadataMap::new(),
67 },
68 provider: Some("anthropic".into()),
69 }),
70 ),
71 Event::new(
72 4,
73 run_id,
74 "llm-0",
75 EventKind::LlmResponse(LlmResponsePayload {
76 response: CompletionResponse {
77 id: "msg_01".into(),
78 model: ModelId::new("claude-sonnet-4-5"),
79 content: vec![
80 Content::text("Let me check."),
81 Content::ToolUse {
82 id: "tu_1".into(),
83 name: "fs_list".into(),
84 input: serde_json::json!({"path": "."}),
85 },
86 ],
87 stop_reason: StopReason::ToolUse,
88 usage: Usage {
89 tokens_input: 42,
90 tokens_output: 18,
91 ..Default::default()
92 },
93 },
94 }),
95 ),
96 Event::new(
97 5,
98 run_id,
99 "tool-0",
100 EventKind::ToolCallStarted(ToolCallStartedPayload {
101 tool_name: "fs_list".into(),
102 tool_use_id: "tu_1".into(),
103 input: serde_json::json!({"path": "."}),
104 }),
105 ),
106 Event::new(
107 6,
108 run_id,
109 "tool-0",
110 EventKind::ToolCallFinished(ToolCallFinishedPayload {
111 tool_name: "fs_list".into(),
112 tool_use_id: "tu_1".into(),
113 output: serde_json::json!([{"type": "text", "text": "Cargo.toml\nsrc/"}]),
114 truncated: false,
115 }),
116 ),
117 Event::new(
118 7,
119 run_id,
120 "turn-0",
121 EventKind::TurnFinished(TurnFinishedPayload {
122 turn_index: 0,
123 stop_reason: StopReason::ToolUse,
124 usage: Usage {
125 tokens_input: 42,
126 tokens_output: 18,
127 ..Default::default()
128 },
129 tool_calls: 1,
130 }),
131 ),
132 // Second turn: llm.failed path, for coverage.
133 Event::new(
134 8,
135 run_id,
136 "turn-1",
137 EventKind::TurnStarted(TurnPayload { turn_index: 1 }),
138 ),
139 Event::new(
140 9,
141 run_id,
142 "llm-1",
143 EventKind::LlmFailed(LlmFailedPayload {
144 reason: "rate limited".into(),
145 }),
146 ),
147 Event::new(
148 10,
149 run_id,
150 "run-0",
151 EventKind::RunFinished(RunFinishedPayload {
152 termination: "Completed { reason: EndTurn }".into(),
153 turns: 1,
154 tool_calls: 1,
155 extra: MetadataMap::new(),
156 }),
157 ),
158 ];
159
160 let path = "crates/oharness-core/testdata/trajectories/v1.0/smoke.jsonl";
161 let mut file = File::create(path).unwrap();
162 for event in events {
163 let line = serde_json::to_vec(&event).unwrap();
164 file.write_all(&line).unwrap();
165 file.write_all(b"\n").unwrap();
166 }
167 println!("wrote {path}");
168}pub fn with_attachment(self, a: Attachment) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
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