fast-agent-mcp 0.1.13__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/METADATA +3 -4
  2. fast_agent_mcp-0.2.0.dist-info/RECORD +123 -0
  3. mcp_agent/__init__.py +75 -0
  4. mcp_agent/agents/agent.py +59 -371
  5. mcp_agent/agents/base_agent.py +522 -0
  6. mcp_agent/agents/workflow/__init__.py +1 -0
  7. mcp_agent/agents/workflow/chain_agent.py +173 -0
  8. mcp_agent/agents/workflow/evaluator_optimizer.py +362 -0
  9. mcp_agent/agents/workflow/orchestrator_agent.py +591 -0
  10. mcp_agent/{workflows/orchestrator → agents/workflow}/orchestrator_models.py +27 -11
  11. mcp_agent/agents/workflow/parallel_agent.py +182 -0
  12. mcp_agent/agents/workflow/router_agent.py +307 -0
  13. mcp_agent/app.py +3 -1
  14. mcp_agent/cli/commands/bootstrap.py +18 -7
  15. mcp_agent/cli/commands/setup.py +12 -4
  16. mcp_agent/cli/main.py +1 -1
  17. mcp_agent/cli/terminal.py +1 -1
  18. mcp_agent/config.py +24 -35
  19. mcp_agent/context.py +3 -1
  20. mcp_agent/context_dependent.py +3 -1
  21. mcp_agent/core/agent_types.py +10 -7
  22. mcp_agent/core/direct_agent_app.py +179 -0
  23. mcp_agent/core/direct_decorators.py +443 -0
  24. mcp_agent/core/direct_factory.py +476 -0
  25. mcp_agent/core/enhanced_prompt.py +15 -20
  26. mcp_agent/core/fastagent.py +151 -337
  27. mcp_agent/core/interactive_prompt.py +424 -0
  28. mcp_agent/core/mcp_content.py +19 -11
  29. mcp_agent/core/prompt.py +6 -2
  30. mcp_agent/core/validation.py +89 -16
  31. mcp_agent/executor/decorator_registry.py +6 -2
  32. mcp_agent/executor/temporal.py +35 -11
  33. mcp_agent/executor/workflow_signal.py +8 -2
  34. mcp_agent/human_input/handler.py +3 -1
  35. mcp_agent/llm/__init__.py +2 -0
  36. mcp_agent/{workflows/llm → llm}/augmented_llm.py +131 -256
  37. mcp_agent/{workflows/llm → llm}/augmented_llm_passthrough.py +35 -107
  38. mcp_agent/llm/augmented_llm_playback.py +83 -0
  39. mcp_agent/{workflows/llm → llm}/model_factory.py +26 -8
  40. mcp_agent/llm/providers/__init__.py +8 -0
  41. mcp_agent/{workflows/llm → llm/providers}/anthropic_utils.py +5 -1
  42. mcp_agent/{workflows/llm → llm/providers}/augmented_llm_anthropic.py +37 -141
  43. mcp_agent/llm/providers/augmented_llm_deepseek.py +53 -0
  44. mcp_agent/{workflows/llm → llm/providers}/augmented_llm_openai.py +112 -148
  45. mcp_agent/{workflows/llm → llm}/providers/multipart_converter_anthropic.py +78 -35
  46. mcp_agent/{workflows/llm → llm}/providers/multipart_converter_openai.py +73 -44
  47. mcp_agent/{workflows/llm → llm}/providers/openai_multipart.py +18 -4
  48. mcp_agent/{workflows/llm → llm/providers}/openai_utils.py +3 -3
  49. mcp_agent/{workflows/llm → llm}/providers/sampling_converter_anthropic.py +3 -3
  50. mcp_agent/{workflows/llm → llm}/providers/sampling_converter_openai.py +3 -3
  51. mcp_agent/{workflows/llm → llm}/sampling_converter.py +0 -21
  52. mcp_agent/{workflows/llm → llm}/sampling_format_converter.py +16 -1
  53. mcp_agent/logging/logger.py +2 -2
  54. mcp_agent/mcp/gen_client.py +9 -3
  55. mcp_agent/mcp/interfaces.py +67 -45
  56. mcp_agent/mcp/logger_textio.py +97 -0
  57. mcp_agent/mcp/mcp_agent_client_session.py +12 -4
  58. mcp_agent/mcp/mcp_agent_server.py +3 -1
  59. mcp_agent/mcp/mcp_aggregator.py +124 -93
  60. mcp_agent/mcp/mcp_connection_manager.py +21 -7
  61. mcp_agent/mcp/prompt_message_multipart.py +59 -1
  62. mcp_agent/mcp/prompt_render.py +77 -0
  63. mcp_agent/mcp/prompt_serialization.py +20 -13
  64. mcp_agent/mcp/prompts/prompt_constants.py +18 -0
  65. mcp_agent/mcp/prompts/prompt_helpers.py +327 -0
  66. mcp_agent/mcp/prompts/prompt_load.py +15 -5
  67. mcp_agent/mcp/prompts/prompt_server.py +154 -87
  68. mcp_agent/mcp/prompts/prompt_template.py +26 -35
  69. mcp_agent/mcp/resource_utils.py +3 -1
  70. mcp_agent/mcp/sampling.py +24 -15
  71. mcp_agent/mcp_server/agent_server.py +8 -5
  72. mcp_agent/mcp_server_registry.py +22 -9
  73. mcp_agent/resources/examples/{workflows → in_dev}/agent_build.py +1 -1
  74. mcp_agent/resources/examples/{data-analysis → in_dev}/slides.py +1 -1
  75. mcp_agent/resources/examples/internal/agent.py +4 -2
  76. mcp_agent/resources/examples/internal/fastagent.config.yaml +8 -2
  77. mcp_agent/resources/examples/prompting/image_server.py +3 -1
  78. mcp_agent/resources/examples/prompting/work_with_image.py +19 -0
  79. mcp_agent/ui/console_display.py +27 -7
  80. fast_agent_mcp-0.1.13.dist-info/RECORD +0 -164
  81. mcp_agent/core/agent_app.py +0 -570
  82. mcp_agent/core/agent_utils.py +0 -69
  83. mcp_agent/core/decorators.py +0 -448
  84. mcp_agent/core/factory.py +0 -422
  85. mcp_agent/core/proxies.py +0 -278
  86. mcp_agent/core/types.py +0 -22
  87. mcp_agent/eval/__init__.py +0 -0
  88. mcp_agent/mcp/stdio.py +0 -114
  89. mcp_agent/resources/examples/data-analysis/analysis-campaign.py +0 -188
  90. mcp_agent/resources/examples/data-analysis/analysis.py +0 -65
  91. mcp_agent/resources/examples/data-analysis/fastagent.config.yaml +0 -41
  92. mcp_agent/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +0 -1471
  93. mcp_agent/resources/examples/mcp_researcher/researcher-eval.py +0 -53
  94. mcp_agent/resources/examples/researcher/fastagent.config.yaml +0 -66
  95. mcp_agent/resources/examples/researcher/researcher-eval.py +0 -53
  96. mcp_agent/resources/examples/researcher/researcher-imp.py +0 -189
  97. mcp_agent/resources/examples/researcher/researcher.py +0 -39
  98. mcp_agent/resources/examples/workflows/chaining.py +0 -45
  99. mcp_agent/resources/examples/workflows/evaluator.py +0 -79
  100. mcp_agent/resources/examples/workflows/fastagent.config.yaml +0 -24
  101. mcp_agent/resources/examples/workflows/human_input.py +0 -26
  102. mcp_agent/resources/examples/workflows/orchestrator.py +0 -74
  103. mcp_agent/resources/examples/workflows/parallel.py +0 -79
  104. mcp_agent/resources/examples/workflows/router.py +0 -54
  105. mcp_agent/resources/examples/workflows/sse.py +0 -23
  106. mcp_agent/telemetry/__init__.py +0 -0
  107. mcp_agent/telemetry/usage_tracking.py +0 -19
  108. mcp_agent/workflows/__init__.py +0 -0
  109. mcp_agent/workflows/embedding/__init__.py +0 -0
  110. mcp_agent/workflows/embedding/embedding_base.py +0 -58
  111. mcp_agent/workflows/embedding/embedding_cohere.py +0 -49
  112. mcp_agent/workflows/embedding/embedding_openai.py +0 -37
  113. mcp_agent/workflows/evaluator_optimizer/__init__.py +0 -0
  114. mcp_agent/workflows/evaluator_optimizer/evaluator_optimizer.py +0 -447
  115. mcp_agent/workflows/intent_classifier/__init__.py +0 -0
  116. mcp_agent/workflows/intent_classifier/intent_classifier_base.py +0 -117
  117. mcp_agent/workflows/intent_classifier/intent_classifier_embedding.py +0 -130
  118. mcp_agent/workflows/intent_classifier/intent_classifier_embedding_cohere.py +0 -41
  119. mcp_agent/workflows/intent_classifier/intent_classifier_embedding_openai.py +0 -41
  120. mcp_agent/workflows/intent_classifier/intent_classifier_llm.py +0 -150
  121. mcp_agent/workflows/intent_classifier/intent_classifier_llm_anthropic.py +0 -60
  122. mcp_agent/workflows/intent_classifier/intent_classifier_llm_openai.py +0 -58
  123. mcp_agent/workflows/llm/__init__.py +0 -0
  124. mcp_agent/workflows/llm/augmented_llm_playback.py +0 -111
  125. mcp_agent/workflows/llm/providers/__init__.py +0 -8
  126. mcp_agent/workflows/orchestrator/__init__.py +0 -0
  127. mcp_agent/workflows/orchestrator/orchestrator.py +0 -535
  128. mcp_agent/workflows/parallel/__init__.py +0 -0
  129. mcp_agent/workflows/parallel/fan_in.py +0 -320
  130. mcp_agent/workflows/parallel/fan_out.py +0 -181
  131. mcp_agent/workflows/parallel/parallel_llm.py +0 -149
  132. mcp_agent/workflows/router/__init__.py +0 -0
  133. mcp_agent/workflows/router/router_base.py +0 -338
  134. mcp_agent/workflows/router/router_embedding.py +0 -226
  135. mcp_agent/workflows/router/router_embedding_cohere.py +0 -59
  136. mcp_agent/workflows/router/router_embedding_openai.py +0 -59
  137. mcp_agent/workflows/router/router_llm.py +0 -304
  138. mcp_agent/workflows/swarm/__init__.py +0 -0
  139. mcp_agent/workflows/swarm/swarm.py +0 -292
  140. mcp_agent/workflows/swarm/swarm_anthropic.py +0 -42
  141. mcp_agent/workflows/swarm/swarm_openai.py +0 -41
  142. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/WHEEL +0 -0
  143. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/entry_points.txt +0 -0
  144. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/licenses/LICENSE +0 -0
  145. /mcp_agent/{workflows/orchestrator → agents/workflow}/orchestrator_prompts.py +0 -0
  146. /mcp_agent/{workflows/llm → llm}/memory.py +0 -0
  147. /mcp_agent/{workflows/llm → llm}/prompt_utils.py +0 -0
