talos_agent/prompt/types.rs
1use talos_core::message::{SystemCacheMarker, SystemCacheType};
2use talos_core::tool::ToolFamily;
3
4/// A description of a tool for inclusion in the system prompt.
5///
6/// Contains only the name and human-readable description, without the full
7/// JSON Schema parameters. This is sufficient for the system prompt context.
8#[derive(Debug, Clone, PartialEq, Default)]
9pub struct ToolDescription {
10 pub name: String,
11 pub description: String,
12 pub parameters: serde_json::Value,
13 pub family: ToolFamily,
14}
15
16/// A context file for inclusion in the system prompt.
17///
18/// Typically loaded from `AGENTS.md` files in the workspace hierarchy.
19#[derive(Debug, Clone, PartialEq)]
20pub struct ContextFile {
21 /// Relative or absolute path to the source file.
22 pub path: String,
23 /// Full content of the file.
24 pub content: String,
25}
26
27/// Activated Skill content included in the model-visible stable prompt prefix.
28#[derive(Debug, Clone, PartialEq, Eq)]
29pub struct ActivatedSkillContext {
30 /// Skill name selected by the user.
31 pub name: String,
32 /// Bounded Skill body and any explicitly loaded references.
33 pub content: String,
34}
35
36/// Type of cache control marker for prompt sections.
37///
38/// Used to indicate which sections of the system prompt are stable across
39/// turns and suitable for provider-side caching.
40#[derive(Debug, Clone, PartialEq)]
41pub enum CacheType {
42 /// The section is stable and suitable for ephemeral caching.
43 /// Content in this range should be cached by the provider and reused
44 /// across turns when the section remains unchanged.
45 Ephemeral,
46}
47
48/// A cache marker indicating a byte range suitable for provider caching.
49///
50/// Each marker specifies the offset and length of a cacheable section within
51/// the assembled prompt, along with the cache type.
52#[derive(Debug, Clone, PartialEq)]
53pub struct CacheMarker {
54 /// Starting byte offset of the cacheable section.
55 pub offset: usize,
56 /// Length of the cacheable section in bytes.
57 pub length: usize,
58 /// Type of caching to apply to this section.
59 pub cache_type: CacheType,
60}
61
62impl From<CacheMarker> for SystemCacheMarker {
63 fn from(marker: CacheMarker) -> Self {
64 let cache_type = match marker.cache_type {
65 CacheType::Ephemeral => SystemCacheType::Ephemeral,
66 };
67 Self {
68 offset: marker.offset,
69 length: marker.length,
70 cache_type,
71 }
72 }
73}