everruns-runtime 0.8.33

Public in-process runtime for embedding Everruns harnesses
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
// Embedder-facing builders for core seed models.
// Decision: keep these in everruns-runtime so core domain structs stay literal
// data models while runtime owns the public embedding ergonomics.

use chrono::{DateTime, Utc};
use everruns_core::network_access::NetworkAccessList;
use everruns_core::{
    Agent, AgentCapabilityConfig, AgentId, AgentStatus, DEFAULT_ORG_PUBLIC_ID, Harness, HarnessId,
    HarnessStatus, ModelId, PrincipalId, ScopedMcpServers, Session, SessionId, SessionStatus,
    ToolDefinition,
};
use uuid::Uuid;

/// Builds a [`Harness`] with runtime-friendly defaults.
///
/// Use this when embedding Everruns directly and seeding a harness in code.
/// IDs and timestamps are generated at [`build`](Self::build) time unless
/// explicitly set.
#[derive(Debug, Clone)]
pub struct HarnessBuilder {
    id: HarnessId,
    name: String,
    display_name: Option<String>,
    description: Option<String>,
    system_prompt: String,
    parent_harness_id: Option<HarnessId>,
    default_model_id: Option<ModelId>,
    tags: Vec<String>,
    capabilities: Vec<AgentCapabilityConfig>,
    initial_files: Vec<everruns_core::InitialFile>,
    network_access: Option<NetworkAccessList>,
    mcp_servers: ScopedMcpServers,
    is_built_in: bool,
    status: HarnessStatus,
    created_at: Option<DateTime<Utc>>,
    updated_at: Option<DateTime<Utc>>,
}

impl HarnessBuilder {
    /// Create a harness builder from the required embedder-facing fields.
    pub fn new(name: impl Into<String>, system_prompt: impl Into<String>) -> Self {
        Self {
            id: HarnessId::new(),
            name: name.into(),
            display_name: None,
            description: None,
            system_prompt: system_prompt.into(),
            parent_harness_id: None,
            default_model_id: None,
            tags: Vec::new(),
            capabilities: Vec::new(),
            initial_files: Vec::new(),
            network_access: None,
            mcp_servers: ScopedMcpServers::default(),
            is_built_in: false,
            status: HarnessStatus::Active,
            created_at: None,
            updated_at: None,
        }
    }

    /// Set a stable harness id instead of generating one.
    pub fn id(mut self, id: HarnessId) -> Self {
        self.id = id;
        self
    }

    /// Return the id currently assigned to this builder.
    pub fn harness_id(&self) -> HarnessId {
        self.id
    }

    pub fn name(mut self, name: impl Into<String>) -> Self {
        self.name = name.into();
        self
    }

    pub fn display_name(mut self, display_name: impl Into<String>) -> Self {
        self.display_name = Some(display_name.into());
        self
    }

    pub fn description(mut self, description: impl Into<String>) -> Self {
        self.description = Some(description.into());
        self
    }

    pub fn system_prompt(mut self, system_prompt: impl Into<String>) -> Self {
        self.system_prompt = system_prompt.into();
        self
    }

    pub fn parent_harness_id(mut self, parent_harness_id: HarnessId) -> Self {
        self.parent_harness_id = Some(parent_harness_id);
        self
    }

    pub fn default_model_id(mut self, default_model_id: ModelId) -> Self {
        self.default_model_id = Some(default_model_id);
        self
    }

    pub fn tag(mut self, tag: impl Into<String>) -> Self {
        self.tags.push(tag.into());
        self
    }

    pub fn tags<I, S>(mut self, tags: I) -> Self
    where
        I: IntoIterator<Item = S>,
        S: Into<String>,
    {
        self.tags.extend(tags.into_iter().map(Into::into));
        self
    }

    pub fn capability(mut self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.capabilities.push(capability.into());
        self
    }

    pub fn with_capability(self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.capability(capability)
    }

