radkit 0.0.5

Rust AI Agent Development Kit
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
//! Integration tests for runtime services.
//!
//! These tests verify that the runtime services (TaskManager, MemoryService, LoggingService,
//! AuthService) work correctly together within a runtime handle.

use radkit::agent::Agent;
use radkit::runtime::context::AuthContext;
use radkit::runtime::memory::{ContentSource, MemoryContent, SearchOptions};
use radkit::runtime::task_manager::InMemoryTaskStore;
use radkit::runtime::{AgentRuntime, ListTasksFilter, LogLevel, Runtime};
use radkit::test_support::FakeLlm;
use std::collections::HashMap;

fn test_agent() -> radkit::agent::AgentDefinition {
    Agent::builder().with_name("Test Agent").build()
}

fn runtime_with_manager(llm: FakeLlm) -> Runtime {
    Runtime::builder(test_agent(), llm)
        .with_task_store(InMemoryTaskStore::new())
        .build()
}

#[tokio::test]
async fn test_auth_service_provides_context() {
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = Runtime::builder(test_agent(), llm).build();

    let auth_context = runtime.auth().get_auth_context();

    assert_eq!(auth_context.app_name, "default-app");
    assert_eq!(auth_context.user_name, "default-user");
}

#[tokio::test]
async fn test_task_manager_save_and_get() {
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = runtime_with_manager(llm);
    let task_manager = runtime.task_manager();

    let auth_context = runtime.auth().get_auth_context();

    use a2a_types::{TaskState, TaskStatus};
    use radkit::runtime::task_manager::Task;

    // Create a task
    let task = Task {
        id: "test-task-1".to_string(),
        context_id: "test-context-1".to_string(),
        status: TaskStatus {
            state: TaskState::Working as i32,
            timestamp: None,
            message: None,
        },
        artifacts: vec![],
    };

    task_manager
        .save_task(&auth_context, &task)
        .await
        .expect("save task");

    // Retrieve the task
    let retrieved = task_manager
        .get_task(&auth_context, "test-task-1")
        .await
        .expect("get task")
        .expect("task should exist");

    assert_eq!(retrieved.id, "test-task-1");
    assert_eq!(retrieved.context_id, "test-context-1");
}

#[tokio::test]
async fn test_task_manager_auth_scoping() {
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = runtime_with_manager(llm).into_shared();
    let task_manager = runtime.task_manager();

    // Create two different auth contexts
    let auth_context_1 = AuthContext {
        app_name: "app1".to_string(),
        user_name: "user1".to_string(),
    };

    let auth_context_2 = AuthContext {
        app_name: "app2".to_string(),
        user_name: "user2".to_string(),
    };

    use a2a_types::{TaskState, TaskStatus};
    use radkit::runtime::task_manager::Task;

    // Save task for auth_context_1
    let task1 = Task {
        id: "task-1".to_string(),
        context_id: "context-1".to_string(),
        status: TaskStatus {
            state: TaskState::Working as i32,
            timestamp: None,
            message: None,
        },
        artifacts: vec![],
    };

    task_manager
        .save_task(&auth_context_1, &task1)
        .await
        .expect("save task for auth1");

    // Save task for auth_context_2
    let task2 = Task {
        id: "task-2".to_string(),
        context_id: "context-2".to_string(),
        status: TaskStatus {
            state: TaskState::Working as i32,
            timestamp: None,
            message: None,
        },
        artifacts: vec![],
    };

    task_manager
        .save_task(&auth_context_2, &task2)
        .await
        .expect("save task for auth2");

    // Verify auth_context_1 can only see its own task
    let retrieved = task_manager
        .get_task(&auth_context_1, "task-1")
        .await
        .expect("get task")
        .expect("task should exist");
    assert_eq!(retrieved.id, "task-1");

    let not_found = task_manager
        .get_task(&auth_context_1, "task-2")
        .await
        .expect("get task");
    assert!(not_found.is_none(), "auth_context_1 should not see task-2");

    // Verify auth_context_2 can only see its own task
    let retrieved = task_manager
        .get_task(&auth_context_2, "task-2")
        .await
        .expect("get task")
        .expect("task should exist");
    assert_eq!(retrieved.id, "task-2");

    let not_found = task_manager
        .get_task(&auth_context_2, "task-1")
        .await
        .expect("get task");
    assert!(not_found.is_none(), "auth_context_2 should not see task-1");
}

