fast-agent-mcp 0.2.57__py3-none-any.whl → 0.3.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.
Potentially problematic release.
This version of fast-agent-mcp might be problematic. Click here for more details.
- fast_agent/__init__.py +127 -0
- fast_agent/agents/__init__.py +36 -0
- {mcp_agent/core → fast_agent/agents}/agent_types.py +2 -1
- fast_agent/agents/llm_agent.py +217 -0
- fast_agent/agents/llm_decorator.py +486 -0
- mcp_agent/agents/base_agent.py → fast_agent/agents/mcp_agent.py +377 -385
- fast_agent/agents/tool_agent.py +168 -0
- {mcp_agent → fast_agent}/agents/workflow/chain_agent.py +43 -33
- {mcp_agent → fast_agent}/agents/workflow/evaluator_optimizer.py +31 -35
- {mcp_agent → fast_agent}/agents/workflow/iterative_planner.py +56 -47
- {mcp_agent → fast_agent}/agents/workflow/orchestrator_models.py +4 -4
- {mcp_agent → fast_agent}/agents/workflow/parallel_agent.py +34 -41
- {mcp_agent → fast_agent}/agents/workflow/router_agent.py +54 -39
- {mcp_agent → fast_agent}/cli/__main__.py +5 -3
- {mcp_agent → fast_agent}/cli/commands/check_config.py +95 -66
- {mcp_agent → fast_agent}/cli/commands/go.py +20 -11
- {mcp_agent → fast_agent}/cli/commands/quickstart.py +4 -4
- {mcp_agent → fast_agent}/cli/commands/server_helpers.py +1 -1
- {mcp_agent → fast_agent}/cli/commands/setup.py +64 -134
- {mcp_agent → fast_agent}/cli/commands/url_parser.py +9 -8
- {mcp_agent → fast_agent}/cli/main.py +36 -16
- {mcp_agent → fast_agent}/cli/terminal.py +2 -2
- {mcp_agent → fast_agent}/config.py +13 -2
- fast_agent/constants.py +8 -0
- {mcp_agent → fast_agent}/context.py +24 -19
- {mcp_agent → fast_agent}/context_dependent.py +9 -5
- fast_agent/core/__init__.py +17 -0
- {mcp_agent → fast_agent}/core/agent_app.py +39 -36
- fast_agent/core/core_app.py +135 -0
- {mcp_agent → fast_agent}/core/direct_decorators.py +12 -26
- {mcp_agent → fast_agent}/core/direct_factory.py +95 -73
- {mcp_agent → fast_agent/core}/executor/executor.py +4 -5
- {mcp_agent → fast_agent}/core/fastagent.py +32 -32
- fast_agent/core/logging/__init__.py +5 -0
- {mcp_agent → fast_agent/core}/logging/events.py +3 -3
- {mcp_agent → fast_agent/core}/logging/json_serializer.py +1 -1
- {mcp_agent → fast_agent/core}/logging/listeners.py +85 -7
- {mcp_agent → fast_agent/core}/logging/logger.py +7 -7
- {mcp_agent → fast_agent/core}/logging/transport.py +10 -11
- fast_agent/core/prompt.py +9 -0
- {mcp_agent → fast_agent}/core/validation.py +4 -4
- fast_agent/event_progress.py +61 -0
- fast_agent/history/history_exporter.py +44 -0
- {mcp_agent → fast_agent}/human_input/__init__.py +9 -12
- {mcp_agent → fast_agent}/human_input/elicitation_handler.py +26 -8
- {mcp_agent → fast_agent}/human_input/elicitation_state.py +7 -7
- {mcp_agent → fast_agent}/human_input/simple_form.py +6 -4
- {mcp_agent → fast_agent}/human_input/types.py +1 -18
- fast_agent/interfaces.py +228 -0
- fast_agent/llm/__init__.py +9 -0
- mcp_agent/llm/augmented_llm.py → fast_agent/llm/fastagent_llm.py +128 -218
- fast_agent/llm/internal/passthrough.py +137 -0
- mcp_agent/llm/augmented_llm_playback.py → fast_agent/llm/internal/playback.py +29 -25
- mcp_agent/llm/augmented_llm_silent.py → fast_agent/llm/internal/silent.py +10 -17
- fast_agent/llm/internal/slow.py +38 -0
- {mcp_agent → fast_agent}/llm/memory.py +40 -30
- {mcp_agent → fast_agent}/llm/model_database.py +35 -2
- {mcp_agent → fast_agent}/llm/model_factory.py +103 -77
- fast_agent/llm/model_info.py +126 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/anthropic}/anthropic_utils.py +7 -7
- fast_agent/llm/provider/anthropic/llm_anthropic.py +603 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/anthropic}/multipart_converter_anthropic.py +79 -86
- fast_agent/llm/provider/bedrock/bedrock_utils.py +218 -0
- fast_agent/llm/provider/bedrock/llm_bedrock.py +2192 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/google}/google_converter.py +66 -14
- fast_agent/llm/provider/google/llm_google_native.py +431 -0
- mcp_agent/llm/providers/augmented_llm_aliyun.py → fast_agent/llm/provider/openai/llm_aliyun.py +6 -7
- mcp_agent/llm/providers/augmented_llm_azure.py → fast_agent/llm/provider/openai/llm_azure.py +4 -4
- mcp_agent/llm/providers/augmented_llm_deepseek.py → fast_agent/llm/provider/openai/llm_deepseek.py +10 -11
- mcp_agent/llm/providers/augmented_llm_generic.py → fast_agent/llm/provider/openai/llm_generic.py +4 -4
- mcp_agent/llm/providers/augmented_llm_google_oai.py → fast_agent/llm/provider/openai/llm_google_oai.py +4 -4
- mcp_agent/llm/providers/augmented_llm_groq.py → fast_agent/llm/provider/openai/llm_groq.py +14 -16
- mcp_agent/llm/providers/augmented_llm_openai.py → fast_agent/llm/provider/openai/llm_openai.py +133 -206
- mcp_agent/llm/providers/augmented_llm_openrouter.py → fast_agent/llm/provider/openai/llm_openrouter.py +6 -6
- mcp_agent/llm/providers/augmented_llm_tensorzero_openai.py → fast_agent/llm/provider/openai/llm_tensorzero_openai.py +17 -16
- mcp_agent/llm/providers/augmented_llm_xai.py → fast_agent/llm/provider/openai/llm_xai.py +6 -6
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/multipart_converter_openai.py +125 -63
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/openai_multipart.py +12 -12
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/openai_utils.py +18 -16
- {mcp_agent → fast_agent}/llm/provider_key_manager.py +2 -2
- {mcp_agent → fast_agent}/llm/provider_types.py +2 -0
- {mcp_agent → fast_agent}/llm/sampling_converter.py +15 -12
- {mcp_agent → fast_agent}/llm/usage_tracking.py +23 -5
- fast_agent/mcp/__init__.py +43 -0
- {mcp_agent → fast_agent}/mcp/elicitation_factory.py +3 -3
- {mcp_agent → fast_agent}/mcp/elicitation_handlers.py +19 -10
- {mcp_agent → fast_agent}/mcp/gen_client.py +3 -3
- fast_agent/mcp/helpers/__init__.py +36 -0
- fast_agent/mcp/helpers/content_helpers.py +183 -0
- {mcp_agent → fast_agent}/mcp/helpers/server_config_helpers.py +8 -8
- {mcp_agent → fast_agent}/mcp/hf_auth.py +25 -23
- fast_agent/mcp/interfaces.py +93 -0
- {mcp_agent → fast_agent}/mcp/logger_textio.py +4 -4
- {mcp_agent → fast_agent}/mcp/mcp_agent_client_session.py +49 -44
- {mcp_agent → fast_agent}/mcp/mcp_aggregator.py +66 -115
- {mcp_agent → fast_agent}/mcp/mcp_connection_manager.py +16 -23
- {mcp_agent/core → fast_agent/mcp}/mcp_content.py +23 -15
- {mcp_agent → fast_agent}/mcp/mime_utils.py +39 -0
- fast_agent/mcp/prompt.py +159 -0
- mcp_agent/mcp/prompt_message_multipart.py → fast_agent/mcp/prompt_message_extended.py +27 -20
- {mcp_agent → fast_agent}/mcp/prompt_render.py +21 -19
- {mcp_agent → fast_agent}/mcp/prompt_serialization.py +46 -46
- fast_agent/mcp/prompts/__main__.py +7 -0
- {mcp_agent → fast_agent}/mcp/prompts/prompt_helpers.py +31 -30
- {mcp_agent → fast_agent}/mcp/prompts/prompt_load.py +8 -8
- {mcp_agent → fast_agent}/mcp/prompts/prompt_server.py +11 -19
- {mcp_agent → fast_agent}/mcp/prompts/prompt_template.py +18 -18
- {mcp_agent → fast_agent}/mcp/resource_utils.py +1 -1
- {mcp_agent → fast_agent}/mcp/sampling.py +31 -26
- {mcp_agent/mcp_server → fast_agent/mcp/server}/__init__.py +1 -1
- {mcp_agent/mcp_server → fast_agent/mcp/server}/agent_server.py +5 -6
- fast_agent/mcp/ui_agent.py +48 -0
- fast_agent/mcp/ui_mixin.py +209 -0
- fast_agent/mcp_server_registry.py +90 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/analysis-campaign.py +5 -4
- {mcp_agent → fast_agent}/resources/examples/data-analysis/analysis.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_forms_server.py +25 -3
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/forms_demo.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/game_character.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/game_character_handler.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/tool_call.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/agent_one.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/agent_two.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher-eval.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher-imp.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/tensorzero/agent.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/tensorzero/image_demo.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/tensorzero/simple_agent.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/chaining.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/evaluator.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/workflows/human_input.py +5 -3
- {mcp_agent → fast_agent}/resources/examples/workflows/orchestrator.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/parallel.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/workflows/router.py +5 -2
- fast_agent/resources/setup/.gitignore +24 -0
- fast_agent/resources/setup/agent.py +18 -0
- fast_agent/resources/setup/fastagent.config.yaml +44 -0
- fast_agent/resources/setup/fastagent.secrets.yaml.example +38 -0
- fast_agent/tools/elicitation.py +369 -0
- fast_agent/types/__init__.py +32 -0
- fast_agent/types/llm_stop_reason.py +77 -0
- fast_agent/ui/__init__.py +38 -0
- fast_agent/ui/console_display.py +1005 -0
- {mcp_agent/human_input → fast_agent/ui}/elicitation_form.py +56 -39
- mcp_agent/human_input/elicitation_forms.py → fast_agent/ui/elicitation_style.py +1 -1
- {mcp_agent/core → fast_agent/ui}/enhanced_prompt.py +96 -25
- {mcp_agent/core → fast_agent/ui}/interactive_prompt.py +330 -125
- fast_agent/ui/mcp_ui_utils.py +224 -0
- {mcp_agent → fast_agent/ui}/progress_display.py +2 -2
- {mcp_agent/logging → fast_agent/ui}/rich_progress.py +4 -4
- {mcp_agent/core → fast_agent/ui}/usage_display.py +3 -8
- {fast_agent_mcp-0.2.57.dist-info → fast_agent_mcp-0.3.0.dist-info}/METADATA +7 -7
- fast_agent_mcp-0.3.0.dist-info/RECORD +202 -0
- fast_agent_mcp-0.3.0.dist-info/entry_points.txt +5 -0
- fast_agent_mcp-0.2.57.dist-info/RECORD +0 -192
- fast_agent_mcp-0.2.57.dist-info/entry_points.txt +0 -6
- mcp_agent/__init__.py +0 -114
- mcp_agent/agents/agent.py +0 -92
- mcp_agent/agents/workflow/__init__.py +0 -1
- mcp_agent/agents/workflow/orchestrator_agent.py +0 -597
- mcp_agent/app.py +0 -175
- mcp_agent/core/__init__.py +0 -26
- mcp_agent/core/prompt.py +0 -191
- mcp_agent/event_progress.py +0 -134
- mcp_agent/human_input/handler.py +0 -81
- mcp_agent/llm/__init__.py +0 -2
- mcp_agent/llm/augmented_llm_passthrough.py +0 -232
- mcp_agent/llm/augmented_llm_slow.py +0 -53
- mcp_agent/llm/providers/__init__.py +0 -8
- mcp_agent/llm/providers/augmented_llm_anthropic.py +0 -717
- mcp_agent/llm/providers/augmented_llm_bedrock.py +0 -1788
- mcp_agent/llm/providers/augmented_llm_google_native.py +0 -495
- mcp_agent/llm/providers/sampling_converter_anthropic.py +0 -57
- mcp_agent/llm/providers/sampling_converter_openai.py +0 -26
- mcp_agent/llm/sampling_format_converter.py +0 -37
- mcp_agent/logging/__init__.py +0 -0
- mcp_agent/mcp/__init__.py +0 -50
- mcp_agent/mcp/helpers/__init__.py +0 -25
- mcp_agent/mcp/helpers/content_helpers.py +0 -187
- mcp_agent/mcp/interfaces.py +0 -266
- mcp_agent/mcp/prompts/__init__.py +0 -0
- mcp_agent/mcp/prompts/__main__.py +0 -10
- mcp_agent/mcp_server_registry.py +0 -343
- mcp_agent/tools/tool_definition.py +0 -14
- mcp_agent/ui/console_display.py +0 -790
- mcp_agent/ui/console_display_legacy.py +0 -401
- {mcp_agent → fast_agent}/agents/workflow/orchestrator_prompts.py +0 -0
- {mcp_agent/agents → fast_agent/cli}/__init__.py +0 -0
- {mcp_agent → fast_agent}/cli/constants.py +0 -0
- {mcp_agent → fast_agent}/core/error_handling.py +0 -0
- {mcp_agent → fast_agent}/core/exceptions.py +0 -0
- {mcp_agent/cli → fast_agent/core/executor}/__init__.py +0 -0
- {mcp_agent → fast_agent/core}/executor/task_registry.py +0 -0
- {mcp_agent → fast_agent/core}/executor/workflow_signal.py +0 -0
- {mcp_agent → fast_agent}/human_input/form_fields.py +0 -0
- {mcp_agent → fast_agent}/llm/prompt_utils.py +0 -0
- {mcp_agent/core → fast_agent/llm}/request_params.py +0 -0
- {mcp_agent → fast_agent}/mcp/common.py +0 -0
- {mcp_agent/executor → fast_agent/mcp/prompts}/__init__.py +0 -0
- {mcp_agent → fast_agent}/mcp/prompts/prompt_constants.py +0 -0
- {mcp_agent → fast_agent}/py.typed +0 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_account_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_game_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/fastagent.secrets.yaml.example +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/fastagent.secrets.yaml.example +0 -0
- {mcp_agent → fast_agent}/resources/examples/researcher/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/.env.sample +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/Makefile +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/README.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/clam.jpg +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/crab.png +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/shrimp.png +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/docker-compose.yml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/Dockerfile +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/entrypoint.sh +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/mcp_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/pyproject.toml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/system_schema.json +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/system_template.minijinja +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/tensorzero.toml +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/graded_report.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/short_story.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/short_story.txt +0 -0
- {mcp_agent → fast_agent/ui}/console.py +0 -0
- {mcp_agent/core → fast_agent/ui}/mermaid_utils.py +0 -0
- {fast_agent_mcp-0.2.57.dist-info → fast_agent_mcp-0.3.0.dist-info}/WHEEL +0 -0
- {fast_agent_mcp-0.2.57.dist-info → fast_agent_mcp-0.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,49 +3,79 @@ Direct factory functions for creating agent and workflow instances without proxi
|
|
|
3
3
|
Implements type-safe factories with improved error handling.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, Dict, Optional, Protocol, TypeVar
|
|
7
7
|
|
|
8
|
-
from
|
|
9
|
-
from
|
|
8
|
+
from fast_agent.agents.agent_types import AgentConfig, AgentType
|
|
9
|
+
from fast_agent.agents.llm_agent import LlmAgent
|
|
10
|
+
from fast_agent.agents.mcp_agent import McpAgent
|
|
11
|
+
from fast_agent.agents.workflow.evaluator_optimizer import (
|
|
10
12
|
EvaluatorOptimizerAgent,
|
|
11
13
|
QualityRating,
|
|
12
14
|
)
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
21
|
-
from
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
from fast_agent.agents.workflow.iterative_planner import IterativePlanner
|
|
16
|
+
from fast_agent.agents.workflow.parallel_agent import ParallelAgent
|
|
17
|
+
from fast_agent.agents.workflow.router_agent import RouterAgent
|
|
18
|
+
from fast_agent.core import Core
|
|
19
|
+
from fast_agent.core.exceptions import AgentConfigError
|
|
20
|
+
from fast_agent.core.logging.logger import get_logger
|
|
21
|
+
from fast_agent.core.validation import get_dependencies_groups
|
|
22
|
+
from fast_agent.event_progress import ProgressAction
|
|
23
|
+
from fast_agent.interfaces import (
|
|
24
|
+
AgentProtocol,
|
|
25
|
+
LLMFactoryProtocol,
|
|
26
|
+
ModelFactoryFunctionProtocol,
|
|
27
|
+
)
|
|
28
|
+
from fast_agent.llm.model_factory import ModelFactory
|
|
29
|
+
from fast_agent.mcp.ui_agent import McpAgentWithUI
|
|
30
|
+
from fast_agent.types import RequestParams
|
|
26
31
|
|
|
27
32
|
# Type aliases for improved readability and IDE support
|
|
28
33
|
AgentDict = Dict[str, AgentProtocol]
|
|
29
34
|
AgentConfigDict = Dict[str, Dict[str, Any]]
|
|
30
35
|
T = TypeVar("T") # For generic types
|
|
31
36
|
|
|
32
|
-
# Type for model factory functions
|
|
33
|
-
ModelFactoryFn = Callable[[Optional[str], Optional[RequestParams]], Callable[[], Any]]
|
|
34
|
-
|
|
35
37
|
|
|
36
38
|
logger = get_logger(__name__)
|
|
37
39
|
|
|
38
40
|
|
|
41
|
+
def _create_agent_with_ui_if_needed(
|
|
42
|
+
agent_class: type,
|
|
43
|
+
config: Any,
|
|
44
|
+
context: Any,
|
|
45
|
+
) -> Any:
|
|
46
|
+
"""
|
|
47
|
+
Create an agent with UI support if MCP UI mode is enabled.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
agent_class: The agent class to potentially enhance with UI
|
|
51
|
+
config: Agent configuration
|
|
52
|
+
context: Application context
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
Either a UI-enhanced agent instance or the original agent instance
|
|
56
|
+
"""
|
|
57
|
+
# Check UI mode from settings
|
|
58
|
+
settings = context.config if hasattr(context, "config") else None
|
|
59
|
+
ui_mode = getattr(settings, "mcp_ui_mode", "auto") if settings else "auto"
|
|
60
|
+
|
|
61
|
+
if ui_mode != "disabled" and agent_class == McpAgent:
|
|
62
|
+
# Use the UI-enhanced agent class instead of the base class
|
|
63
|
+
return McpAgentWithUI(config=config, context=context, ui_mode=ui_mode)
|
|
64
|
+
else:
|
|
65
|
+
# Create the original agent instance
|
|
66
|
+
return agent_class(config=config, context=context)
|
|
67
|
+
|
|
68
|
+
|
|
39
69
|
class AgentCreatorProtocol(Protocol):
|
|
40
70
|
"""Protocol for agent creator functions."""
|
|
41
71
|
|
|
42
72
|
async def __call__(
|
|
43
73
|
self,
|
|
44
|
-
app_instance:
|
|
74
|
+
app_instance: Core,
|
|
45
75
|
agents_dict: AgentConfigDict,
|
|
46
76
|
agent_type: AgentType,
|
|
47
77
|
active_agents: Optional[AgentDict] = None,
|
|
48
|
-
model_factory_func: Optional[
|
|
78
|
+
model_factory_func: Optional[ModelFactoryFunctionProtocol] = None,
|
|
49
79
|
**kwargs: Any,
|
|
50
80
|
) -> AgentDict: ...
|
|
51
81
|
|
|
@@ -56,7 +86,7 @@ def get_model_factory(
|
|
|
56
86
|
request_params: Optional[RequestParams] = None,
|
|
57
87
|
default_model: Optional[str] = None,
|
|
58
88
|
cli_model: Optional[str] = None,
|
|
59
|
-
) ->
|
|
89
|
+
) -> LLMFactoryProtocol:
|
|
60
90
|
"""
|
|
61
91
|
Get model factory using specified or default model.
|
|
62
92
|
Model string is parsed by ModelFactory to determine provider and reasoning effort.
|
|
@@ -89,15 +119,15 @@ def get_model_factory(
|
|
|
89
119
|
request_params = RequestParams(model=model_spec)
|
|
90
120
|
|
|
91
121
|
# Let model factory handle the model string parsing and setup
|
|
92
|
-
return ModelFactory.create_factory(model_spec
|
|
122
|
+
return ModelFactory.create_factory(model_spec)
|
|
93
123
|
|
|
94
124
|
|
|
95
125
|
async def create_agents_by_type(
|
|
96
|
-
app_instance:
|
|
126
|
+
app_instance: Core,
|
|
97
127
|
agents_dict: AgentConfigDict,
|
|
98
128
|
agent_type: AgentType,
|
|
129
|
+
model_factory_func: ModelFactoryFunctionProtocol,
|
|
99
130
|
active_agents: Optional[AgentDict] = None,
|
|
100
|
-
model_factory_func: Optional[ModelFactoryFn] = None,
|
|
101
131
|
**kwargs: Any,
|
|
102
132
|
) -> AgentDict:
|
|
103
133
|
"""
|
|
@@ -117,11 +147,6 @@ async def create_agents_by_type(
|
|
|
117
147
|
if active_agents is None:
|
|
118
148
|
active_agents = {}
|
|
119
149
|
|
|
120
|
-
if model_factory_func is None:
|
|
121
|
-
# Default factory that just returns the inputs - should be overridden
|
|
122
|
-
def model_factory_func(model=None, request_params=None):
|
|
123
|
-
return lambda: None
|
|
124
|
-
|
|
125
150
|
# Create a dictionary to store the initialized agents
|
|
126
151
|
result_agents: AgentDict = {}
|
|
127
152
|
|
|
@@ -143,11 +168,13 @@ async def create_agents_by_type(
|
|
|
143
168
|
# Type-specific initialization based on the Enum type
|
|
144
169
|
# Note: Above we compared string values from config, here we compare Enum objects directly
|
|
145
170
|
if agent_type == AgentType.BASIC:
|
|
146
|
-
# Create
|
|
147
|
-
agent =
|
|
148
|
-
|
|
149
|
-
|
|
171
|
+
# Create agent with UI support if needed
|
|
172
|
+
agent = _create_agent_with_ui_if_needed(
|
|
173
|
+
McpAgent,
|
|
174
|
+
config,
|
|
175
|
+
app_instance.context,
|
|
150
176
|
)
|
|
177
|
+
|
|
151
178
|
await agent.initialize()
|
|
152
179
|
|
|
153
180
|
# Attach LLM to the agent
|
|
@@ -160,15 +187,21 @@ async def create_agents_by_type(
|
|
|
160
187
|
result_agents[name] = agent
|
|
161
188
|
|
|
162
189
|
elif agent_type == AgentType.CUSTOM:
|
|
163
|
-
# Get the class to instantiate
|
|
164
|
-
cls = agent_data
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
# Get the class to instantiate (support legacy 'agent_class' and new 'cls')
|
|
191
|
+
cls = agent_data.get("agent_class") or agent_data.get("cls")
|
|
192
|
+
if cls is None:
|
|
193
|
+
raise AgentConfigError(
|
|
194
|
+
f"Custom agent '{name}' missing class reference ('agent_class' or 'cls')"
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
# Create agent with UI support if needed
|
|
198
|
+
agent = _create_agent_with_ui_if_needed(
|
|
199
|
+
cls,
|
|
200
|
+
config,
|
|
201
|
+
app_instance.context,
|
|
169
202
|
)
|
|
170
|
-
await agent.initialize()
|
|
171
203
|
|
|
204
|
+
await agent.initialize()
|
|
172
205
|
# Attach LLM to the agent
|
|
173
206
|
llm_factory = model_factory_func(model=config.model)
|
|
174
207
|
await agent.attach_llm(
|
|
@@ -195,23 +228,13 @@ async def create_agents_by_type(
|
|
|
195
228
|
agent = active_agents[agent_name]
|
|
196
229
|
child_agents.append(agent)
|
|
197
230
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
plan_type=agent_data.get("plan_type", "full"),
|
|
206
|
-
)
|
|
207
|
-
else:
|
|
208
|
-
orchestrator = IterativePlanner(
|
|
209
|
-
config=config,
|
|
210
|
-
context=app_instance.context,
|
|
211
|
-
agents=child_agents,
|
|
212
|
-
plan_iterations=agent_data.get("plan_iterations", 5),
|
|
213
|
-
plan_type=agent_data.get("plan_type", "full"),
|
|
214
|
-
)
|
|
231
|
+
orchestrator = IterativePlanner(
|
|
232
|
+
config=config,
|
|
233
|
+
context=app_instance.context,
|
|
234
|
+
agents=child_agents,
|
|
235
|
+
plan_iterations=agent_data.get("plan_iterations", 5),
|
|
236
|
+
plan_type=agent_data.get("plan_type", "full"),
|
|
237
|
+
)
|
|
215
238
|
|
|
216
239
|
# Initialize the orchestrator
|
|
217
240
|
await orchestrator.initialize()
|
|
@@ -219,7 +242,6 @@ async def create_agents_by_type(
|
|
|
219
242
|
# Attach LLM to the orchestrator
|
|
220
243
|
llm_factory = model_factory_func(model=config.model)
|
|
221
244
|
|
|
222
|
-
# print("************", config.default_request_params.instruction)
|
|
223
245
|
await orchestrator.attach_llm(
|
|
224
246
|
llm_factory,
|
|
225
247
|
request_params=config.default_request_params,
|
|
@@ -304,7 +326,7 @@ async def create_agents_by_type(
|
|
|
304
326
|
raise AgentConfigError(f"Chain agent {agent_name} not found")
|
|
305
327
|
chain_agents.append(active_agents[agent_name])
|
|
306
328
|
|
|
307
|
-
from
|
|
329
|
+
from fast_agent.agents.workflow.chain_agent import ChainAgent
|
|
308
330
|
|
|
309
331
|
# Get the cumulative parameter
|
|
310
332
|
cumulative = agent_data.get("cumulative", False)
|
|
@@ -358,9 +380,9 @@ async def create_agents_by_type(
|
|
|
358
380
|
|
|
359
381
|
|
|
360
382
|
async def create_agents_in_dependency_order(
|
|
361
|
-
app_instance:
|
|
383
|
+
app_instance: Core,
|
|
362
384
|
agents_dict: AgentConfigDict,
|
|
363
|
-
model_factory_func:
|
|
385
|
+
model_factory_func: ModelFactoryFunctionProtocol,
|
|
364
386
|
allow_cycles: bool = False,
|
|
365
387
|
) -> AgentDict:
|
|
366
388
|
"""
|
|
@@ -394,8 +416,8 @@ async def create_agents_in_dependency_order(
|
|
|
394
416
|
if agents_dict[name]["type"] == AgentType.BASIC.value
|
|
395
417
|
},
|
|
396
418
|
AgentType.BASIC,
|
|
397
|
-
active_agents,
|
|
398
419
|
model_factory_func,
|
|
420
|
+
active_agents,
|
|
399
421
|
)
|
|
400
422
|
active_agents.update(basic_agents)
|
|
401
423
|
|
|
@@ -409,8 +431,8 @@ async def create_agents_in_dependency_order(
|
|
|
409
431
|
if agents_dict[name]["type"] == AgentType.CUSTOM.value
|
|
410
432
|
},
|
|
411
433
|
AgentType.CUSTOM,
|
|
412
|
-
active_agents,
|
|
413
434
|
model_factory_func,
|
|
435
|
+
active_agents,
|
|
414
436
|
)
|
|
415
437
|
active_agents.update(basic_agents)
|
|
416
438
|
|
|
@@ -424,8 +446,8 @@ async def create_agents_in_dependency_order(
|
|
|
424
446
|
if agents_dict[name]["type"] == AgentType.PARALLEL.value
|
|
425
447
|
},
|
|
426
448
|
AgentType.PARALLEL,
|
|
427
|
-
active_agents,
|
|
428
449
|
model_factory_func,
|
|
450
|
+
active_agents,
|
|
429
451
|
)
|
|
430
452
|
active_agents.update(parallel_agents)
|
|
431
453
|
|
|
@@ -439,8 +461,8 @@ async def create_agents_in_dependency_order(
|
|
|
439
461
|
if agents_dict[name]["type"] == AgentType.ROUTER.value
|
|
440
462
|
},
|
|
441
463
|
AgentType.ROUTER,
|
|
442
|
-
active_agents,
|
|
443
464
|
model_factory_func,
|
|
465
|
+
active_agents,
|
|
444
466
|
)
|
|
445
467
|
active_agents.update(router_agents)
|
|
446
468
|
|
|
@@ -454,8 +476,8 @@ async def create_agents_in_dependency_order(
|
|
|
454
476
|
if agents_dict[name]["type"] == AgentType.CHAIN.value
|
|
455
477
|
},
|
|
456
478
|
AgentType.CHAIN,
|
|
457
|
-
active_agents,
|
|
458
479
|
model_factory_func,
|
|
480
|
+
active_agents,
|
|
459
481
|
)
|
|
460
482
|
active_agents.update(chain_agents)
|
|
461
483
|
|
|
@@ -469,8 +491,8 @@ async def create_agents_in_dependency_order(
|
|
|
469
491
|
if agents_dict[name]["type"] == AgentType.EVALUATOR_OPTIMIZER.value
|
|
470
492
|
},
|
|
471
493
|
AgentType.EVALUATOR_OPTIMIZER,
|
|
472
|
-
active_agents,
|
|
473
494
|
model_factory_func,
|
|
495
|
+
active_agents,
|
|
474
496
|
)
|
|
475
497
|
active_agents.update(evaluator_agents)
|
|
476
498
|
|
|
@@ -483,8 +505,8 @@ async def create_agents_in_dependency_order(
|
|
|
483
505
|
if agents_dict[name]["type"] == AgentType.ORCHESTRATOR.value
|
|
484
506
|
},
|
|
485
507
|
AgentType.ORCHESTRATOR,
|
|
486
|
-
active_agents,
|
|
487
508
|
model_factory_func,
|
|
509
|
+
active_agents,
|
|
488
510
|
)
|
|
489
511
|
active_agents.update(orchestrator_agents)
|
|
490
512
|
|
|
@@ -498,8 +520,8 @@ async def create_agents_in_dependency_order(
|
|
|
498
520
|
if agents_dict[name]["type"] == AgentType.ITERATIVE_PLANNER.value
|
|
499
521
|
},
|
|
500
522
|
AgentType.ITERATIVE_PLANNER,
|
|
501
|
-
active_agents,
|
|
502
523
|
model_factory_func,
|
|
524
|
+
active_agents,
|
|
503
525
|
)
|
|
504
526
|
active_agents.update(orchestrator2_agents)
|
|
505
527
|
|
|
@@ -509,8 +531,8 @@ async def create_agents_in_dependency_order(
|
|
|
509
531
|
async def _create_default_fan_in_agent(
|
|
510
532
|
fan_in_name: str,
|
|
511
533
|
context,
|
|
512
|
-
model_factory_func:
|
|
513
|
-
) ->
|
|
534
|
+
model_factory_func: ModelFactoryFunctionProtocol,
|
|
535
|
+
) -> AgentProtocol:
|
|
514
536
|
"""
|
|
515
537
|
Create a default fan-in agent for parallel workflows when none is specified.
|
|
516
538
|
|
|
@@ -530,7 +552,7 @@ async def _create_default_fan_in_agent(
|
|
|
530
552
|
)
|
|
531
553
|
|
|
532
554
|
# Create and initialize the default agent
|
|
533
|
-
fan_in_agent =
|
|
555
|
+
fan_in_agent = LlmAgent(
|
|
534
556
|
config=default_config,
|
|
535
557
|
context=context,
|
|
536
558
|
)
|
|
@@ -19,17 +19,17 @@ from typing import (
|
|
|
19
19
|
|
|
20
20
|
from pydantic import BaseModel, ConfigDict
|
|
21
21
|
|
|
22
|
-
from
|
|
23
|
-
from
|
|
22
|
+
from fast_agent.context_dependent import ContextDependent
|
|
23
|
+
from fast_agent.core.executor.workflow_signal import (
|
|
24
24
|
AsyncioSignalHandler,
|
|
25
25
|
Signal,
|
|
26
26
|
SignalHandler,
|
|
27
27
|
SignalValueT,
|
|
28
28
|
)
|
|
29
|
-
from
|
|
29
|
+
from fast_agent.core.logging.logger import get_logger
|
|
30
30
|
|
|
31
31
|
if TYPE_CHECKING:
|
|
32
|
-
from
|
|
32
|
+
from fast_agent.context import Context
|
|
33
33
|
|
|
34
34
|
logger = get_logger(__name__)
|
|
35
35
|
|
|
@@ -221,7 +221,6 @@ class AsyncioExecutor(Executor):
|
|
|
221
221
|
|
|
222
222
|
return result
|
|
223
223
|
except Exception as e:
|
|
224
|
-
# TODO: saqadri - adding logging or other error handling here
|
|
225
224
|
return e
|
|
226
225
|
|
|
227
226
|
if self._activity_semaphore:
|
|
@@ -15,40 +15,40 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, TypeVar
|
|
|
15
15
|
import yaml
|
|
16
16
|
from opentelemetry import trace
|
|
17
17
|
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
21
|
-
from
|
|
22
|
-
from
|
|
18
|
+
from fast_agent import config
|
|
19
|
+
from fast_agent.context import Context
|
|
20
|
+
from fast_agent.core import Core
|
|
21
|
+
from fast_agent.core.agent_app import AgentApp
|
|
22
|
+
from fast_agent.core.direct_decorators import (
|
|
23
23
|
agent as agent_decorator,
|
|
24
24
|
)
|
|
25
|
-
from
|
|
25
|
+
from fast_agent.core.direct_decorators import (
|
|
26
26
|
chain as chain_decorator,
|
|
27
27
|
)
|
|
28
|
-
from
|
|
28
|
+
from fast_agent.core.direct_decorators import (
|
|
29
29
|
custom as custom_decorator,
|
|
30
30
|
)
|
|
31
|
-
from
|
|
31
|
+
from fast_agent.core.direct_decorators import (
|
|
32
32
|
evaluator_optimizer as evaluator_optimizer_decorator,
|
|
33
33
|
)
|
|
34
|
-
from
|
|
34
|
+
from fast_agent.core.direct_decorators import (
|
|
35
35
|
iterative_planner as orchestrator2_decorator,
|
|
36
36
|
)
|
|
37
|
-
from
|
|
37
|
+
from fast_agent.core.direct_decorators import (
|
|
38
38
|
orchestrator as orchestrator_decorator,
|
|
39
39
|
)
|
|
40
|
-
from
|
|
40
|
+
from fast_agent.core.direct_decorators import (
|
|
41
41
|
parallel as parallel_decorator,
|
|
42
42
|
)
|
|
43
|
-
from
|
|
43
|
+
from fast_agent.core.direct_decorators import (
|
|
44
44
|
router as router_decorator,
|
|
45
45
|
)
|
|
46
|
-
from
|
|
46
|
+
from fast_agent.core.direct_factory import (
|
|
47
47
|
create_agents_in_dependency_order,
|
|
48
48
|
get_model_factory,
|
|
49
49
|
)
|
|
50
|
-
from
|
|
51
|
-
from
|
|
50
|
+
from fast_agent.core.error_handling import handle_error
|
|
51
|
+
from fast_agent.core.exceptions import (
|
|
52
52
|
AgentConfigError,
|
|
53
53
|
CircularDependencyError,
|
|
54
54
|
ModelConfigError,
|
|
@@ -57,18 +57,18 @@ from mcp_agent.core.exceptions import (
|
|
|
57
57
|
ServerConfigError,
|
|
58
58
|
ServerInitializationError,
|
|
59
59
|
)
|
|
60
|
-
from
|
|
61
|
-
from
|
|
60
|
+
from fast_agent.core.logging.logger import get_logger
|
|
61
|
+
from fast_agent.core.validation import (
|
|
62
62
|
validate_provider_keys_post_creation,
|
|
63
63
|
validate_server_references,
|
|
64
64
|
validate_workflow_references,
|
|
65
65
|
)
|
|
66
|
-
from
|
|
67
|
-
from
|
|
66
|
+
from fast_agent.mcp.prompts.prompt_load import load_prompt_multipart
|
|
67
|
+
from fast_agent.ui.usage_display import display_usage_report
|
|
68
68
|
|
|
69
69
|
if TYPE_CHECKING:
|
|
70
|
-
from
|
|
71
|
-
from
|
|
70
|
+
from fast_agent.interfaces import AgentProtocol
|
|
71
|
+
from fast_agent.types import PromptMessageExtended
|
|
72
72
|
|
|
73
73
|
F = TypeVar("F", bound=Callable[..., Any]) # For decorated functions
|
|
74
74
|
logger = get_logger(__name__)
|
|
@@ -87,7 +87,7 @@ class FastAgent:
|
|
|
87
87
|
ignore_unknown_args: bool = False,
|
|
88
88
|
parse_cli_args: bool = True,
|
|
89
89
|
quiet: bool = False, # Add quiet parameter
|
|
90
|
-
**kwargs
|
|
90
|
+
**kwargs,
|
|
91
91
|
) -> None:
|
|
92
92
|
"""
|
|
93
93
|
Initialize the fast-agent application.
|
|
@@ -201,15 +201,15 @@ class FastAgent:
|
|
|
201
201
|
self.config["logger"]["show_tools"] = False
|
|
202
202
|
|
|
203
203
|
# Create the app with our local settings
|
|
204
|
-
self.app =
|
|
204
|
+
self.app = Core(
|
|
205
205
|
name=name,
|
|
206
206
|
settings=config.Settings(**self.config) if hasattr(self, "config") else None,
|
|
207
|
-
**kwargs
|
|
207
|
+
**kwargs,
|
|
208
208
|
)
|
|
209
209
|
|
|
210
210
|
# Stop progress display immediately if quiet mode is requested
|
|
211
211
|
if self._programmatic_quiet:
|
|
212
|
-
from
|
|
212
|
+
from fast_agent.ui.progress_display import progress_display
|
|
213
213
|
|
|
214
214
|
progress_display.stop()
|
|
215
215
|
|
|
@@ -229,7 +229,7 @@ class FastAgent:
|
|
|
229
229
|
but without relying on the global cache."""
|
|
230
230
|
|
|
231
231
|
# Import but make a local copy to avoid affecting the global state
|
|
232
|
-
from
|
|
232
|
+
from fast_agent.config import _settings, get_settings
|
|
233
233
|
|
|
234
234
|
# Temporarily clear the global settings to ensure a fresh load
|
|
235
235
|
old_settings = _settings
|
|
@@ -266,7 +266,7 @@ class FastAgent:
|
|
|
266
266
|
Context manager for running the application.
|
|
267
267
|
Initializes all registered agents.
|
|
268
268
|
"""
|
|
269
|
-
active_agents: Dict[str,
|
|
269
|
+
active_agents: Dict[str, AgentProtocol] = {}
|
|
270
270
|
had_error = False
|
|
271
271
|
await self.app.initialize()
|
|
272
272
|
|
|
@@ -292,7 +292,7 @@ class FastAgent:
|
|
|
292
292
|
self.app.context.config.logger.show_tools = False
|
|
293
293
|
|
|
294
294
|
# Directly disable the progress display singleton
|
|
295
|
-
from
|
|
295
|
+
from fast_agent.ui.progress_display import progress_display
|
|
296
296
|
|
|
297
297
|
progress_display.stop()
|
|
298
298
|
|
|
@@ -342,7 +342,7 @@ class FastAgent:
|
|
|
342
342
|
print("Press Ctrl+C to stop")
|
|
343
343
|
|
|
344
344
|
# Create the MCP server
|
|
345
|
-
from
|
|
345
|
+
from fast_agent.mcp.server import AgentMCPServer
|
|
346
346
|
|
|
347
347
|
mcp_server = AgentMCPServer(
|
|
348
348
|
agent_app=wrapper,
|
|
@@ -397,7 +397,7 @@ class FastAgent:
|
|
|
397
397
|
|
|
398
398
|
if hasattr(self.args, "prompt_file") and self.args.prompt_file:
|
|
399
399
|
agent_name = self.args.agent
|
|
400
|
-
prompt: List[
|
|
400
|
+
prompt: List[PromptMessageExtended] = load_prompt_multipart(
|
|
401
401
|
Path(self.args.prompt_file)
|
|
402
402
|
)
|
|
403
403
|
if agent_name not in active_agents:
|
|
@@ -443,14 +443,14 @@ class FastAgent:
|
|
|
443
443
|
finally:
|
|
444
444
|
# Ensure progress display is stopped before showing usage summary
|
|
445
445
|
try:
|
|
446
|
-
from
|
|
446
|
+
from fast_agent.ui.progress_display import progress_display
|
|
447
447
|
|
|
448
448
|
progress_display.stop()
|
|
449
449
|
except: # noqa: E722
|
|
450
450
|
pass
|
|
451
451
|
|
|
452
452
|
# Print usage report before cleanup (show for user exits too)
|
|
453
|
-
if active_agents and not had_error:
|
|
453
|
+
if active_agents and not had_error and not quiet_mode:
|
|
454
454
|
self._print_usage_report(active_agents)
|
|
455
455
|
|
|
456
456
|
# Clean up any active agents (always cleanup, even on errors)
|
|
@@ -129,15 +129,15 @@ class StreamingExclusionFilter(EventFilter):
|
|
|
129
129
|
# First check if it passes the base filter
|
|
130
130
|
if not super().matches(event):
|
|
131
131
|
return False
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
# Exclude events with "Streaming progress" message
|
|
134
134
|
if event.message == "Streaming progress":
|
|
135
135
|
return False
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
# Also check for events with progress_action = STREAMING in data
|
|
138
138
|
if event.data and isinstance(event.data.get("data"), dict):
|
|
139
139
|
event_data = event.data["data"]
|
|
140
140
|
if event_data.get("progress_action") == "Streaming":
|
|
141
141
|
return False
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
return True
|