    pub fn capabilities<I, C>(mut self, capabilities: I) -> Self
    where
        I: IntoIterator<Item = C>,
        C: Into<AgentCapabilityConfig>,
    {
        self.capabilities
            .extend(capabilities.into_iter().map(Into::into));
        self
    }

    pub fn initial_file(mut self, file: everruns_core::InitialFile) -> Self {
        self.initial_files.push(file);
        self
    }

    pub fn network_access(mut self, network_access: NetworkAccessList) -> Self {
        self.network_access = Some(network_access);
        self
    }

    pub fn mcp_servers(mut self, mcp_servers: ScopedMcpServers) -> Self {
        self.mcp_servers = mcp_servers;
        self
    }

    pub fn is_built_in(mut self, is_built_in: bool) -> Self {
        self.is_built_in = is_built_in;
        self
    }

    pub fn status(mut self, status: HarnessStatus) -> Self {
        self.status = status;
        self
    }

    pub fn created_at(mut self, created_at: DateTime<Utc>) -> Self {
        self.created_at = Some(created_at);
        self
    }

    pub fn updated_at(mut self, updated_at: DateTime<Utc>) -> Self {
        self.updated_at = Some(updated_at);
        self
    }

    /// Build the harness. Builders do not validate domain invariants.
    pub fn build(self) -> Harness {
        let created_at = self.created_at.unwrap_or_else(Utc::now);
        let updated_at = self.updated_at.unwrap_or(created_at);

        Harness {
            id: self.id,
            name: self.name,
            display_name: self.display_name,
            description: self.description,
            system_prompt: self.system_prompt,
            parent_harness_id: self.parent_harness_id,
            default_model_id: self.default_model_id,
            tags: self.tags,
            capabilities: self.capabilities,
            initial_files: self.initial_files,
            network_access: self.network_access,
            mcp_servers: self.mcp_servers,
            is_built_in: self.is_built_in,
            status: self.status,
            created_at,
            updated_at,
            archived_at: None,
            deleted_at: None,
        }
    }
}

/// Builds an [`Agent`] with runtime-friendly defaults.
#[derive(Debug, Clone)]
pub struct AgentBuilder {
    id: AgentId,
    name: String,
    display_name: Option<String>,
    description: Option<String>,
    system_prompt: String,
    default_model_id: Option<ModelId>,
    tags: Vec<String>,
    capabilities: Vec<AgentCapabilityConfig>,
    initial_files: Vec<everruns_core::InitialFile>,
    network_access: Option<NetworkAccessList>,
    max_iterations: Option<usize>,
    tools: Vec<ToolDefinition>,
    mcp_servers: ScopedMcpServers,
    status: AgentStatus,
    created_at: Option<DateTime<Utc>>,
    updated_at: Option<DateTime<Utc>>,
}

impl AgentBuilder {
    /// Create an agent builder from the required embedder-facing fields.
    pub fn new(name: impl Into<String>, system_prompt: impl Into<String>) -> Self {
        Self {
            id: AgentId::new(),
            name: name.into(),
            display_name: None,
            description: None,
            system_prompt: system_prompt.into(),
            default_model_id: None,
            tags: Vec::new(),
            capabilities: Vec::new(),
            initial_files: Vec::new(),
            network_access: None,
            max_iterations: None,
            tools: Vec::new(),
            mcp_servers: ScopedMcpServers::default(),
            status: AgentStatus::Active,
            created_at: None,
            updated_at: None,
        }
    }

    /// Set a stable agent id instead of generating one.
    pub fn id(mut self, id: AgentId) -> Self {
        self.id = id;
        self
    }

    /// Return the id currently assigned to this builder.
    pub fn agent_id(&self) -> AgentId {
        self.id
    }

    pub fn name(mut self, name: impl Into<String>) -> Self {
        self.name = name.into();
        self
    }

