-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(prompts): harvest static composer override #2819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -299,6 +299,31 @@ static LOCALE_CLOSER_JA_OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceL | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static LOCALE_CLOSER_PT_BR_OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static LOCALE_CLOSER_VI_OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static AUTHORITY_RECAP_OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static STATIC_PROMPT_COMPOSER: std::sync::OnceLock<Box<StaticPromptComposer>> = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::sync::OnceLock::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Context passed to an embedder-provided static prompt composer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// This hook only replaces the byte-stable base/personality prompt segment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Mode deltas, approval policy, tool taxonomy, Context Management, and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Compaction Relay stay owned by CodeWhale's runtime prompt assembly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[non_exhaustive] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub struct StaticPromptCtx<'a> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Active model identifier after caller-side routing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub model_id: &'a str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Personality overlay requested for the base static prompt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub personality: Personality, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Whether shell tools are present in the runtime tool catalog. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub shell_tools_available: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Default base/personality prompt layers that would be used without an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// override. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub default_layers: &'a str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Embedder hook for replacing CodeWhale's byte-stable base/personality prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// segment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub type StaticPromptComposer = dyn Fn(&StaticPromptCtx<'_>) -> String + Send + Sync + 'static; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Replace `BASE_PROMPT` for all subsequent prompt composition. First call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// wins; later calls return the rejected string. Set before spawning any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -352,10 +377,26 @@ pub fn set_authority_recap_override(s: String) -> Result<(), String> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set_prompt_override(&AUTHORITY_RECAP_OVERRIDE, s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Replace the byte-stable base/personality prompt segment for subsequent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// prompt composition. First call wins; later calls return the rejected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// composer so embedders can preserve ownership. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub fn set_static_prompt_composer_override( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f: Box<StaticPromptComposer>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> Result<(), Box<StaticPromptComposer>> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set_static_prompt_composer(&STATIC_PROMPT_COMPOSER, f) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn set_prompt_override(cell: &std::sync::OnceLock<String>, s: String) -> Result<(), String> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cell.set(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn set_static_prompt_composer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cell: &std::sync::OnceLock<Box<StaticPromptComposer>>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f: Box<StaticPromptComposer>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> Result<(), Box<StaticPromptComposer>> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cell.set(f) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn effective_prompt_override<'a>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cell: &'a std::sync::OnceLock<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fallback: &'static str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -367,6 +408,10 @@ fn effective_base_prompt() -> &'static str { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| effective_prompt_override(&BASE_PROMPT_OVERRIDE, BASE_PROMPT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn effective_static_prompt_composer() -> Option<&'static StaticPromptComposer> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STATIC_PROMPT_COMPOSER.get().map(Box::as_ref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn effective_locale_preamble_zh_hans() -> &'static str { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| effective_prompt_override(&LOCALE_PREAMBLE_ZH_HANS_OVERRIDE, LOCALE_PREAMBLE_ZH_HANS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -787,6 +832,22 @@ fn compose_prompt_with_approval_model_and_shell( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| allow_shell: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> String { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let shell_tools_available = allow_shell && mode != AppMode::Plan; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let default_layers = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compose_default_static_layers(personality, model_id, shell_tools_available); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| apply_static_prompt_composer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| effective_static_prompt_composer(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| personality, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell_tools_available, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| &default_layers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+835
to
+843
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn compose_default_static_layers( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| personality: Personality, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_id: &str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell_tools_available: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> String { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let base_prompt = render_base_prompt_for_tool_availability( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| effective_base_prompt().trim(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -806,6 +867,24 @@ fn compose_prompt_with_approval_model_and_shell( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn apply_static_prompt_composer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| composer: Option<&StaticPromptComposer>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| personality: Personality, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_id: &str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell_tools_available: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default_layers: &str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> String { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| match composer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Some(composer) => composer(&StaticPromptCtx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| personality, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell_tools_available, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default_layers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| None => default_layers.to_string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+870
to
+886
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid an unnecessary
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn render_base_prompt_for_tool_availability( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prompt: &str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_id: &str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1217,6 +1296,80 @@ mod tests { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(effective_prompt_override(&cell, "fallback"), "first"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn static_prompt_composer_storage_returns_rejected_composer() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let cell = std::sync::OnceLock::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let first: Box<StaticPromptComposer> = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Box::new(|ctx| format!("first:{}", ctx.default_layers.len())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let second: Box<StaticPromptComposer> = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Box::new(|ctx| format!("second:{}", ctx.default_layers.len())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(set_static_prompt_composer(&cell, first).is_ok()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let rejected = set_static_prompt_composer(&cell, second) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .err() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .expect("second composer should be rejected"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let ctx = StaticPromptCtx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_id: "deepseek-v4-pro", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| personality: Personality::Calm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell_tools_available: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default_layers: "fallback", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(rejected(&ctx), "second:8"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cell.get().expect("first composer retained")(&ctx), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "first:8" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn static_prompt_composer_unset_keeps_default_layers_byte_identical() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for personality in [Personality::Calm, Personality::Playful] { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for shell_tools_available in [true, false] { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let default_layers = compose_default_static_layers( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| personality, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "deepseek-v4-flash", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell_tools_available, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let composed = apply_static_prompt_composer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| personality, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "deepseek-v4-flash", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell_tools_available, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| &default_layers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1334
to
+1340
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clone
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_byte_identical("unset static prompt composer", &default_layers, &composed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn static_prompt_composer_receives_context_and_replaces_layers() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let default_layers = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compose_default_static_layers(Personality::Calm, "deepseek-v4-pro", false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let composer: Box<StaticPromptComposer> = Box::new(|ctx| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(ctx.model_id, "deepseek-v4-pro"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(ctx.personality, Personality::Calm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!ctx.shell_tools_available); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(ctx.default_layers.contains("You are deepseek-v4-pro")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(ctx.default_layers.contains("Personality: Calm")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!ctx.default_layers.contains("## Core Tool Taxonomy")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!ctx.default_layers.contains("Approval Policy")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "embedder static prompt".to_string() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let composed = apply_static_prompt_composer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Some(composer.as_ref()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Personality::Calm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "deepseek-v4-pro", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| &default_layers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1362
to
+1368
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(composed, "embedder static prompt"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn contains_cjk(text: &str) -> bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text.chars().any(|ch| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matches!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
Box::as_refdirectly as a function pointer will fail to compile becauseBoxdoes not have an inherentas_refmethod. Instead, use a closure orAsRef::as_refto map theOnceLockvalue.