Skip to content

Commit ddb07f5

Browse files
committed
Renaming for ensemble agent
1 parent 7c1b1b7 commit ddb07f5

15 files changed

Lines changed: 111 additions & 195 deletions

File tree

ensemble_agent/agent.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
INTERACTIVE_REVIEW_GOAL,
2020
build_system_prompt,
2121
)
22-
from .scripts import detect_run_script
23-
from .skills import load_skills
24-
from .skills.generator import GeneratorSkill
22+
from .tools import load_tool_providers
23+
from .tools.generator import GeneratorTools
2524

2625
DEFAULT_PROMPT = """Create six_hump_camel APOSMM scripts:
2726
- Executable: six_hump_camel/six_hump_camel.x
@@ -33,7 +32,7 @@
3332

3433

3534
async def run_agent(config: AgentConfig):
36-
"""Main entry point: build skills, connect MCP, run the agent loop."""
35+
"""Main entry point: build tools, connect MCP, run the agent loop."""
3736

3837
# Archive existing output dir before starting fresh
3938
ArchiveManager.archive_existing_output_dir(config.output_dir)
@@ -47,41 +46,38 @@ async def run_agent(config: AgentConfig):
4746
log_path = Path(config.output_dir) / "debug_log.txt"
4847
debug = DebugLogger(log_path, model=config.model)
4948

50-
# Load skills — drop generator when using existing scripts
51-
skill_names = config.skills
52-
if config.scripts_dir and "generator" in skill_names:
53-
skill_names = ",".join(s for s in skill_names.split(",") if s.strip() != "generator")
54-
skills = load_skills(skill_names, config, archive)
55-
has_generator = any(isinstance(s, GeneratorSkill) for s in skills)
49+
# Load tool providers
50+
providers = load_tool_providers(config, archive)
51+
has_generator = any(isinstance(p, GeneratorTools) for p in providers)
5652

57-
# MCP setup for generator skill
53+
# MCP setup for generator
5854
async with AsyncExitStack() as stack:
5955
if has_generator:
6056
mcp_server = find_mcp_server(config.mcp_server)
6157
print(f"Generator MCP: {mcp_server}")
6258
session = await stack.enter_async_context(connect_mcp(mcp_server))
6359
print("Connected to MCP server")
6460

65-
# Get MCP tool schema and inject into generator skill
61+
# Get MCP tool schema and inject into generator
6662
mcp_tools = await session.list_tools()
6763
mcp_tool = mcp_tools.tools[0]
68-
for skill in skills:
69-
if isinstance(skill, GeneratorSkill):
70-
skill.set_mcp_session(session)
71-
skill.set_mcp_tool_schema(mcp_tool)
64+
for p in providers:
65+
if isinstance(p, GeneratorTools):
66+
p.set_mcp_session(session)
67+
p.set_mcp_tool_schema(mcp_tool)
7268

73-
# Collect tools from all skills
69+
# Collect tools from all providers
7470
tools = []
75-
for skill in skills:
76-
tools.extend(skill.get_tools())
71+
for p in providers:
72+
tools.extend(p.get_tools())
7773

7874
# Create LLM and agent
7975
llm, service = create_llm(config.model, config.temperature, config.base_url)
8076
agent = create_agent(llm, tools)
8177
print(f"Agent initialized (model: {config.model}, service: {service})\n")
8278

8379
# Build system prompt
84-
system_prompt = build_system_prompt(skills, has_generator)
80+
system_prompt = build_system_prompt(providers, has_generator)
8581
messages = [("system", system_prompt)]
8682

8783
if debug:

ensemble_agent/config.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
# UI
3434
INPUT_MARKER = "[INPUT_REQUESTED]"
3535

36-
# Default skills
37-
DEFAULT_SKILLS = "file_ops,runner,generator,reference_docs"
38-
3936

4037
def _default_model() -> str:
4138
"""Pick default model based on available API keys."""
@@ -66,9 +63,6 @@ class AgentConfig:
6663
default_factory=lambda: os.environ.get("OPENAI_BASE_URL")
6764
)
6865

69-
# Skills
70-
skills: str = DEFAULT_SKILLS
71-
7266
# MCP servers
7367
mcp_server: Optional[str] = None
7468

@@ -104,18 +98,16 @@ def parse_args(argv=None) -> AgentConfig:
10498
formatter_class=argparse.RawDescriptionHelpFormatter,
10599
epilog="""
106100
Examples:
107-
python -m ensemble_agent --interactive
108-
python -m ensemble_agent --scripts tests/scripts_with_errors/
109-
python -m ensemble_agent --prompt "Create APOSMM scripts..."
110-
python -m ensemble_agent --scripts tests/ --skills file_ops,runner
101+
python ensemble_agent.py --interactive
102+
python ensemble_agent.py --scripts agentic/tests/scripts_with_errors/
103+
python ensemble_agent.py --prompt "Create APOSMM scripts..."
111104
""",
112105
)
113106
parser.add_argument("--interactive", action="store_true", help="Enable interactive chat mode")
114107
parser.add_argument("--scripts", dest="scripts_dir", help="Use existing scripts from directory")
115108
parser.add_argument("--prompt", help="Prompt for script generation")
116109
parser.add_argument("--prompt-file", help="Read prompt from file")
117110
parser.add_argument("--model", default=None, help="LLM model name")
118-
parser.add_argument("--skills", default=DEFAULT_SKILLS, help=f"Comma-separated skills (default: {DEFAULT_SKILLS})")
119111
parser.add_argument("--mcp-server", help="Path to generator mcp_server.mjs")
120112
parser.add_argument("--generate-only", action="store_true", help="Only generate scripts, don't run")
121113
parser.add_argument("--show-prompts", action="store_true", help="Print prompts sent to AI")
@@ -129,7 +121,6 @@ def parse_args(argv=None) -> AgentConfig:
129121
scripts_dir=args.scripts_dir,
130122
prompt=args.prompt,
131123
prompt_file=args.prompt_file,
132-
skills=args.skills,
133124
mcp_server=args.mcp_server,
134125
show_prompts=args.show_prompts,
135126
debug=args.debug or bool(os.environ.get("AGENT_DEBUG")),

ensemble_agent/prompts.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- Don't run scripts unless the user explicitly asks you to run them.
1414
- When reviewing scripts, highlight key configuration: generator bounds/parameters and the objective function.
1515
16-
{skills_context}"""
16+
{reference_context}"""
1717

1818
GENERATOR_RULES = (
1919
"- Only use CreateLibEnsembleScripts ONCE to generate initial scripts. NEVER call it again.\n"
@@ -45,19 +45,19 @@
4545
INTERACTIVE_REVIEW_GOAL = """I have existing scripts. The main script is '{run_script_name}'. Please review them and highlight the key configuration."""
4646

4747

48-
def build_system_prompt(skills, has_generator):
49-
"""Assemble the system prompt from skill fragments."""
48+
def build_system_prompt(providers, has_generator):
49+
"""Assemble the system prompt from provider fragments and reference docs."""
5050
generator_rules = GENERATOR_RULES if has_generator else NO_GENERATOR_RULES
5151

5252
fragments = []
53-
for skill in skills:
54-
frag = skill.get_prompt_fragment()
53+
for p in providers:
54+
frag = p.get_prompt_fragment()
5555
if frag:
5656
fragments.append(frag)
5757

58-
skills_context = "\n\n".join(fragments) if fragments else ""
58+
reference_context = "\n\n".join(fragments) if fragments else ""
5959

6060
return SYSTEM_PROMPT.format(
6161
generator_rules=generator_rules,
62-
skills_context=skills_context,
62+
reference_context=reference_context,
6363
)
File renamed without changes.
File renamed without changes.

ensemble_agent/skills/__init__.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

ensemble_agent/skills/base.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

ensemble_agent/skills/reference_docs.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

ensemble_agent/tools/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Tool provider registry and loader."""
2+
3+
from .base import ToolProvider
4+
from .file_ops import FileOpsTools
5+
from .runner import RunnerTools
6+
from .generator import GeneratorTools
7+
# from .reference_loader import ReferenceLoader
8+
9+
10+
def load_tool_providers(config, archive):
11+
"""Load tool providers based on config.
12+
13+
Always loads: file_ops, runner.
14+
Loads generator only when not using existing scripts.
15+
"""
16+
providers = [
17+
FileOpsTools(config, archive),
18+
RunnerTools(config, archive),
19+
# ReferenceLoader(config, archive),
20+
]
21+
if not config.scripts_dir:
22+
providers.append(GeneratorTools(config, archive))
23+
return providers

0 commit comments

Comments
 (0)