    pub fn display_name(mut self, display_name: impl Into<String>) -> Self {
        self.display_name = Some(display_name.into());
        self
    }

    pub fn description(mut self, description: impl Into<String>) -> Self {
        self.description = Some(description.into());
        self
    }

    pub fn system_prompt(mut self, system_prompt: impl Into<String>) -> Self {
        self.system_prompt = system_prompt.into();
        self
    }

    pub fn default_model_id(mut self, default_model_id: ModelId) -> Self {
        self.default_model_id = Some(default_model_id);
        self
    }

    pub fn tag(mut self, tag: impl Into<String>) -> Self {
        self.tags.push(tag.into());
        self
    }

    pub fn tags<I, S>(mut self, tags: I) -> Self
    where
        I: IntoIterator<Item = S>,
        S: Into<String>,
    {
        self.tags.extend(tags.into_iter().map(Into::into));
        self
    }

    pub fn capability(mut self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.capabilities.push(capability.into());
        self
    }

    pub fn with_capability(self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.capability(capability)
    }

    pub fn capabilities<I, C>(mut self, capabilities: I) -> Self
    where
        I: IntoIterator<Item = C>,
        C: Into<AgentCapabilityConfig>,
    {
        self.capabilities
            .extend(capabilities.into_iter().map(Into::into));
        self
    }

    pub fn initial_file(mut self, file: everruns_core::InitialFile) -> Self {
        self.initial_files.push(file);
        self
    }

    pub fn network_access(mut self, network_access: NetworkAccessList) -> Self {
        self.network_access = Some(network_access);
        self
    }

    pub fn max_iterations(mut self, max_iterations: usize) -> Self {
        self.max_iterations = Some(max_iterations);
        self
    }

    pub fn tool(mut self, tool: ToolDefinition) -> Self {
        self.tools.push(tool);
        self
    }

    pub fn tools<I>(mut self, tools: I) -> Self
    where
        I: IntoIterator<Item = ToolDefinition>,
    {
        self.tools.extend(tools);
        self
    }

    pub fn mcp_servers(mut self, mcp_servers: ScopedMcpServers) -> Self {
        self.mcp_servers = mcp_servers;
        self
    }

    pub fn status(mut self, status: AgentStatus) -> Self {
        self.status = status;
        self
    }

    pub fn created_at(mut self, created_at: DateTime<Utc>) -> Self {
        self.created_at = Some(created_at);
        self
    }

    pub fn updated_at(mut self, updated_at: DateTime<Utc>) -> Self {
        self.updated_at = Some(updated_at);
        self
    }

    /// Build the agent. Builders do not validate domain invariants.
    pub fn build(self) -> Agent {
        let created_at = self.created_at.unwrap_or_else(Utc::now);
        let updated_at = self.updated_at.unwrap_or(created_at);

        Agent {
            public_id: self.id,
            internal_id: Uuid::nil(),
            name: self.name,
            display_name: self.display_name,
            description: self.description,
            system_prompt: self.system_prompt,
            default_model_id: self.default_model_id,
            default_version_id: None,
            forked_from_agent_id: None,
            forked_from_version_id: None,
            root_agent_id: None,
            tags: self.tags,
            capabilities: self.capabilities,
            initial_files: self.initial_files,
            network_access: self.network_access,
            max_iterations: self.max_iterations,
            tools: self.tools,
            mcp_servers: self.mcp_servers,
            status: self.status,
            created_at,
            updated_at,
            archived_at: None,
            deleted_at: None,
            usage: None,
        }
    }
}

