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
@@ -1,448 +0,0 @@
1
- """
2
- Decorators for FastAgent applications.
3
- Contains decorator definitions extracted from fastagent.py.
4
- """
5
-
6
- from typing import Callable, Dict, List, Literal, Optional, TypeVar
7
-
8
- from mcp_agent.core.agent_types import AgentConfig, AgentType
9
- from mcp_agent.workflows.llm.augmented_llm import RequestParams
10
-
11
- T = TypeVar("T") # For the wrapper classes
12
-
13
-
14
- def _create_decorator(
15
- self,
16
- agent_type: AgentType,
17
- default_name: str = None,
18
- default_instruction: str = None,
19
- default_servers: List[str] = None,
20
- default_use_history: bool = True,
21
- wrapper_needed: bool = False,
22
- **extra_defaults,
23
- ) -> Callable:
24
- """
25
- Factory method for creating agent decorators with common behavior.
26
-
27
- Args:
28
- agent_type: Type of agent/workflow to create
29
- default_name: Default name to use if not provided
30
- default_instruction: Default instruction to use if not provided
31
- default_servers: Default servers list to use if not provided
32
- default_use_history: Default history setting
33
- wrapper_needed: Whether to wrap the decorated function
34
- **extra_defaults: Additional agent/workflow-specific parameters
35
- """
36
-
37
- def decorator_wrapper(**kwargs):
38
- # Apply defaults for common parameters
39
- name = kwargs.get("name", default_name or f"{agent_type.name.title()}")
40
- instruction = kwargs.get("instruction", default_instruction or "")
41
- servers = kwargs.get("servers", default_servers or [])
42
- model = kwargs.get("model", None)
43
- use_history = kwargs.get("use_history", default_use_history)
44
- request_params = kwargs.get("request_params", None)
45
- human_input = kwargs.get("human_input", False)
46
-
47
- # Create base request params
48
- def decorator(func: Callable) -> Callable:
49
- # Create base request params
50
- if request_params is not None or model is not None or use_history != default_use_history:
51
- max_tokens = 4096 if agent_type == AgentType.BASIC else None
52
- params_dict = {"use_history": use_history, "model": model}
53
- if max_tokens:
54
- params_dict["maxTokens"] = max_tokens
55
- if request_params:
56
- params_dict.update(request_params)
57
- base_params = RequestParams(**params_dict)
58
- else:
59
- base_params = RequestParams(use_history=use_history)
60
-
61
- # Create agent configuration
62
- config = AgentConfig(
63
- name=name,
64
- instruction=instruction,
65
- servers=servers,
66
- model=model,
67
- use_history=use_history,
68
- default_request_params=base_params,
69
- human_input=human_input,
70
- )
71
-
72
- # Build agent/workflow specific data
73
- agent_data = {
74
- "config": config,
75
- "type": agent_type.value,
76
- "func": func,
77
- }
78
-
79
- # Add extra parameters specific to this agent type
80
- for key, value in kwargs.items():
81
- if key not in [
82
- "name",
83
- "instruction",
84
- "servers",
85
- "model",
86
- "use_history",
87
- "request_params",
88
- "human_input",
89
- ]:
90
- agent_data[key] = value
91
-
92
- # Store the configuration under the agent name
93
- self.agents[name] = agent_data
94
-
95
- # Either wrap or return the original function
96
- if wrapper_needed:
97
-
98
- async def wrapper(*args, **kwargs):
99
- return await func(*args, **kwargs)
100
-
101
- return wrapper
102
- return func
103
-
104
- return decorator
105
-
106
- return decorator_wrapper
107
-
108
-
109
- def agent(
110
- self,
111
- name: str = "Agent",
112
- instruction_or_kwarg: str = None,
113
- *,
114
- instruction: str = "You are a helpful agent.",
115
- servers: List[str] = [],
116
- model: str | None = None,
117
- use_history: bool = True,
118
- request_params: Optional[Dict] = None,
119
- human_input: bool = False,
120
- ) -> Callable:
121
- """
122
- Decorator to create and register an agent with configuration.
123
-
124
- Args:
125
- name: Name of the agent
126
- instruction_or_kwarg: Optional positional parameter for instruction
127
- instruction: Base instruction for the agent (keyword arg)
128
- servers: List of server names the agent should connect to
129
- model: Model specification string (highest precedence)
130
- use_history: Whether to maintain conversation history
131
- request_params: Additional request parameters for the LLM
132
- human_input: Whether to enable human input capabilities
133
-
134
- The instruction can be provided either as a second positional argument
135
- or as a keyword argument. Positional argument takes precedence when both are provided.
136
-
137
- Usage:
138
- @fast.agent("agent_name", "Your instruction here") # Using positional arg
139
- @fast.agent("agent_name", instruction="Your instruction here") # Using keyword arg
140
- """
141
- # Use positional argument if provided, otherwise use keyword argument
142
- final_instruction = instruction_or_kwarg if instruction_or_kwarg is not None else instruction
143
-
144
- decorator = self._create_decorator(
145
- AgentType.BASIC,
146
- default_name="Agent",
147
- default_instruction="You are a helpful agent.",
148
- default_use_history=True,
149
- )(
150
- name=name,
151
- instruction=final_instruction,
152
- servers=servers,
153
- model=model,
154
- use_history=use_history,
155
- request_params=request_params,
156
- human_input=human_input,
157
- )
158
- return decorator
159
-
160
-
161
- def orchestrator(
162
- self,
163
- name: str = "Orchestrator",
164
- *,
165
- instruction: str | None = None,
166
- agents: List[str],
167
- model: str | None = None,
168
- use_history: bool = False,
169
- request_params: Optional[Dict] = None,
170
- human_input: bool = False,
171
- plan_type: Literal["full", "iterative"] = "full",
172
- max_iterations: int = 30, # Add the max_iterations parameter with default value
173
- ) -> Callable:
174
- """
175
- Decorator to create and register an orchestrator.
176
-
177
- Args:
178
- name: Name of the orchestrator
179
- instruction: Base instruction for the orchestrator
180
- agents: List of agent names this orchestrator can use
181
- model: Model specification string (highest precedence)
182
- use_history: Whether to maintain conversation history (forced false)
183
- request_params: Additional request parameters for the LLM
184
- human_input: Whether to enable human input capabilities
185
- plan_type: Planning approach - "full" generates entire plan first, "iterative" plans one step at a time
186
- max_iterations: Maximum number of planning iterations (default: 10)
187
- """
188
- default_instruction = """
189
- You are an expert planner. Given an objective task and a list of MCP servers (which are collections of tools)
190
- or Agents (which are collections of servers), your job is to break down the objective into a series of steps,
191
- which can be performed by LLMs with access to the servers or agents.
192
- """
193
-
194
- # Handle request_params update with max_iterations
195
- if request_params is None:
196
- request_params = {"max_iterations": max_iterations}
197
- elif isinstance(request_params, dict):
198
- if "max_iterations" not in request_params:
199
- request_params["max_iterations"] = max_iterations
200
-
201
- decorator = self._create_decorator(
202
- AgentType.ORCHESTRATOR,
203
- default_name="Orchestrator",
204
- default_instruction=default_instruction,
205
- default_servers=[],
206
- default_use_history=False,
207
- )(
208
- name=name,
209
- instruction=instruction,
210
- child_agents=agents,
211
- model=model,
212
- use_history=use_history,
213
- request_params=request_params,
214
- human_input=human_input,
215
- plan_type=plan_type,
216
- )
217
- return decorator
218
-
219
-
220
- def parallel(
221
- self,
222
- name: str,
223
- fan_out: List[str],
224
- fan_in: Optional[str] = None,
225
- instruction: str = "",
226
- model: str | None = None,
227
- use_history: bool = True,
228
- request_params: Optional[Dict] = None,
229
- include_request: bool = True,
230
- ) -> Callable:
231
- """
232
- Decorator to create and register a parallel executing agent.
233
-
234
- Args:
235
- name: Name of the parallel executing agent
236
- fan_out: List of parallel execution agents
237
- fan_in: Optional name of collecting agent. If not provided, a passthrough agent
238
- will be created automatically with the name "{name}_fan_in"
239
- instruction: Optional instruction for the parallel agent
240
- model: Model specification string
241
- use_history: Whether to maintain conversation history
242
- request_params: Additional request parameters for the LLM
243
- include_request: Whether to include the original request in the fan-in message
244
- """
245
- # If fan_in is not provided, create a passthrough agent with a derived name
246
- if fan_in is None:
247
- passthrough_name = f"{name}_fan_in"
248
-
249
- # Register the passthrough agent directly in self.agents
250
- self.agents[passthrough_name] = {
251
- "config": AgentConfig(
252
- name=passthrough_name,
253
- model="passthrough",
254
- instruction=f"This agent combines the results from the fan-out agents verbatim. {name}",
255
- servers=[],
256
- use_history=use_history,
257
- ),
258
- "type": AgentType.BASIC.value, # Using BASIC type since we're just attaching a PassthroughLLM
259
- "func": lambda x: x, # Simple passthrough function (never actually called)
260
- }
261
-
262
- # Use this passthrough as the fan-in
263
- fan_in = passthrough_name
264
-
265
- decorator = self._create_decorator(
266
- AgentType.PARALLEL,
267
- default_instruction="",
268
- default_servers=[],
269
- default_use_history=True,
270
- )(
271
- name=name,
272
- fan_in=fan_in,
273
- fan_out=fan_out,
274
- instruction=instruction,
275
- model=model,
276
- use_history=use_history,
277
- request_params=request_params,
278
- include_request=include_request,
279
- )
280
- return decorator
281
-
282
-
283
- def evaluator_optimizer(
284
- self,
285
- name: str,
286
- generator: str,
287
- evaluator: str,
288
- min_rating: str = "GOOD",
289
- max_refinements: int = 3,
290
- use_history: bool = True,
291
- request_params: Optional[Dict] = None,
292
- instruction: Optional[str] = None,
293
- ) -> Callable:
294
- """
295
- Decorator to create and register an evaluator-optimizer workflow.
296
-
297
- Args:
298
- name: Name of the workflow
299
- generator: Name of the generator agent
300
- evaluator: Name of the evaluator agent
301
- min_rating: Minimum acceptable quality rating (EXCELLENT, GOOD, FAIR, POOR)
302
- max_refinements: Maximum number of refinement iterations
303
- use_history: Whether to maintain conversation history
304
- request_params: Additional request parameters for the LLM
305
- instruction: Optional instruction for the workflow (if not provided, uses generator's instruction)
306
- """
307
- decorator = self._create_decorator(
308
- AgentType.EVALUATOR_OPTIMIZER,
309
- default_instruction="", # We'll get instruction from generator or override
310
- default_servers=[],
311
- default_use_history=True,
312
- wrapper_needed=True,
313
- )(
314
- name=name,
315
- generator=generator,
316
- evaluator=evaluator,
317
- min_rating=min_rating,
318
- max_refinements=max_refinements,
319
- use_history=use_history,
320
- request_params=request_params,
321
- instruction=instruction, # Pass through any custom instruction
322
- )
323
- return decorator
324
-
325
-
326
- def router(
327
- self,
328
- name: str,
329
- agents: List[str],
330
- # servers: List[str] = [],
331
- model: Optional[str] = None,
332
- use_history: bool = True,
333
- request_params: Optional[Dict] = None,
334
- human_input: bool = False,
335
- ) -> Callable:
336
- """
337
- Decorator to create and register a router.
338
-
339
- Args:
340
- name: Name of the router
341
- agents: List of agent names this router can delegate to
342
- servers: List of server names the router can use directly (currently not supported)
343
- model: Model specification string
344
- use_history: Whether to maintain conversation history
345
- request_params: Additional request parameters for the LLM
346
- human_input: Whether to enable human input capabilities
347
- """
348
- decorator = self._create_decorator(
349
- AgentType.ROUTER,
350
- default_instruction="",
351
- default_servers=[],
352
- default_use_history=False,
353
- wrapper_needed=True,
354
- )(
355
- name=name,
356
- agents=agents,
357
- model=model,
358
- use_history=use_history,
359
- request_params=request_params,
360
- human_input=human_input,
361
- )
362
- return decorator
363
-
364
-
365
- def chain(
366
- self,
367
- name: str = "Chain",
368
- *,
369
- sequence: List[str] = None,
370
- agents: List[str] = None, # Alias for sequence
371
- instruction: str = None,
372
- model: str | None = None,
373
- use_history: bool = True,
374
- request_params: Optional[Dict] = None,
375
- continue_with_final: bool = True,
376
- cumulative: bool = False,
377
- ) -> Callable:
378
- """
379
- Decorator to create and register a chain of agents.
380
-
381
- Args:
382
- name: Name of the chain
383
- sequence: List of agent names in order of execution (preferred name)
384
- agents: Alias for sequence (backwards compatibility)
385
- instruction: Optional custom instruction for the chain (if none provided, will autogenerate based on sequence)
386
- model: Model specification string (not used directly in chain)
387
- use_history: Whether to maintain conversation history
388
- request_params: Additional request parameters
389
- continue_with_final: When using prompt(), whether to continue with the final agent after processing chain (default: True)
390
- cumulative: When True, each agent receives all previous agent responses concatenated (default: False)
391
- When False, each agent only gets the output of the previous agent (default behavior)
392
- """
393
- # Support both parameter names
394
- agent_sequence = sequence or agents
395
- if agent_sequence is None:
396
- raise ValueError("Either 'sequence' or 'agents' parameter must be provided")
397
-
398
- # Auto-generate instruction if not provided
399
- if instruction is None:
400
- # Generate an appropriate instruction based on mode
401
- if cumulative:
402
- instruction = f"Cumulative chain of agents: {', '.join(agent_sequence)}"
403
- else:
404
- instruction = f"Chain of agents: {', '.join(agent_sequence)}"
405
-
406
- decorator = self._create_decorator(
407
- AgentType.CHAIN,
408
- default_name="Chain",
409
- default_instruction=instruction,
410
- default_use_history=True,
411
- wrapper_needed=True,
412
- )(
413
- name=name,
414
- sequence=agent_sequence,
415
- instruction=instruction,
416
- model=model,
417
- use_history=use_history,
418
- request_params=request_params,
419
- continue_with_final=continue_with_final,
420
- cumulative=cumulative,
421
- )
422
- return decorator
423
-
424
-
425
- def passthrough(self, name: str = "Passthrough", use_history: bool = True, **kwargs) -> Callable:
426
- """
427
- Decorator to create and register a passthrough agent.
428
- A passthrough agent simply returns any input message without modification.
429
-
430
- This is useful for parallel workflows where no fan-in aggregation is needed
431
- (the fan-in agent can be a passthrough that simply returns the combined outputs).
432
-
433
- Args:
434
- name: Name of the passthrough agent
435
- use_history: Whether to maintain conversation history
436
- **kwargs: Additional parameters (ignored, for compatibility)
437
- """
438
- decorator = self._create_decorator(
439
- AgentType.BASIC, # Using BASIC agent type since we'll use a regular agent with PassthroughLLM
440
- default_name="Passthrough",
441
- default_instruction="Passthrough agent that returns input without modification",
442
- default_use_history=use_history,
443
- wrapper_needed=True,
444
- )(
445
- name=name,
446
- use_history=use_history,
447
- )
448
- return decorator