Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4264,6 +4264,11 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet
)
.await?;
let session_id = session.session_id.clone();
// Sync context window from AI config so subagents with large-context
// models are not prematurely capped at SessionConfig::default()'s 128128.
self.session_manager
.refresh_session_context_window(&session_id)
.await?;
if let Some(source_session_id) = prompt_cache_source_session_id.as_deref() {
let copied = self
.session_manager
Expand Down
27 changes: 27 additions & 0 deletions src/crates/assembly/core/src/agentic/session/session_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,33 @@ impl SessionManager {
Ok(())
}

/// Sync session context window from AI config without requiring an explicit model_id.
///
/// Subagent sessions created via `build_session_config_for_workspace` use
/// `SessionConfig::default()` which hardcodes `max_context_tokens: 128128`.
/// This method reloads the AI config and updates `max_context_tokens` to the
/// model's actual configured `context_window`, so subagents with large-context
/// models are not prematurely capped.
pub async fn refresh_session_context_window(
&self,
session_id: &str,
) -> BitFunResult<()> {
if let Some(ai_config) = Self::load_ai_config_for_model_resolution().await {
if let Some(mut session) = self.sessions.get_mut(session_id) {
let previous = session.config.max_context_tokens;
Self::sync_session_context_window_from_ai_config(&mut session, &ai_config);
let updated = session.config.max_context_tokens;
if updated != previous {
debug!(
"Refreshed session context window: session_id={}, previous={}, updated={}",
session_id, previous, updated
);
}
}
}
Ok(())
}

/// Update session activity time
pub fn touch_session(&self, session_id: &str) {
if let Some(mut session) = self.sessions.get_mut(session_id) {
Expand Down
Loading