#[tokio::test]
async fn test_task_manager_list_tasks() {
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = runtime_with_manager(llm).into_shared();
    let task_manager = runtime.task_manager();
    let auth_context = runtime.auth().get_auth_context();

    use a2a_types::{TaskState, TaskStatus};
    use radkit::runtime::task_manager::Task;

    // Create multiple tasks
    for i in 1..=5 {
        let task = Task {
            id: format!("task-{i}"),
            context_id: format!("context-{i}"),
            status: TaskStatus {
                state: TaskState::Working as i32,
                timestamp: None,
                message: None,
            },
            artifacts: vec![],
        };

        task_manager
            .save_task(&auth_context, &task)
            .await
            .expect("save task");
    }

    // List all tasks
    let filter = ListTasksFilter::default();
    let result = task_manager
        .list_tasks(&auth_context, &filter)
        .await
        .expect("list tasks");

    assert!(result.items.len() >= 5, "Should have at least 5 tasks");
}

#[tokio::test]
async fn test_memory_service_add_and_search() {
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = Runtime::builder(test_agent(), llm).build();

    let auth = runtime.auth();
    let auth_context = auth.get_auth_context();
    let memory = runtime.memory();

    // Add a user fact
    let content = MemoryContent {
        text: "User Alice prefers dark mode theme".to_string(),
        source: ContentSource::UserFact {
            category: Some("preferences".to_string()),
        },
        metadata: HashMap::new(),
    };

    let id = memory
        .add(&auth_context, content)
        .await
        .expect("add memory");

    assert!(id.starts_with("fact:preferences:"));

    // Search for the fact
    let results = memory
        .search(&auth_context, "dark mode", SearchOptions::history_only())
        .await
        .expect("search memory");

    assert_eq!(results.len(), 1);
    assert!(results[0].text.contains("dark mode"));
}

#[tokio::test]
async fn test_memory_service_auth_scoping() {
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = Runtime::builder(test_agent(), llm).build();

    let memory = runtime.memory();

    // Create two different auth contexts
    let auth_context_1 = AuthContext {
        app_name: "app1".to_string(),
        user_name: "user1".to_string(),
    };

    let auth_context_2 = AuthContext {
        app_name: "app2".to_string(),
        user_name: "user2".to_string(),
    };

    // Add fact for auth_context_1
    memory
        .add(
            &auth_context_1,
            MemoryContent {
                text: "User1 secret information".to_string(),
                source: ContentSource::UserFact { category: None },
                metadata: HashMap::new(),
            },
        )
        .await
        .expect("add for auth1");

    // Add fact for auth_context_2
    memory
        .add(
            &auth_context_2,
            MemoryContent {
                text: "User2 secret information".to_string(),
                source: ContentSource::UserFact { category: None },
                metadata: HashMap::new(),
            },
        )
        .await
        .expect("add for auth2");

    // Verify auth_context_1 only sees its own data
    let results1 = memory
        .search(&auth_context_1, "secret", SearchOptions::default())
        .await
        .expect("search auth1");
    assert_eq!(results1.len(), 1);
    assert!(results1[0].text.contains("User1"));

    // Verify auth_context_2 only sees its own data
    let results2 = memory
        .search(&auth_context_2, "secret", SearchOptions::default())
        .await
        .expect("search auth2");
    assert_eq!(results2.len(), 1);
    assert!(results2[0].text.contains("User2"));
}

#[tokio::test]
async fn test_logging_service() {
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = Runtime::builder(test_agent(), llm).build();

    let logging = runtime.logging();

    // Test logging at different levels (should not panic)
    logging.log(LogLevel::Info, "Test info message");
    logging.log(LogLevel::Warn, "Test warn message");
    logging.log(LogLevel::Error, "Test error message");
    logging.log(LogLevel::Debug, "Test debug message");
}