mcp_agent/config.py CHANGED
@@ -100,31 +100,36 @@ class MCPSettings(BaseModel):
100
100
 
101
101
  class AnthropicSettings(BaseModel):
102
102
  """
103
- Settings for using Anthropic models in the MCP Agent application.
103
+ Settings for using Anthropic models in the fast-agent application.
104
104
  """
105
105
 
106
106
  api_key: str | None = None
107
107
 
108
+ base_url: str | None = None
109
+
108
110
  model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
109
111
 
110
112
 
111
- class CohereSettings(BaseModel):
113
+ class OpenAISettings(BaseModel):
112
114
  """
113
- Settings for using Cohere models in the MCP Agent application.
115
+ Settings for using OpenAI models in the fast-agent application.
114
116
  """
115
117
 
116
118
  api_key: str | None = None
119
+ reasoning_effort: Literal["low", "medium", "high"] = "medium"
120
+
121
+ base_url: str | None = None
117
122
 
118
123
  model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
119
124
 
120
125
 
121
- class OpenAISettings(BaseModel):
126
+ class DeepSeekSettings(BaseModel):
122
127
  """
123
- Settings for using OpenAI models in the MCP Agent application.
128
+ Settings for using OpenAI models in the fast-agent application.
124
129
  """
125
130
 