/// Builds a [`Session`] with runtime-friendly defaults.
#[derive(Debug, Clone)]
pub struct SessionBuilder {
    id: SessionId,
    organization_id: String,
    harness_id: HarnessId,
    agent_id: Option<AgentId>,
    owner_principal_id: PrincipalId,
    title: Option<String>,
    locale: Option<String>,
    tags: Vec<String>,
    model_id: Option<ModelId>,
    capabilities: Vec<AgentCapabilityConfig>,
    tools: Vec<ToolDefinition>,
    mcp_servers: ScopedMcpServers,
    system_prompt: Option<String>,
    initial_files: Vec<everruns_core::InitialFile>,
    network_access: Option<NetworkAccessList>,
    max_iterations: Option<usize>,
    status: SessionStatus,
    created_at: Option<DateTime<Utc>>,
    updated_at: Option<DateTime<Utc>>,
}

impl SessionBuilder {
    /// Create a session builder for the required harness id.
    pub fn new(harness_id: HarnessId) -> Self {
        Self {
            id: SessionId::new(),
            organization_id: DEFAULT_ORG_PUBLIC_ID.to_string(),
            harness_id,
            agent_id: None,
            owner_principal_id: PrincipalId::from_seed(1),
            title: None,
            locale: None,
            tags: Vec::new(),
            model_id: None,
            capabilities: Vec::new(),
            tools: Vec::new(),
            mcp_servers: ScopedMcpServers::default(),
            system_prompt: None,
            initial_files: Vec::new(),
            network_access: None,
            max_iterations: None,
            status: SessionStatus::Started,
            created_at: None,
            updated_at: None,
        }
    }

    /// Set a stable session id instead of generating one.
    pub fn id(mut self, id: SessionId) -> Self {
        self.id = id;
        self
    }

    /// Return the id currently assigned to this builder.
    pub fn session_id(&self) -> SessionId {
        self.id
    }

    pub fn organization_id(mut self, organization_id: impl Into<String>) -> Self {
        self.organization_id = organization_id.into();
        self
    }

    pub fn harness(mut self, harness_id: HarnessId) -> Self {
        self.harness_id = harness_id;
        self
    }

    pub fn agent(mut self, agent_id: AgentId) -> Self {
        self.agent_id = Some(agent_id);
        self
    }

    pub fn owner_principal_id(mut self, owner_principal_id: PrincipalId) -> Self {
        self.owner_principal_id = owner_principal_id;
        self
    }

    pub fn title(mut self, title: impl Into<String>) -> Self {
        self.title = Some(title.into());
        self
    }

    pub fn locale(mut self, locale: impl Into<String>) -> Self {
        self.locale = Some(locale.into());
        self
    }

    pub fn tag(mut self, tag: impl Into<String>) -> Self {
        self.tags.push(tag.into());
        self
    }

    pub fn tags<I, S>(mut self, tags: I) -> Self
    where
        I: IntoIterator<Item = S>,
        S: Into<String>,
    {
        self.tags.extend(tags.into_iter().map(Into::into));
        self
    }

    pub fn model_id(mut self, model_id: ModelId) -> Self {
        self.model_id = Some(model_id);
        self
    }

    pub fn capability(mut self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.capabilities.push(capability.into());
        self
    }

    pub fn with_capability(self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.capability(capability)
    }

    pub fn capabilities<I, C>(mut self, capabilities: I) -> Self
    where
        I: IntoIterator<Item = C>,
        C: Into<AgentCapabilityConfig>,
    {
        self.capabilities
            .extend(capabilities.into_iter().map(Into::into));
        self
    }

    pub fn tool(mut self, tool: ToolDefinition) -> Self {
        self.tools.push(tool);
        self
    }

    pub fn tools<I>(mut self, tools: I) -> Self
    where
        I: IntoIterator<Item = ToolDefinition>,
    {
        self.tools.extend(tools);
        self
    }

    pub fn mcp_servers(mut self, mcp_servers: ScopedMcpServers) -> Self {
        self.mcp_servers = mcp_servers;
        self
    }

    pub fn system_prompt(mut self, system_prompt: impl Into<String>) -> Self {
        self.system_prompt = Some(system_prompt.into());
        self
    }

    pub fn initial_file(mut self, file: everruns_core::InitialFile) -> Self {
        self.initial_files.push(file);
        self
    }

