mirror of
https://github.com/openai/codex.git
synced 2026-11-03 08:22:30 +00:00
Make context contributors async (#22491)
## Summary - make ContextContributor return a boxed Send future - await context contributors during initial context assembly - update existing contributors and extension-api examples for the async contract ## Testing - cargo test -p codex-extension-api --examples - cargo test -p codex-git-attribution - cargo test -p codex-core build_initial_context_includes_git_attribution_from_extensions -- --nocapture - cargo test -p codex-core build_initial_context_omits_git_attribution_when_feature_is_disabled -- --nocapture - cargo test -p codex-core (fails in unrelated agent::control::tests::spawn_agent_fork_last_n_turns_keeps_only_recent_turns stack overflow) - just fix -p codex-extension-api - just fix -p codex-git-attribution - just fix -p codex-core - cargo clippy -p codex-extension-api --examples
This commit is contained in:
1 parent
1dcc89f1d4
commit
68e045a631
6 files changed
+114
-69
No files matched your search
@@ -2694,11 +2694,15 @@ impl Session {
|
||||
{
|
||||
developer_sections.push(plugin_instructions.render());
|
||||
}
|
||||
for contributor in self.services.extensions.context_contributors() {
|
||||
for fragment in contributor.contribute(
|
||||
&self.services.session_extension_data,
|
||||
&self.services.thread_extension_data,
|
||||
) {
|
||||
let context_contributors = self.services.extensions.context_contributors().to_vec();
|
||||
for contributor in context_contributors {
|
||||
for fragment in contributor
|
||||
.contribute(
|
||||
&self.services.session_extension_data,
|
||||
&self.services.thread_extension_data,
|
||||
)
|
||||
.await
|
||||
{
|
||||
match fragment.slot() {
|
||||
PromptSlot::DeveloperPolicy | PromptSlot::DeveloperCapabilities => {
|
||||
developer_sections.push(fragment.text().to_string());
|
||||
|
||||
@@ -6352,21 +6352,25 @@ struct GitAttributionTestContributor;
|
||||
struct GitAttributionTestState;
|
||||
|
||||
impl codex_extension_api::ContextContributor for GitAttributionTestContributor {
|
||||
fn contribute(
|
||||
&self,
|
||||
_session_store: &codex_extension_api::ExtensionData,
|
||||
thread_store: &codex_extension_api::ExtensionData,
|
||||
) -> Vec<codex_extension_api::PromptFragment> {
|
||||
thread_store
|
||||
.get::<GitAttributionTestState>()
|
||||
.is_some()
|
||||
.then(|| {
|
||||
codex_extension_api::PromptFragment::developer_policy(
|
||||
"git attribution extension enabled",
|
||||
)
|
||||
})
|
||||
.into_iter()
|
||||
.collect()
|
||||
fn contribute<'a>(
|
||||
&'a self,
|
||||
_session_store: &'a codex_extension_api::ExtensionData,
|
||||
thread_store: &'a codex_extension_api::ExtensionData,
|
||||
) -> std::pin::Pin<
|
||||
Box<dyn std::future::Future<Output = Vec<codex_extension_api::PromptFragment>> + Send + 'a>,
|
||||
> {
|
||||
Box::pin(async move {
|
||||
thread_store
|
||||
.get::<GitAttributionTestState>()
|
||||
.is_some()
|
||||
.then(|| {
|
||||
codex_extension_api::PromptFragment::developer_policy(
|
||||
"git attribution extension enabled",
|
||||
)
|
||||
})
|
||||
.into_iter()
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user