#[tokio::test]
async fn test_runtime_services_together() {
    // Test that all services can be used together in a workflow
    let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
    let runtime = runtime_with_manager(llm).into_shared();
    let task_manager = runtime.task_manager();

    let auth = runtime.auth();
    let auth_context = auth.get_auth_context();

    // Use logging
    runtime.logging().log(LogLevel::Info, "Starting workflow");

    // Use memory to store workflow state as a user fact
    let workflow_content = MemoryContent {
        text: "Workflow step 1: processing data".to_string(),
        source: ContentSource::UserFact {
            category: Some("workflow".to_string()),
        },
        metadata: HashMap::new(),
    };
    let _workflow_id = runtime
        .memory()
        .add(&auth_context, workflow_content)
        .await
        .expect("save workflow state");

    // Create a task
    use a2a_types::{TaskState, TaskStatus};
    use radkit::runtime::task_manager::Task;

    let task = Task {
        id: "workflow-task-1".to_string(),
        context_id: "workflow-context-1".to_string(),
        status: TaskStatus {
            state: TaskState::Working as i32,
            timestamp: None,
            message: None,
        },
        artifacts: vec![],
    };

    task_manager
        .save_task(&auth_context, &task)
        .await
        .expect("save task");

    // Retrieve workflow state via search
    let workflow_results = runtime
        .memory()
        .search(
            &auth_context,
            "workflow processing",
            SearchOptions::default(),
        )
        .await
        .expect("search workflow state");

    assert!(!workflow_results.is_empty(), "Should find workflow state");
    assert!(workflow_results[0].text.contains("processing"));

    // Retrieve task
    let retrieved_task = task_manager
        .get_task(&auth_context, "workflow-task-1")
        .await
        .expect("get task")
        .expect("task should exist");

    assert_eq!(retrieved_task.id, "workflow-task-1");

    // Log completion
    runtime.logging().log(LogLevel::Info, "Workflow completed");
}

#[cfg(all(feature = "runtime", not(all(target_os = "wasi", target_env = "p1"))))]
mod a2a_v1_runtime_tests {
    use super::*;
    use a2a_client::A2AClient;
    use a2a_types::{self as v1, AgentCard, Message, Part};
    use futures::StreamExt;
    use radkit::agent::{
        OnInputResult, OnRequestResult, RegisteredSkill, SkillHandler, SkillMetadata,
    };
    use radkit::errors::{AgentError, AgentResult};
    use radkit::models::{Content, LlmResponse};
    use radkit::runtime::context::{ProgressSender, State as SkillState};
    use std::time::Duration;

    struct ImmediateSkill;

    #[async_trait::async_trait]
    impl SkillHandler for ImmediateSkill {
        async fn on_request(
            &self,
            _state: &mut SkillState,
            _progress: &ProgressSender,
            _runtime: &dyn AgentRuntime,
            _content: Content,
        ) -> Result<OnRequestResult, AgentError> {
            Ok(OnRequestResult::Completed {
                message: Some(Content::from_text("Done")),
                artifacts: Vec::new(),
            })
        }

        async fn on_input_received(
            &self,
            _state: &mut SkillState,
            _progress: &ProgressSender,
            _runtime: &dyn AgentRuntime,
            _input: Content,
        ) -> Result<OnInputResult, AgentError> {
            unreachable!("immediate skill never continues");
        }
    }

    impl RegisteredSkill for ImmediateSkill {
        fn metadata() -> std::sync::Arc<SkillMetadata> {
            std::sync::Arc::new(SkillMetadata::new(
                "immediate-skill",
                "Immediate Skill",
                "Completes immediately",
                &[],
                &[],
                &[],
                &[],
            ))
        }
    }

    fn negotiation_response(skill_id: &str) -> AgentResult<LlmResponse> {
        FakeLlm::text_response(
            serde_json::json!({
                "type": "start_task",
                "skill_id": skill_id,
                "reasoning": "selected in test"
            })
            .to_string(),
        )
    }

    fn test_agent() -> radkit::agent::AgentDefinition {
        Agent::builder()
            .with_name("Test Agent")
            .with_version("1.0.0")
            .with_skill(ImmediateSkill)
            .build()
    }

    fn free_local_address() -> String {
        let listener = std::net::TcpListener::bind("127.0.0.1:0").expect("bind ephemeral port");
        let address = listener.local_addr().expect("listener address");
        drop(listener);
        address.to_string()
    }

    async fn wait_for_server(base_url: &str) {
        let client = reqwest::Client::new();
        let card_url = format!("{base_url}/.well-known/agent-card.json");

        for _ in 0..50 {
            let ready = client
                .get(&card_url)
                .send()
                .await
                .map(|response| response.status().is_success())
                .unwrap_or(false);
            if ready {
                return;
            }
            tokio::time::sleep(Duration::from_millis(50)).await;
        }

        panic!("runtime server did not start at {card_url}");
    }