    pub fn network_access(mut self, network_access: NetworkAccessList) -> Self {
        self.network_access = Some(network_access);
        self
    }

    pub fn max_iterations(mut self, max_iterations: usize) -> Self {
        self.max_iterations = Some(max_iterations);
        self
    }

    pub fn status(mut self, status: SessionStatus) -> Self {
        self.status = status;
        self
    }

    pub fn created_at(mut self, created_at: DateTime<Utc>) -> Self {
        self.created_at = Some(created_at);
        self
    }

    pub fn updated_at(mut self, updated_at: DateTime<Utc>) -> Self {
        self.updated_at = Some(updated_at);
        self
    }

    /// Build the session. Builders do not validate domain invariants.
    pub fn build(self) -> Session {
        let created_at = self.created_at.unwrap_or_else(Utc::now);
        let updated_at = self.updated_at.unwrap_or(created_at);

        Session {
            id: self.id,
            organization_id: self.organization_id,
            harness_id: self.harness_id,
            agent_id: self.agent_id,
            agent_version_id: None,
            agent_identity_id: None,
            owner_principal_id: self.owner_principal_id,
            resolved_owner_user_id: None,
            owner: None,
            effective_owner: None,
            title: self.title,
            locale: self.locale,
            preview: None,
            output_preview: None,
            tags: self.tags,
            model_id: self.model_id,
            capabilities: self.capabilities,
            tools: self.tools,
            mcp_servers: self.mcp_servers,
            system_prompt: self.system_prompt,
            initial_files: self.initial_files,
            hints: None,
            network_access: self.network_access,
            max_iterations: self.max_iterations,
            status: self.status,
            created_at,
            updated_at,
            started_at: None,
            finished_at: None,
            usage: None,
            is_pinned: None,
            active_schedule_count: None,
            features: Vec::new(),
            parent_session_id: None,
            subagent_name: None,
            subagent_task: None,
            subagent_status: None,
            blueprint_id: None,
            blueprint_config: None,
        }
    }
}

/// High-level builder for seeding one harness, one agent, and one session.
///
/// This is the compact path used by embedders that want a runnable runtime
/// without constructing each core model separately.
#[derive(Debug, Clone)]
pub struct SingleSessionBuilder {
    harness: HarnessBuilder,
    agent: AgentBuilder,
    session: SessionBuilder,
}

impl Default for SingleSessionBuilder {
    fn default() -> Self {
        let harness = HarnessBuilder::new("embedded-harness", "");
        let agent = AgentBuilder::new("embedded-agent", "");
        let session = SessionBuilder::new(harness.harness_id()).agent(agent.agent_id());
        Self {
            harness,
            agent,
            session,
        }
    }
}

impl SingleSessionBuilder {
    /// Configure the seeded harness. Mutates the existing `HarnessBuilder`
    /// in place so previously configured fields (e.g. `network_access`) are
    /// preserved regardless of call order.
    pub fn harness(mut self, name: impl Into<String>, system_prompt: impl Into<String>) -> Self {
        let harness_id = self.harness.harness_id();
        self.harness = self.harness.name(name).system_prompt(system_prompt);
        self.session = self.session.harness(harness_id);
        self
    }

    /// Configure the seeded agent. Mutates the existing `AgentBuilder` in
    /// place so previously configured fields (e.g. `network_access`) are
    /// preserved regardless of call order.
    pub fn agent(mut self, name: impl Into<String>, system_prompt: impl Into<String>) -> Self {
        let agent_id = self.agent.agent_id();
        self.agent = self.agent.name(name).system_prompt(system_prompt);
        self.session = self.session.agent(agent_id);
        self
    }

    /// Add a harness-level capability.
    pub fn with_capability(self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.harness_capability(capability)
    }

    /// Add a harness-level capability.
    pub fn harness_capability(mut self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.harness = self.harness.capability(capability);
        self
    }

