Skip to content

feat(prompts): harvest static composer override#2819

Merged
Hmbown merged 1 commit into
codex/v0.9.0-stewardshipfrom
codex/v090-static-prompt-composer-harvest
Jun 6, 2026
Merged

feat(prompts): harvest static composer override#2819
Hmbown merged 1 commit into
codex/v0.9.0-stewardshipfrom
codex/v090-static-prompt-composer-harvest

Conversation

@Hmbown
Copy link
Copy Markdown
Owner

@Hmbown Hmbown commented Jun 6, 2026

Summary

  • harvest and narrow the static prompt composer hook proposed by @h3c-hexin in feat(prompts): add static prompt composer override for embedders #2786
  • expose StaticPromptCtx with model, personality, shell availability, and reusable default base/personality layers
  • keep mode metadata, approval policy, tool taxonomy, Context Management, and the Compaction Relay under CodeWhale runtime prompt assembly
  • update v0.9 contributor credit and changelog notes for the harvested direction

Verification

  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/release/check-versions.sh
  • cmp -s CHANGELOG.md crates/tui/CHANGELOG.md
  • cargo test -p codewhale-tui prompts::tests:: -- --nocapture
  • cargo test -p codewhale-tui --locked --bin codewhale-tui runtime_prompt -- --nocapture
  • cargo check -p codewhale-tui --all-features --locked

Refs #2786.

Co-authored-by: h3c-hexin 13790929+h3c-hexin@users.noreply.github.com

Refine the embedder static prompt composer direction from #2786 so it only owns the byte-stable base/personality prompt segment while runtime metadata, Context Management, and the compaction relay stay under CodeWhale prompt assembly.

Co-authored-by: h3c-hexin <13790929+h3c-hexin@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@Hmbown Hmbown marked this pull request as ready for review June 6, 2026 03:27
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@Hmbown Hmbown merged commit d868a0b into codex/v0.9.0-stewardship Jun 6, 2026
2 checks passed
@Hmbown Hmbown deleted the codex/v090-static-prompt-composer-harvest branch June 6, 2026 03:27
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a static prompt composer override mechanism (StaticPromptComposer) that allows embedders to replace the base/personality prompt segment while preserving CodeWhale's runtime prompt assembly. Feedback on the changes includes a compilation fix for mapping the OnceLock value of the composer using a closure instead of Box::as_ref directly, as well as an optimization to pass default_layers by value to avoid unnecessary string allocations when no custom composer is configured.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/tui/src/prompts.rs
Comment on lines +411 to +413
fn effective_static_prompt_composer() -> Option<&'static StaticPromptComposer> {
STATIC_PROMPT_COMPOSER.get().map(Box::as_ref)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using Box::as_ref directly as a function pointer will fail to compile because Box does not have an inherent as_ref method. Instead, use a closure or AsRef::as_ref to map the OnceLock value.

Suggested change
fn effective_static_prompt_composer() -> Option<&'static StaticPromptComposer> {
STATIC_PROMPT_COMPOSER.get().map(Box::as_ref)
}
fn effective_static_prompt_composer() -> Option<&'static StaticPromptComposer> {
STATIC_PROMPT_COMPOSER.get().map(|b| b.as_ref())
}

Comment thread crates/tui/src/prompts.rs
Comment on lines +870 to +886
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(),
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To avoid an unnecessary String allocation/clone when composer is None (which is the default/common path), we can pass default_layers by value (String) to apply_static_prompt_composer instead of borrowing it as &str.

Suggested change
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(),
}
}
fn apply_static_prompt_composer(
composer: Option<&StaticPromptComposer>,
personality: Personality,
model_id: &str,
shell_tools_available: bool,
default_layers: String,
) -> String {
match composer {
Some(composer) => composer(&StaticPromptCtx {
model_id,
personality,
shell_tools_available,
default_layers: &default_layers,
}),
None => default_layers,
}
}

Comment thread crates/tui/src/prompts.rs
Comment on lines +835 to +843
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,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pass default_layers by value to avoid cloning it when no custom composer is set.

Suggested change
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,
)
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 thread crates/tui/src/prompts.rs
Comment on lines +1334 to +1340
let composed = apply_static_prompt_composer(
None,
personality,
"deepseek-v4-flash",
shell_tools_available,
&default_layers,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Clone default_layers here since it is used in the subsequent assertion.

Suggested change
let composed = apply_static_prompt_composer(
None,
personality,
"deepseek-v4-flash",
shell_tools_available,
&default_layers,
);
let composed = apply_static_prompt_composer(
None,
personality,
"deepseek-v4-flash",
shell_tools_available,
default_layers.clone(),
);

Comment thread crates/tui/src/prompts.rs
Comment on lines +1362 to +1368
let composed = apply_static_prompt_composer(
Some(composer.as_ref()),
Personality::Calm,
"deepseek-v4-pro",
false,
&default_layers,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pass default_layers by value as it is not used after this call.

Suggested change
let composed = apply_static_prompt_composer(
Some(composer.as_ref()),
Personality::Calm,
"deepseek-v4-pro",
false,
&default_layers,
);
let composed = apply_static_prompt_composer(
Some(composer.as_ref()),
Personality::Calm,
"deepseek-v4-pro",
false,
default_layers,
);

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant