mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
Rename plugin mention instruction plumbing
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
co-authored by
Codex
parent
88c2095fed
commit
d53e1aa6e7
+17
-17
@@ -258,10 +258,10 @@ use crate::mentions::collect_explicit_app_ids;
|
||||
use crate::mentions::collect_explicit_plugin_mentions;
|
||||
use crate::mentions::collect_tool_mentions_from_messages;
|
||||
use crate::network_policy_decision::execpolicy_network_rule_amendment;
|
||||
use crate::plugins::ExplicitPluginInstructionsContext;
|
||||
use crate::plugins::PluginMentionInstructionsContext;
|
||||
use crate::plugins::PluginsManager;
|
||||
use crate::plugins::build_explicit_plugin_instructions_context;
|
||||
use crate::plugins::build_plugin_developer_sections;
|
||||
use crate::plugins::build_plugin_mention_developer_sections;
|
||||
use crate::plugins::build_plugin_mention_instructions_context;
|
||||
use crate::plugins::render_plugins_section;
|
||||
use crate::project_doc::get_user_instructions;
|
||||
use crate::protocol::AgentMessageContentDeltaEvent;
|
||||
@@ -2572,14 +2572,14 @@ impl Session {
|
||||
.await
|
||||
}
|
||||
|
||||
/// `explicit_plugin_instructions` carries the already-resolved turn-local plugin mention
|
||||
/// `plugin_mention_instructions` carries the already-resolved turn-local plugin mention
|
||||
/// context from the current user input so this builder can render that guidance without
|
||||
/// re-listing MCP tools.
|
||||
async fn build_settings_update_items(
|
||||
&self,
|
||||
reference_context_item: Option<&TurnContextItem>,
|
||||
current_context: &TurnContext,
|
||||
explicit_plugin_instructions: &ExplicitPluginInstructionsContext,
|
||||
plugin_mention_instructions: &PluginMentionInstructionsContext,
|
||||
) -> Vec<ResponseItem> {
|
||||
// TODO: Make context updates a pure diff of persisted previous/current TurnContextItem
|
||||
// state so replay/backtracking is deterministic. Runtime inputs that affect model-visible
|
||||
@@ -2598,7 +2598,7 @@ impl Session {
|
||||
shell.as_ref(),
|
||||
exec_policy.as_ref(),
|
||||
self.features.enabled(Feature::Personality),
|
||||
explicit_plugin_instructions,
|
||||
plugin_mention_instructions,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3438,14 +3438,14 @@ impl Session {
|
||||
}
|
||||
}
|
||||
|
||||
/// `explicit_plugin_instructions` is optional because compaction/rebuild callers do not have
|
||||
/// `plugin_mention_instructions` is optional because compaction/rebuild callers do not have
|
||||
/// the raw current-turn user input needed to resolve explicit plugin mentions. When present,
|
||||
/// it carries the already-resolved plugin/tool/app context for turn-local plugin guidance in
|
||||
/// the canonical developer envelope.
|
||||
pub(crate) async fn build_initial_context(
|
||||
&self,
|
||||
turn_context: &TurnContext,
|
||||
explicit_plugin_instructions: Option<&ExplicitPluginInstructionsContext>,
|
||||
plugin_mention_instructions: Option<&PluginMentionInstructionsContext>,
|
||||
) -> Vec<ResponseItem> {
|
||||
let mut developer_sections = Vec::<String>::with_capacity(8);
|
||||
let mut contextual_user_sections = Vec::<String>::with_capacity(2);
|
||||
@@ -3566,9 +3566,9 @@ impl Session {
|
||||
{
|
||||
developer_sections.push(plugin_section);
|
||||
}
|
||||
if let Some(explicit_plugin_instructions) = explicit_plugin_instructions {
|
||||
developer_sections.extend(build_plugin_developer_sections(
|
||||
explicit_plugin_instructions,
|
||||
if let Some(plugin_mention_instructions) = plugin_mention_instructions {
|
||||
developer_sections.extend(build_plugin_mention_developer_sections(
|
||||
plugin_mention_instructions,
|
||||
));
|
||||
}
|
||||
if turn_context.features.enabled(Feature::CodexGitCommit)
|
||||
@@ -3659,27 +3659,27 @@ impl Session {
|
||||
/// reinjects full initial context into replacement history. Other non-regular tasks
|
||||
/// intentionally do not update the baseline.
|
||||
///
|
||||
/// `explicit_plugin_instructions` carries the current turn's already-resolved explicit
|
||||
/// `plugin_mention_instructions` carries the current turn's already-resolved explicit
|
||||
/// plugin-mention context so whichever canonical builder path runs can render that guidance
|
||||
/// exactly once without re-listing MCP tools.
|
||||
pub(crate) async fn record_context_updates_and_set_reference_context_item(
|
||||
&self,
|
||||
turn_context: &TurnContext,
|
||||
explicit_plugin_instructions: &ExplicitPluginInstructionsContext,
|
||||
plugin_mention_instructions: &PluginMentionInstructionsContext,
|
||||
) {
|
||||
let reference_context_item = {
|
||||
let state = self.state.lock().await;
|
||||
state.reference_context_item()
|
||||
};
|
||||
let context_items = if reference_context_item.is_none() {
|
||||
self.build_initial_context(turn_context, Some(explicit_plugin_instructions))
|
||||
self.build_initial_context(turn_context, Some(plugin_mention_instructions))
|
||||
.await
|
||||
} else {
|
||||
// Steady-state path: append only context diffs to minimize token overhead.
|
||||
self.build_settings_update_items(
|
||||
reference_context_item.as_ref(),
|
||||
turn_context,
|
||||
explicit_plugin_instructions,
|
||||
plugin_mention_instructions,
|
||||
)
|
||||
.await
|
||||
};
|
||||
@@ -5651,7 +5651,7 @@ pub(crate) async fn run_turn(
|
||||
.iter()
|
||||
.filter_map(crate::plugins::PluginCapabilitySummary::telemetry_metadata)
|
||||
.collect::<Vec<_>>();
|
||||
let explicit_plugin_instructions = build_explicit_plugin_instructions_context(
|
||||
let plugin_mention_instructions = build_plugin_mention_instructions_context(
|
||||
&mentioned_plugins,
|
||||
&mcp_tools,
|
||||
&available_connectors,
|
||||
@@ -5659,7 +5659,7 @@ pub(crate) async fn run_turn(
|
||||
|
||||
sess.record_context_updates_and_set_reference_context_item(
|
||||
turn_context.as_ref(),
|
||||
&explicit_plugin_instructions,
|
||||
&plugin_mention_instructions,
|
||||
)
|
||||
.await;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::exec::ExecToolCallOutput;
|
||||
use crate::function_tool::FunctionCallError;
|
||||
use crate::mcp_connection_manager::ToolInfo;
|
||||
use crate::models_manager::model_info;
|
||||
use crate::plugins::ExplicitPluginInstructionsContext;
|
||||
use crate::plugins::PluginMentionInstructionsContext;
|
||||
use crate::shell::default_user_shell;
|
||||
use crate::tools::format_exec_output_str;
|
||||
|
||||
@@ -960,12 +960,12 @@ async fn resumed_history_injects_initial_context_on_first_context_update_only()
|
||||
session
|
||||
.record_context_updates_and_set_reference_context_item(
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
expected.extend(
|
||||
session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await,
|
||||
);
|
||||
let history_after_seed = session.clone_history().await;
|
||||
@@ -974,7 +974,7 @@ async fn resumed_history_injects_initial_context_on_first_context_update_only()
|
||||
session
|
||||
.record_context_updates_and_set_reference_context_item(
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
let history_after_second_seed = session.clone_history().await;
|
||||
@@ -1350,7 +1350,7 @@ async fn thread_rollback_drops_last_turn_from_history() {
|
||||
let rollout_path = attach_rollout_recorder(&sess).await;
|
||||
|
||||
let initial_context = sess
|
||||
.build_initial_context(tc.as_ref(), /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(tc.as_ref(), /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let turn_1 = vec![
|
||||
user_message("turn 1 user"),
|
||||
@@ -1416,7 +1416,7 @@ async fn thread_rollback_clears_history_when_num_turns_exceeds_existing_turns()
|
||||
attach_rollout_recorder(&sess).await;
|
||||
|
||||
let initial_context = sess
|
||||
.build_initial_context(tc.as_ref(), /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(tc.as_ref(), /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let turn_1 = vec![user_message("turn 1 user")];
|
||||
let mut full_history = Vec::new();
|
||||
@@ -1444,7 +1444,7 @@ async fn thread_rollback_fails_without_persisted_rollout_path() {
|
||||
let (sess, tc, rx) = make_session_and_context_with_rx().await;
|
||||
|
||||
let initial_context = sess
|
||||
.build_initial_context(tc.as_ref(), /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(tc.as_ref(), /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
sess.record_into_history(&initial_context, tc.as_ref())
|
||||
.await;
|
||||
@@ -1763,7 +1763,7 @@ async fn thread_rollback_fails_when_turn_in_progress() {
|
||||
let (sess, tc, rx) = make_session_and_context_with_rx().await;
|
||||
|
||||
let initial_context = sess
|
||||
.build_initial_context(tc.as_ref(), /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(tc.as_ref(), /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
sess.record_into_history(&initial_context, tc.as_ref())
|
||||
.await;
|
||||
@@ -1786,7 +1786,7 @@ async fn thread_rollback_fails_when_num_turns_is_zero() {
|
||||
let (sess, tc, rx) = make_session_and_context_with_rx().await;
|
||||
|
||||
let initial_context = sess
|
||||
.build_initial_context(tc.as_ref(), /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(tc.as_ref(), /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
sess.record_into_history(&initial_context, tc.as_ref())
|
||||
.await;
|
||||
@@ -3723,7 +3723,7 @@ async fn build_settings_update_items_emits_environment_item_for_network_changes(
|
||||
.build_settings_update_items(
|
||||
Some(&reference_context_item),
|
||||
¤t_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -3762,7 +3762,7 @@ async fn build_settings_update_items_emits_environment_item_for_time_changes() {
|
||||
.build_settings_update_items(
|
||||
Some(&reference_context_item),
|
||||
¤t_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -3798,7 +3798,7 @@ async fn build_settings_update_items_emits_realtime_start_when_session_becomes_l
|
||||
.build_settings_update_items(
|
||||
Some(&previous_context.to_turn_context_item()),
|
||||
¤t_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -3827,7 +3827,7 @@ async fn build_settings_update_items_emits_realtime_end_when_session_stops_being
|
||||
.build_settings_update_items(
|
||||
Some(&previous_context.to_turn_context_item()),
|
||||
¤t_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -3864,7 +3864,7 @@ async fn build_settings_update_items_uses_previous_turn_settings_for_realtime_en
|
||||
.build_settings_update_items(
|
||||
Some(&previous_context_item),
|
||||
¤t_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -3883,7 +3883,7 @@ async fn build_initial_context_uses_previous_realtime_state() {
|
||||
turn_context.realtime_active = true;
|
||||
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let developer_texts = developer_input_texts(&initial_context);
|
||||
assert!(
|
||||
@@ -3899,7 +3899,7 @@ async fn build_initial_context_uses_previous_realtime_state() {
|
||||
state.set_reference_context_item(Some(previous_context_item));
|
||||
}
|
||||
let resumed_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let resumed_developer_texts = developer_input_texts(&resumed_context);
|
||||
assert!(
|
||||
@@ -3926,7 +3926,7 @@ async fn build_initial_context_omits_default_image_save_location_with_image_hist
|
||||
.await;
|
||||
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let developer_texts = developer_input_texts(&initial_context);
|
||||
assert!(
|
||||
@@ -3942,7 +3942,7 @@ async fn build_initial_context_omits_default_image_save_location_without_image_h
|
||||
let (session, turn_context) = make_session_and_context().await;
|
||||
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let developer_texts = developer_input_texts(&initial_context);
|
||||
|
||||
@@ -4057,7 +4057,7 @@ async fn build_initial_context_uses_previous_turn_settings_for_realtime_end() {
|
||||
.set_previous_turn_settings(Some(previous_turn_settings))
|
||||
.await;
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let developer_texts = developer_input_texts(&initial_context);
|
||||
assert!(
|
||||
@@ -4081,7 +4081,7 @@ async fn build_initial_context_restates_realtime_start_when_reference_context_is
|
||||
.set_previous_turn_settings(Some(previous_turn_settings))
|
||||
.await;
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let developer_texts = developer_input_texts(&initial_context);
|
||||
assert!(
|
||||
@@ -4099,12 +4099,12 @@ async fn record_context_updates_and_set_reference_context_item_injects_full_cont
|
||||
session
|
||||
.record_context_updates_and_set_reference_context_item(
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
let history = session.clone_history().await;
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
assert_eq!(history.raw_items().to_vec(), initial_context);
|
||||
|
||||
@@ -4135,7 +4135,7 @@ async fn record_context_updates_and_set_reference_context_item_reinjects_full_co
|
||||
session
|
||||
.record_context_updates_and_set_reference_context_item(
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
{
|
||||
@@ -4149,7 +4149,7 @@ async fn record_context_updates_and_set_reference_context_item_reinjects_full_co
|
||||
session
|
||||
.record_context_updates_and_set_reference_context_item(
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -4157,7 +4157,7 @@ async fn record_context_updates_and_set_reference_context_item_reinjects_full_co
|
||||
let mut expected_history = vec![compacted_summary];
|
||||
expected_history.extend(
|
||||
session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await,
|
||||
);
|
||||
assert_eq!(history.raw_items().to_vec(), expected_history);
|
||||
@@ -4206,7 +4206,7 @@ async fn record_context_updates_and_set_reference_context_item_persists_baseline
|
||||
.build_settings_update_items(
|
||||
Some(&previous_context_item),
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(update_items, Vec::new());
|
||||
@@ -4214,7 +4214,7 @@ async fn record_context_updates_and_set_reference_context_item_persists_baseline
|
||||
session
|
||||
.record_context_updates_and_set_reference_context_item(
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -4261,7 +4261,7 @@ async fn build_initial_context_prepends_model_switch_message() {
|
||||
.set_previous_turn_settings(Some(previous_turn_settings))
|
||||
.await;
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
|
||||
let ResponseItem::Message { role, content, .. } = &initial_context[0] else {
|
||||
@@ -4332,7 +4332,7 @@ async fn record_context_updates_and_set_reference_context_item_persists_full_rei
|
||||
session
|
||||
.record_context_updates_and_set_reference_context_item(
|
||||
&turn_context,
|
||||
&ExplicitPluginInstructionsContext::default(),
|
||||
&PluginMentionInstructionsContext::default(),
|
||||
)
|
||||
.await;
|
||||
session.ensure_rollout_materialized().await;
|
||||
@@ -4948,7 +4948,7 @@ async fn sample_rollout(
|
||||
let mut initial_context = session
|
||||
.build_initial_context(
|
||||
reconstruction_turn.as_ref(),
|
||||
/*explicit_plugin_instructions*/ None,
|
||||
/*plugin_mention_instructions*/ None,
|
||||
)
|
||||
.await;
|
||||
// Ensure personality_spec is present when Personality is enabled, so expected matches
|
||||
|
||||
@@ -203,7 +203,7 @@ async fn run_compact_task_inner(
|
||||
let initial_context = sess
|
||||
.build_initial_context(
|
||||
turn_context.as_ref(),
|
||||
/*explicit_plugin_instructions*/ None,
|
||||
/*plugin_mention_instructions*/ None,
|
||||
)
|
||||
.await;
|
||||
new_history =
|
||||
|
||||
@@ -178,7 +178,7 @@ pub(crate) async fn process_compacted_history(
|
||||
initial_context_injection,
|
||||
InitialContextInjection::BeforeLastUserMessage
|
||||
) {
|
||||
sess.build_initial_context(turn_context, /*explicit_plugin_instructions*/ None)
|
||||
sess.build_initial_context(turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await
|
||||
} else {
|
||||
Vec::new()
|
||||
|
||||
@@ -10,7 +10,7 @@ async fn process_compacted_history_with_test_session(
|
||||
.set_previous_turn_settings(previous_turn_settings.cloned())
|
||||
.await;
|
||||
let initial_context = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
let refreshed = crate::compact_remote::process_compacted_history(
|
||||
&session,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::codex::PreviousTurnSettings;
|
||||
use crate::codex::TurnContext;
|
||||
use crate::environment_context::EnvironmentContext;
|
||||
use crate::plugins::ExplicitPluginInstructionsContext;
|
||||
use crate::plugins::build_plugin_developer_sections;
|
||||
use crate::plugins::PluginMentionInstructionsContext;
|
||||
use crate::plugins::build_plugin_mention_developer_sections;
|
||||
use crate::shell::Shell;
|
||||
use codex_execpolicy::Policy;
|
||||
use codex_features::Feature;
|
||||
@@ -194,7 +194,7 @@ pub(crate) fn build_settings_update_items(
|
||||
shell: &Shell,
|
||||
exec_policy: &Policy,
|
||||
personality_feature_enabled: bool,
|
||||
explicit_plugin_instructions: &ExplicitPluginInstructionsContext,
|
||||
plugin_mention_instructions: &PluginMentionInstructionsContext,
|
||||
) -> Vec<ResponseItem> {
|
||||
// TODO(ccunningham): build_settings_update_items still does not cover every
|
||||
// model-visible item emitted by build_initial_context. Persist the remaining
|
||||
@@ -213,8 +213,8 @@ pub(crate) fn build_settings_update_items(
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(DeveloperInstructions::into_text)
|
||||
.chain(build_plugin_developer_sections(
|
||||
explicit_plugin_instructions,
|
||||
.chain(build_plugin_mention_developer_sections(
|
||||
plugin_mention_instructions,
|
||||
))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
||||
@@ -5,17 +5,17 @@ use crate::connectors;
|
||||
use crate::mcp::CODEX_APPS_MCP_SERVER_NAME;
|
||||
use crate::mcp_connection_manager::ToolInfo;
|
||||
use crate::plugins::PluginCapabilitySummary;
|
||||
use crate::plugins::render_explicit_plugin_instructions;
|
||||
use crate::plugins::render_plugin_mention_instructions;
|
||||
|
||||
/// Turn-local data needed to render explicit plugin-mention guidance inside the
|
||||
/// canonical pre-user developer envelope.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub(crate) struct ExplicitPluginInstructionsContext {
|
||||
entries: Vec<ExplicitPluginInstructionsEntry>,
|
||||
pub(crate) struct PluginMentionInstructionsContext {
|
||||
entries: Vec<PluginMentionInstructionsEntry>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
struct ExplicitPluginInstructionsEntry {
|
||||
struct PluginMentionInstructionsEntry {
|
||||
plugin: PluginCapabilitySummary,
|
||||
available_mcp_servers: Vec<String>,
|
||||
available_apps: Vec<String>,
|
||||
@@ -23,13 +23,13 @@ struct ExplicitPluginInstructionsEntry {
|
||||
|
||||
/// Capture the turn-local plugin/tool/app ingredients needed to render explicit plugin guidance
|
||||
/// later in the canonical context builders, without re-listing MCP tools.
|
||||
pub(crate) fn build_explicit_plugin_instructions_context(
|
||||
pub(crate) fn build_plugin_mention_instructions_context(
|
||||
mentioned_plugins: &[PluginCapabilitySummary],
|
||||
mcp_tools: &HashMap<String, ToolInfo>,
|
||||
available_connectors: &[connectors::AppInfo],
|
||||
) -> ExplicitPluginInstructionsContext {
|
||||
) -> PluginMentionInstructionsContext {
|
||||
if mentioned_plugins.is_empty() {
|
||||
return ExplicitPluginInstructionsContext::default();
|
||||
return PluginMentionInstructionsContext::default();
|
||||
}
|
||||
|
||||
let entries = mentioned_plugins
|
||||
@@ -62,7 +62,7 @@ pub(crate) fn build_explicit_plugin_instructions_context(
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
ExplicitPluginInstructionsEntry {
|
||||
PluginMentionInstructionsEntry {
|
||||
plugin: plugin.clone(),
|
||||
available_mcp_servers,
|
||||
available_apps,
|
||||
@@ -70,23 +70,23 @@ pub(crate) fn build_explicit_plugin_instructions_context(
|
||||
})
|
||||
.collect();
|
||||
|
||||
ExplicitPluginInstructionsContext { entries }
|
||||
PluginMentionInstructionsContext { entries }
|
||||
}
|
||||
|
||||
/// Render explicit plugin-mention guidance from the already-resolved per-turn plugin context.
|
||||
/// Render plugin-mention guidance from the already-resolved per-turn plugin context.
|
||||
///
|
||||
/// The live turn path builds `ExplicitPluginInstructionsContext` once from the current turn's
|
||||
/// The live turn path builds `PluginMentionInstructionsContext` once from the current turn's
|
||||
/// plugin/tool/app inventory, then whichever canonical context builder runs uses this renderer.
|
||||
pub(crate) fn build_plugin_developer_sections(
|
||||
explicit_plugin_instructions: &ExplicitPluginInstructionsContext,
|
||||
pub(crate) fn build_plugin_mention_developer_sections(
|
||||
plugin_mention_instructions: &PluginMentionInstructionsContext,
|
||||
) -> Vec<String> {
|
||||
// Turn each explicit plugin mention into developer-message sections that
|
||||
// can be folded into the canonical pre-user developer envelope for this turn.
|
||||
explicit_plugin_instructions
|
||||
plugin_mention_instructions
|
||||
.entries
|
||||
.iter()
|
||||
.filter_map(|entry| {
|
||||
render_explicit_plugin_instructions(
|
||||
render_plugin_mention_instructions(
|
||||
&entry.plugin,
|
||||
&entry.available_mcp_servers,
|
||||
&entry.available_apps,
|
||||
|
||||
@@ -12,9 +12,9 @@ pub(crate) mod test_support;
|
||||
mod toggles;
|
||||
|
||||
pub(crate) use discoverable::list_tool_suggest_discoverable_plugins;
|
||||
pub(crate) use injection::ExplicitPluginInstructionsContext;
|
||||
pub(crate) use injection::build_explicit_plugin_instructions_context;
|
||||
pub(crate) use injection::build_plugin_developer_sections;
|
||||
pub(crate) use injection::PluginMentionInstructionsContext;
|
||||
pub(crate) use injection::build_plugin_mention_developer_sections;
|
||||
pub(crate) use injection::build_plugin_mention_instructions_context;
|
||||
pub use manager::AppConnectorId;
|
||||
pub use manager::ConfiguredMarketplace;
|
||||
pub use manager::ConfiguredMarketplaceListOutcome;
|
||||
@@ -50,7 +50,7 @@ pub use marketplace::MarketplacePluginPolicy;
|
||||
pub use marketplace::MarketplacePluginSource;
|
||||
pub use remote::RemotePluginFetchError;
|
||||
pub use remote::fetch_remote_featured_plugin_ids;
|
||||
pub(crate) use render::render_explicit_plugin_instructions;
|
||||
pub(crate) use render::render_plugin_mention_instructions;
|
||||
pub(crate) use render::render_plugins_section;
|
||||
pub(crate) use startup_sync::curated_plugins_repo_path;
|
||||
pub(crate) use startup_sync::read_curated_plugins_sha;
|
||||
|
||||
@@ -41,7 +41,7 @@ pub(crate) fn render_plugins_section(plugins: &[PluginCapabilitySummary]) -> Opt
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn render_explicit_plugin_instructions(
|
||||
pub(crate) fn render_plugin_mention_instructions(
|
||||
plugin: &PluginCapabilitySummary,
|
||||
available_mcp_servers: &[String],
|
||||
available_apps: &[String],
|
||||
|
||||
@@ -23,8 +23,8 @@ fn render_plugins_section_includes_descriptions_and_skill_naming_guidance() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_explicit_plugin_instructions_wraps_turn_local_guidance_in_stable_tag() {
|
||||
let rendered = render_explicit_plugin_instructions(
|
||||
fn render_plugin_mention_instructions_wraps_turn_local_guidance_in_stable_tag() {
|
||||
let rendered = render_plugin_mention_instructions(
|
||||
&PluginCapabilitySummary {
|
||||
config_name: "sample@test".to_string(),
|
||||
display_name: "sample".to_string(),
|
||||
|
||||
@@ -196,7 +196,7 @@ fn out_of_range_truncation_drops_pre_user_active_turn_prefix() {
|
||||
async fn ignores_session_prefix_messages_when_truncating() {
|
||||
let (session, turn_context) = make_session_and_context().await;
|
||||
let mut items = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
items.push(user_msg("feature request"));
|
||||
items.push(assistant_msg("ack"));
|
||||
|
||||
@@ -125,7 +125,7 @@ fn truncates_rollout_from_start_applies_thread_rollback_markers() {
|
||||
async fn ignores_session_prefix_messages_when_truncating_rollout_from_start() {
|
||||
let (session, turn_context) = make_session_and_context().await;
|
||||
let mut items = session
|
||||
.build_initial_context(&turn_context, /*explicit_plugin_instructions*/ None)
|
||||
.build_initial_context(&turn_context, /*plugin_mention_instructions*/ None)
|
||||
.await;
|
||||
items.push(user_msg("feature request"));
|
||||
items.push(assistant_msg("ack"));
|
||||
|
||||
Reference in New Issue
Block a user