    /// Add an agent-level capability.
    pub fn agent_capability(mut self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.agent = self.agent.capability(capability);
        self
    }

    /// Add a session-level capability.
    pub fn session_capability(mut self, capability: impl Into<AgentCapabilityConfig>) -> Self {
        self.session = self.session.capability(capability);
        self
    }

    pub fn harness_display_name(mut self, display_name: impl Into<String>) -> Self {
        self.harness = self.harness.display_name(display_name);
        self
    }

    pub fn agent_display_name(mut self, display_name: impl Into<String>) -> Self {
        self.agent = self.agent.display_name(display_name);
        self
    }

    pub fn harness_description(mut self, description: impl Into<String>) -> Self {
        self.harness = self.harness.description(description);
        self
    }

    pub fn agent_description(mut self, description: impl Into<String>) -> Self {
        self.agent = self.agent.description(description);
        self
    }

    pub fn session_title(mut self, title: impl Into<String>) -> Self {
        self.session = self.session.title(title);
        self
    }

    pub fn locale(mut self, locale: impl Into<String>) -> Self {
        self.session = self.session.locale(locale);
        self
    }

    pub fn tag(mut self, tag: impl Into<String>) -> Self {
        let tag = tag.into();
        self.harness = self.harness.tag(tag.clone());
        self.agent = self.agent.tag(tag.clone());
        self.session = self.session.tag(tag);
        self
    }

    pub fn session_model_id(mut self, model_id: ModelId) -> Self {
        self.session = self.session.model_id(model_id);
        self
    }

    pub fn harness_default_model_id(mut self, model_id: ModelId) -> Self {
        self.harness = self.harness.default_model_id(model_id);
        self
    }

    pub fn agent_default_model_id(mut self, model_id: ModelId) -> Self {
        self.agent = self.agent.default_model_id(model_id);
        self
    }

    pub fn agent_max_iterations(mut self, max_iterations: usize) -> Self {
        self.agent = self.agent.max_iterations(max_iterations);
        self
    }

    pub fn session_max_iterations(mut self, max_iterations: usize) -> Self {
        self.session = self.session.max_iterations(max_iterations);
        self
    }

    pub fn agent_tool(mut self, tool: ToolDefinition) -> Self {
        self.agent = self.agent.tool(tool);
        self
    }

    pub fn session_tool(mut self, tool: ToolDefinition) -> Self {
        self.session = self.session.tool(tool);
        self
    }

    pub fn harness_initial_file(mut self, file: everruns_core::InitialFile) -> Self {
        self.harness = self.harness.initial_file(file);
        self
    }

    pub fn agent_initial_file(mut self, file: everruns_core::InitialFile) -> Self {
        self.agent = self.agent.initial_file(file);
        self
    }

    pub fn session_initial_file(mut self, file: everruns_core::InitialFile) -> Self {
        self.session = self.session.initial_file(file);
        self
    }

    pub fn harness_network_access(mut self, network_access: NetworkAccessList) -> Self {
        self.harness = self.harness.network_access(network_access);
        self
    }

    pub fn agent_network_access(mut self, network_access: NetworkAccessList) -> Self {
        self.agent = self.agent.network_access(network_access);
        self
    }

    pub fn session_network_access(mut self, network_access: NetworkAccessList) -> Self {
        self.session = self.session.network_access(network_access);
        self
    }

    pub fn harness_id(&self) -> HarnessId {
        self.harness.harness_id()
    }

    pub fn agent_id(&self) -> AgentId {
        self.agent.agent_id()
    }

    pub fn session_id(&self) -> SessionId {
        self.session.session_id()
    }

    pub(crate) fn build(self) -> (Harness, Agent, Session, SessionId) {
        let session_id = self.session.session_id();
        (
            self.harness.build(),
            self.agent.build(),
            self.session.build(),
            session_id,
        )
    }
}