    fn create_message(text: &str) -> Message {
        Message {
            message_id: uuid::Uuid::new_v4().to_string(),
            context_id: String::new(),
            task_id: String::new(),
            role: v1::Role::User.into(),
            parts: vec![Part {
                content: Some(v1::part::Content::Text(text.to_string())),
                metadata: None,
                filename: String::new(),
                media_type: "text/plain".to_string(),
            }],
            metadata: None,
            extensions: Vec::new(),
            reference_task_ids: Vec::new(),
        }
    }

    fn http_json_client(base_url: &str) -> A2AClient {
        A2AClient::from_card(AgentCard {
            name: "Test Agent".to_string(),
            description: "desc".to_string(),
            supported_interfaces: vec![v1::AgentInterface {
                url: base_url.to_string(),
                protocol_binding: "HTTP+JSON".to_string(),
                tenant: String::new(),
                protocol_version: "1.0".to_string(),
            }],
            provider: None,
            version: "1.0.0".to_string(),
            documentation_url: None,
            capabilities: Some(v1::AgentCapabilities {
                streaming: Some(true),
                push_notifications: Some(false),
                extensions: Vec::new(),
                extended_agent_card: Some(false),
            }),
            security_schemes: std::collections::HashMap::new(),
            security_requirements: Vec::new(),
            default_input_modes: vec!["text/plain".to_string()],
            default_output_modes: vec!["text/plain".to_string()],
            skills: Vec::new(),
            signatures: Vec::new(),
            icon_url: None,
        })
        .expect("http client")
    }

    fn rpc_client(base_url: &str) -> A2AClient {
        A2AClient::from_card(AgentCard {
            name: "Test Agent".to_string(),
            description: "desc".to_string(),
            supported_interfaces: vec![v1::AgentInterface {
                url: format!("{base_url}/rpc"),
                protocol_binding: "JSONRPC".to_string(),
                tenant: String::new(),
                protocol_version: "1.0".to_string(),
            }],
            provider: None,
            version: "1.0.0".to_string(),
            documentation_url: None,
            capabilities: Some(v1::AgentCapabilities {
                streaming: Some(true),
                push_notifications: Some(false),
                extensions: Vec::new(),
                extended_agent_card: Some(false),
            }),
            security_schemes: std::collections::HashMap::new(),
            security_requirements: Vec::new(),
            default_input_modes: vec!["text/plain".to_string()],
            default_output_modes: vec!["text/plain".to_string()],
            skills: Vec::new(),
            signatures: Vec::new(),
            icon_url: None,
        })
        .expect("rpc client")
    }

    #[tokio::test]
    async fn a2a_client_v1_http_json_roundtrip() {
        let llm = FakeLlm::with_responses("fake-llm", [negotiation_response("immediate-skill")]);
        let address = free_local_address();
        let base_url = format!("http://{address}");
        let runtime = Runtime::builder(test_agent(), llm)
            .base_url(base_url.clone())
            .build();
        let server = tokio::spawn(async move {
            runtime.serve(address).await.expect("runtime server");
        });

        wait_for_server(&base_url).await;

        let client = http_json_client(&base_url);
        let send_response = client
            .send_message(v1::SendMessageRequest {
                tenant: String::new(),
                message: Some(create_message("hello")),
                configuration: None,
                metadata: None,
            })
            .await
            .expect("send message");

        let task = match send_response.payload {
            Some(v1::send_message_response::Payload::Task(task)) => task,
            other => panic!("expected task payload, got {other:?}"),
        };
        assert_eq!(
            v1::TaskState::try_from(task.status.as_ref().expect("status").state)
                .expect("task state"),
            v1::TaskState::Completed
        );

        let fetched = client
            .get_task(v1::GetTaskRequest {
                tenant: String::new(),
                id: task.id.clone(),
                history_length: Some(5),
            })
            .await
            .expect("get task");
        assert_eq!(fetched.id, task.id);

        let listed = client
            .list_tasks(v1::ListTasksRequest {
                tenant: String::new(),
                context_id: task.context_id.clone(),
                status: v1::TaskState::Unspecified.into(),
                page_size: Some(10),
                page_token: String::new(),
                history_length: Some(5),
                status_timestamp_after: None,
                include_artifacts: Some(true),
            })
            .await
            .expect("list tasks");
        assert!(listed
            .tasks
            .iter()
            .any(|listed_task| listed_task.id == task.id));

        let card = client
            .get_extended_agent_card(v1::GetExtendedAgentCardRequest {
                tenant: String::new(),
            })
            .await
            .expect("extended card");
        assert_eq!(card.name, "Test Agent");

        server.abort();
        let _ = server.await;
    }

