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
299 changes: 0 additions & 299 deletions backend/scripts/experiment_agent_build_arms.py

This file was deleted.

1 change: 0 additions & 1 deletion backend/src/agents/main_agent/chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def _create_agent(self) -> None:
hooks=hooks,
plugins=plugins,
memory_context=getattr(self, "memory_context", None),
session_id=getattr(self, "session_id", None),
)

except Exception as e:
Expand Down
11 changes: 3 additions & 8 deletions backend/src/agents/main_agent/core/agent_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@ class AgentFactory:
"""Factory for creating configured Strands Agent instances with multi-provider support"""

@staticmethod
def _create_bedrock_model(model_config: ModelConfig, session_id: Optional[str] = None) -> BedrockModel:
def _create_bedrock_model(model_config: ModelConfig) -> BedrockModel:
"""
Create a BedrockModel instance

Args:
model_config: Model configuration
session_id: The conversation, which decides the agent-build A/B
arm (see ``ModelConfig.to_bedrock_config``).

Returns:
BedrockModel: Configured Bedrock model (a ``CountTokensBedrockModel``
so native CountTokens works for inference-profile model ids).
"""
bedrock_config = model_config.to_bedrock_config(session_id=session_id)
bedrock_config = model_config.to_bedrock_config()
# Strands awaits count_tokens before every model call; keep that local.
# Native counts are taken off the critical path by the
# context-attribution hook (native_count_tokens in a background task).
Expand Down Expand Up @@ -192,7 +190,6 @@ def create_agent(
hooks: Optional[List[Any]] = None,
plugins: Optional[List[Any]] = None,
memory_context: Optional[str] = None,
session_id: Optional[str] = None,
) -> Agent:
"""
Create a Strands Agent instance with the appropriate model provider
Expand All @@ -209,8 +206,6 @@ def create_agent(
memory_context: Optional rendered Memory-Space block. Sent after
the system prompt, behind a cache point of its own when the
model supports cache points (see below).
session_id: The conversation this agent serves. Only the Bedrock
provider reads it, to pick the agent-build A/B arm.

Returns:
Agent: Configured Strands Agent instance
Expand All @@ -224,7 +219,7 @@ def create_agent(

# Create appropriate model based on provider
if provider == ModelProvider.BEDROCK:
model = AgentFactory._create_bedrock_model(model_config, session_id=session_id)
model = AgentFactory._create_bedrock_model(model_config)
elif provider == ModelProvider.OPENAI:
model = AgentFactory._create_openai_model(model_config)
elif provider == ModelProvider.MANTLE:
Expand Down
11 changes: 5 additions & 6 deletions backend/src/agents/main_agent/core/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,25 +414,24 @@ def bedrock_cache_points_supported(self) -> bool:
and ("claude" in model_lower or "anthropic" in model_lower)
)

def to_bedrock_config(self, session_id: Optional[str] = None) -> Dict[str, Any]:
def to_bedrock_config(self) -> Dict[str, Any]:
"""Convert to BedrockModel kwargs, translating canonical inference params.

``session_id`` decides the agent-build A/B arm
(``memory_shared_clients_enabled``): on the shared arm the model is
With ``agent_build_shared_session_enabled`` (default on) the model is
built on the process-wide boto3 session instead of the fresh
``boto3.Session()`` Strands would otherwise construct (and re-parse
the bedrock-runtime model on). Nothing here reaches the prompt.
"""
config: Dict[str, Any] = {"model_id": self.model_id}

from apis.shared.feature_flags import memory_shared_clients_enabled
from apis.shared.feature_flags import agent_build_shared_session_enabled

if memory_shared_clients_enabled(session_id):
if agent_build_shared_session_enabled():
from apis.shared.aws_clients import shared_boto_session

# Never alongside `region_name`: BedrockModel.__init__ raises when
# both are given (strands-agents 1.55.0). This config sets no
# region on either arm; the session resolves it from the
# region either way; the session resolves it from the
# environment exactly as Strands' own fresh session would.
config["boto_session"] = shared_boto_session()
_apply_canonical_params(
Expand Down
Loading