126
131
  api_key: str | None = None
127
- reasoning_effort: Literal["low", "medium", "high"] = "medium"
132
+ # reasoning_effort: Literal["low", "medium", "high"] = "medium"
128
133
 
129
134
  base_url: str | None = None
130
135
 
@@ -133,7 +138,7 @@ class OpenAISettings(BaseModel):
133
138
 
134
139
  class TemporalSettings(BaseModel):
135
140
  """
136
- Temporal settings for the MCP Agent application.
141
+ Temporal settings for the fast-agent application.
137
142
  """
138
143
 
139
144
  host: str
@@ -142,27 +147,14 @@ class TemporalSettings(BaseModel):
142
147
  api_key: str | None = None
143
148
 
144
149
 
145
- class UsageTelemetrySettings(BaseModel):
146
- """
147
- Settings for usage telemetry in the MCP Agent application.
148
- Anonymized usage metrics are sent to a telemetry server to help improve the product.
149
- """
150
-
151
- enabled: bool = True
152
- """Enable usage telemetry in the MCP Agent application."""
153
-
154
- enable_detailed_telemetry: bool = False
155
- """If enabled, detailed telemetry data, including prompts and agents, will be sent to the telemetry server."""
156
-
157
-
158
150
  class OpenTelemetrySettings(BaseModel):