    #[tokio::test]
    async fn a2a_client_v1_jsonrpc_stream_roundtrip() {
        let llm = FakeLlm::with_responses("fake-llm", [negotiation_response("immediate-skill")]);
        let address = free_local_address();
        let base_url = format!("http://{address}");
        let runtime = Runtime::builder(test_agent(), llm)
            .base_url(base_url.clone())
            .build();
        let server = tokio::spawn(async move {
            runtime.serve(address).await.expect("runtime server");
        });

        wait_for_server(&base_url).await;

        let client = rpc_client(&base_url);
        let mut stream = client
            .send_streaming_message(v1::SendMessageRequest {
                tenant: String::new(),
                message: Some(create_message("hello")),
                configuration: None,
                metadata: None,
            })
            .await
            .expect("stream start");

        let mut last_event = None;
        while let Some(item) = stream.next().await {
            let event = item.expect("stream event");
            last_event = Some(event);
        }

        let last_event = last_event.expect("final event");
        match last_event.payload {
            Some(v1::stream_response::Payload::Task(task)) => {
                assert_eq!(
                    v1::TaskState::try_from(task.status.as_ref().expect("status").state)
                        .expect("task state"),
                    v1::TaskState::Completed
                );
            }
            Some(v1::stream_response::Payload::StatusUpdate(update)) => {
                assert_eq!(
                    v1::TaskState::try_from(update.status.as_ref().expect("status").state)
                        .expect("task state"),
                    v1::TaskState::Completed
                );
            }
            other => panic!("unexpected final payload: {other:?}"),
        }

        server.abort();
        let _ = server.await;
    }
}

#[cfg(all(
    feature = "runtime",
    feature = "task-store-sqlite",
    not(all(target_os = "wasi", target_env = "p1"))
))]
mod sqlite_task_store_tests {
    use super::*;
    use a2a_types::{TaskState, TaskStatus};
    use radkit::runtime::task_manager::Task;
    use radkit::runtime::SqliteTaskStore;
    use std::path::Path;
    use uuid::Uuid;

    fn temp_db_path(test_name: &str) -> std::path::PathBuf {
        std::env::temp_dir().join(format!("radkit-{test_name}-{}.sqlite", Uuid::new_v4()))
    }

    fn cleanup_db_files(path: &Path) {
        let _ = std::fs::remove_file(path);
        let _ = std::fs::remove_file(format!("{}-wal", path.display()));
        let _ = std::fs::remove_file(format!("{}-shm", path.display()));
    }

    #[tokio::test]
    async fn test_sqlite_task_store_persists_across_runtime_rebuild() {
        let path = temp_db_path("runtime-sqlite-store");

        {
            let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
            let store = SqliteTaskStore::from_path(&path)
                .await
                .expect("sqlite store");
            let runtime = Runtime::builder(test_agent(), llm)
                .with_task_store(store)
                .build();

            let auth_context = runtime.auth().get_auth_context();
            let task = Task {
                id: "persisted-task".to_string(),
                context_id: "persisted-context".to_string(),
                status: TaskStatus {
                    state: TaskState::Working as i32,
                    timestamp: None,
                    message: None,
                },
                artifacts: vec![],
            };

            runtime
                .task_manager()
                .save_task(&auth_context, &task)
                .await
                .expect("save task");
        }

        {
            let llm = FakeLlm::with_responses("fake_llm", std::iter::empty());
            let store = SqliteTaskStore::from_path(&path)
                .await
                .expect("sqlite store");
            let runtime = Runtime::builder(test_agent(), llm)
                .with_task_store(store)
                .build();

            let auth_context = runtime.auth().get_auth_context();
            let task = runtime
                .task_manager()
                .get_task(&auth_context, "persisted-task")
                .await
                .expect("get task")
                .expect("task should exist");

            assert_eq!(task.context_id, "persisted-context");
        }

        cleanup_db_files(&path);
    }
}