159
151
  """
160
- OTEL settings for the MCP Agent application.
152
+ OTEL settings for the fast-agent application.
161
153
  """
162
154
 
163
155
  enabled: bool = True
164
156
 
165
- service_name: str = "mcp-agent"
157
+ service_name: str = "fast-agent"
166
158
  service_instance_id: str | None = None
167
159
  service_version: str | None = None
168
160
 
@@ -178,7 +170,7 @@ class OpenTelemetrySettings(BaseModel):
178
170
 
179
171
  class LoggerSettings(BaseModel):
180
172
  """
181
- Logger settings for the MCP Agent application.
173
+ Logger settings for the fast-agent application.
182
174
  """
183
175
 
184
176
  type: Literal["none", "console", "file", "http"] = "file"
@@ -221,7 +213,7 @@ class LoggerSettings(BaseModel):
221
213
 
222
214
  class Settings(BaseSettings):
223
215
  """
224
- Settings class for the MCP Agent application.
216
+ Settings class for the fast-agent application.
225
217
  """
226
218
 
227
219
  model_config = SettingsConfigDict(
@@ -236,7 +228,7 @@ class Settings(BaseSettings):
236
228
  """MCP config, such as MCP servers"""
237
229
 
238
230
  execution_engine: Literal["asyncio", "temporal"] = "asyncio"
239
- """Execution engine for the MCP Agent application"""
231
+ """Execution engine for the fast-agent application"""
240
232
 
241
233
  default_model: str | None = "haiku"
242
234
  """
@@ -247,22 +239,19 @@ class Settings(BaseSettings):
247
239
  """Settings for Temporal workflow orchestration"""
248
240
 
249
241
  anthropic: AnthropicSettings | None = None
250
- """Settings for using Anthropic models in the MCP Agent application"""
242
+ """Settings for using Anthropic models in the fast-agent application"""
251
243
 
252
- cohere: CohereSettings | None = None
253
- """Settings for using Cohere models in the MCP Agent application"""
244
+ otel: OpenTelemetrySettings | None = OpenTelemetrySettings()
245
+ """OpenTelemetry logging settings for the fast-agent application"""
254
246
 
255
247
  openai: OpenAISettings | None = None
256
- """Settings for using OpenAI models in the MCP Agent application"""
248
+ """Settings for using OpenAI models in the fast-agent application"""
257
249
 
258
- otel: OpenTelemetrySettings | None = OpenTelemetrySettings()
259
- """OpenTelemetry logging settings for the MCP Agent application"""
250
+ deepseek: DeepSeekSettings | None = None
251
+ """Settings for using DeepSeek models in the fast-agent application"""
260
252
 
261
253
  logger: LoggerSettings | None = LoggerSettings()
262
- """Logger settings for the MCP Agent application"""
263
-
264
- usage_telemetry: UsageTelemetrySettings | None = UsageTelemetrySettings()
265
- """Usage tracking settings for the MCP Agent application"""
254
+ """Logger settings for the fast-agent application"""
266
255
 
267
256
  @classmethod
268
257
  def find_config(cls) -> Path | None:
mcp_agent/context.py CHANGED
@@ -156,7 +156,9 @@ async def configure_executor(config: "Settings"):
156
156
  return executor
157
157
 
158
158
 
159
- async def initialize_context(config: Optional[Union["Settings", str]] = None, store_globally: bool = False):
159
+ async def initialize_context(
160
+ config: Optional[Union["Settings", str]] = None, store_globally: bool = False
161
+ ):
160
162
  """
161
163
  Initialize the global application context.
162
164
  """
@@ -31,7 +31,9 @@ class ContextDependent:
31
31
 
32
32
  return get_current_context()
33
33
  except Exception as e:
34
- raise RuntimeError(f"No context available for {self.__class__.__name__}. Either initialize MCPApp first or pass context explicitly.") from e
34
+ raise RuntimeError(
35
+ f"No context available for {self.__class__.__name__}. Either initialize MCPApp first or pass context explicitly."
36
+ ) from e
35
37
 
36
38
  @contextmanager
37
39
  def use_context(self, context: "Context"):
@@ -2,9 +2,10 @@
2
2
  Type definitions for agents and agent configurations.
3
3
  """
4
4
 
5
+ import dataclasses
5
6
  from dataclasses import dataclass
6
7
  from enum import Enum
7
- from typing import Callable, Dict, List, Optional, Union
8
+ from typing import List
8
9
 
9
10
  # Forward imports to avoid circular dependencies
10
11
  from mcp_agent.core.request_params import RequestParams
@@ -26,18 +27,20 @@ class AgentConfig:
26
27
  """Configuration for an Agent instance"""
27
28
 
28
29
  name: str
29
- instruction: Union[str, Callable[[Dict], str]]
30
- servers: List[str]
31
- model: Optional[str] = None
30
+ instruction: str = "You are a helpful agent."
31
+ servers: List[str] = dataclasses.field(default_factory=list)
32
+ model: str | None = None
32
33
  use_history: bool = True
33
- default_request_params: Optional[RequestParams] = None
34
+ default_request_params: RequestParams | None = None
34
35
  human_input: bool = False
35
36
 
36
- def __post_init__(self):
37
+ def __post_init__(self) -> None:
37
38
  """Ensure default_request_params exists with proper history setting"""
38
39
 
39
40
  if self.default_request_params is None:
40
- self.default_request_params = RequestParams(use_history=self.use_history)
41
+ self.default_request_params = RequestParams(
42
+ use_history=self.use_history, systemPrompt=self.instruction
43
+ )
41
44
  else:
42
45
  # Override the request params history setting if explicitly configured
43
46
  self.default_request_params.use_history = self.use_history
@@ -0,0 +1,179 @@
1
+ """
2
+ Direct AgentApp implementation for interacting with agents without proxies.
3
+ """
4
+
5
+ from typing import Dict, Optional, Union
6
+
7
+ from mcp_agent.agents.agent import Agent
8
+ from mcp_agent.core.interactive_prompt import InteractivePrompt
9
+ from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
10
+
11
+
12
+ class DirectAgentApp:
13
+ """
14
+ Container for active agents that provides a simple API for interacting with them.
15
+ This implementation works directly with Agent instances without proxies.
16
+
17
+ The DirectAgentApp provides both attribute-style access (app.agent_name)
18
+ and dictionary-style access (app["agent_name"]) to agents.
19
+
20
+ It also implements the AgentProtocol interface, automatically forwarding
21
+ calls to the default agent (the first agent in the container).
22
+ """
23
+
24
+ def __init__(self, agents: Dict[str, Agent]) -> None:
25
+ """
26
+ Initialize the DirectAgentApp.
27
+
28
+ Args:
29
+ agents: Dictionary of agent instances keyed by name
30
+ """
31
+ self._agents = agents
32
+
33
+ def __getitem__(self, key: str) -> Agent:
34
+ """Allow access to agents using dictionary syntax."""
35
+ if key not in self._agents:
36
+ raise KeyError(f"Agent '{key}' not found")
37
+ return self._agents[key]
38
+
39
+ def __getattr__(self, name: str) -> Agent:
40
+ """Allow access to agents using attribute syntax."""
41
+ if name in self._agents:
42
+ return self._agents[name]
43
+ raise AttributeError(f"Agent '{name}' not found")
44
+
45
+ async def __call__(
46
+ self,
47
+ message: Union[str, PromptMessageMultipart] | None = None,
48
+ agent_name: str | None = None,
49
+ default_prompt: str = "",
50
+ ) -> str:
51
+ """
52
+ Make the object callable to send messages or start interactive prompt.
53
+ This mirrors the FastAgent implementation that allowed agent("message").
54
+
55
+ Args:
56
+ message: The message to send
57
+ agent_name: Optional name of the agent to send to (defaults to first agent)
58
+ default: Default message to use in interactive prompt mode
59
+
60
+ Returns:
61
+ The agent's response as a string or the result of the interactive session
62
+ """
63
+ if message:
64
+ return await self._agent(agent_name).send(message)
65
+
66
+ return await self._agent(agent_name).prompt(default_prompt=default_prompt)
67
+
68
+ async def send(self, message: str, agent_name: Optional[str] = None) -> str:
69
+ """
70
+ Send a message to the specified agent (or to all agents).
71
+
72
+ Args:
73
+ message: The message to send
74
+ agent_name: Optional name of the agent to send to
75
+
76
+ Returns:
77
+ The agent's response as a string
78
+ """
79
+ return await self._agent(agent_name).send(message)
80
+
81
+ def _agent(self, agent_name: str | None) -> Agent:
82
+ if agent_name:
83
+ if agent_name not in self._agents:
84
+ raise ValueError(f"Agent '{agent_name}' not found")
85
+ return self._agents[agent_name]
86
+
87
+ return next(iter(self._agents.values()))
88
+
89
+ async def apply_prompt(
90
+ self,
91
+ prompt_name: str,
92
+ arguments: Dict[str, str] | None = None,
93
+ agent_name: str | None = None,
94
+ ) -> str:
95
+ """
96
+ Apply a prompt template to an agent (default agent if not specified).
97
+
98
+ Args:
99
+ prompt_name: Name of the prompt template to apply
100
+ agent_name: Name of the agent to send to
101
+ arguments: Optional arguments for the prompt template
102
+
103
+ Returns:
104
+ The agent's response as a string
105
+ """
106
+ return await self._agent(agent_name).apply_prompt(prompt_name, arguments)
107
+
108
+ async def list_prompts(self, agent_name: str | None = None):
109
+ """
110
+ List available prompts for an agent.
111
+
112
+ Args:
113
+ agent_name: Name of the agent to list prompts for
114
+
115
+ Returns:
116
+ Dictionary mapping server names to lists of available prompts
117
+ """
118
+ return await self._agent(agent_name).list_prompts()
119
+
120
+ async def with_resource(self, user_prompt: str, server_name: str, resource_name: str) -> str:
121
+ return await self._agent(None).with_resource(
122
+ prompt_content=user_prompt, server_name=server_name, resource_name=resource_name
123
+ )
124
+
125
+ async def prompt(self, agent_name: Optional[str] = None, default_prompt: str = "") -> str:
126
+ """
127
+ Interactive prompt for sending messages with advanced features.
128
+
129
+ Args:
130
+ agent_name: Optional target agent name (uses default if not specified)
131
+ default: Default message to use when user presses enter
132
+
133
+ Returns:
134
+ The result of the interactive session
135
+ """
136
+
137
+ # Get the default agent name if none specified
138
+ if agent_name:
139
+ # Validate that this agent exists
140
+ if agent_name not in self._agents:
141
+ raise ValueError(f"Agent '{agent_name}' not found")
142
+ target_name = agent_name
143
+ else:
144
+ # Use the first agent's name as default
145
+ target_name = next(iter(self._agents.keys()))
146
+
147
+ # Don't delegate to the agent's own prompt method - use our implementation
148
+ # The agent's prompt method doesn't fully support switching between agents
149
+
150
+ # Create agent_types dictionary mapping agent names to their types
151
+ agent_types = {}
152
+ for name, agent in self._agents.items():
153
+ # Determine agent type if possible
154
+ agent_type = "Agent" # Default type
155
+
156
+ # Try to get the type from the agent directly
157
+ if hasattr(agent, "agent_type"):
158
+ agent_type = agent.agent_type
159
+ elif hasattr(agent, "config") and hasattr(agent.config, "agent_type"):
160
+ agent_type = agent.config.agent_type
161
+
162
+ agent_types[name] = agent_type
163
+
164
+ # Create the interactive prompt
165
+ prompt = InteractivePrompt(agent_types=agent_types)
166
+
167
+ # Define the wrapper for send function
168
+ async def send_wrapper(message, agent_name):
169
+ return await self.send(message, agent_name)
170
+
171
+ # Start the prompt loop with the agent name (not the agent object)
172
+ return await prompt.prompt_loop(
173
+ send_func=send_wrapper,
174
+ default_agent=target_name, # Pass the agent name, not the agent object
175
+ available_agents=list(self._agents.keys()),
176
+ apply_prompt_func=self.apply_prompt,
177
+ list_prompts_func=self.list_prompts,
178
+ default=default_prompt,
179
+ )