diff --git a/maestro/src/agents/meta_agent/README.md b/maestro/src/agents/meta_agent/README.md index 6e80e0f..c9e4a55 100644 --- a/maestro/src/agents/meta_agent/README.md +++ b/maestro/src/agents/meta_agent/README.md @@ -1,6 +1,6 @@ # META AGENT -Our goal is to create an agent that can create the relevant agents/workflow.yaml files necessary for you to delegate your tasks. +Our goal is to create an agent that can create the relevant agents/workflow.yaml files necessary for you to delegate your tasks. Currently, because we are process of generalizing our prompts, currently the workflow is split into 2 files, `workflow_agent.yaml` and `workflow_workflow.yaml`. ## Validating/Creating Agents/Workflow files @@ -13,7 +13,7 @@ Validating the YAML file adheres to the schema: Creating the agents(with the ability to manually add tools): `maestro create ./src/agents/meta_agent/agents.yaml` -To run the workflow: +To run the workflow: (Replace `workflow.yaml` with the desired workflow for now) If you already created the agents and enabled the tool: `maestro run None ./src/agents/meta_agent/workflow.yaml` diff --git a/maestro/src/agents/meta_agent/agents.yaml b/maestro/src/agents/meta_agent/agents.yaml index 576a8c7..5838a5c 100644 --- a/maestro/src/agents/meta_agent/agents.yaml +++ b/maestro/src/agents/meta_agent/agents.yaml @@ -162,4 +162,67 @@ spec: **Rules:** - Replace `N` with the number of agents. - Replace `{agent_list}` with a **newline-separated list** of agents. - - Output the formatted text exactly as structured." \ No newline at end of file + - Output the formatted text exactly as structured." + +--- +apiVersion: maestro/v1alpha1 +kind: Agent +metadata: + name: Format Workflow Agent + labels: + app: meta-agent +spec: + model: llama3.1 + description: "Formats a structured prompt by replacing placeholders with user-defined values." + instructions: | + You are a **workflow prompt formatter agent**. Your job is to format a structured workflow as given below. + + **Your task:** + - Replace `{agent_list}` with a newline-separated list of user-defined agents. + - Replace `{num_agents}` with the total number of agents. + + **Template (with placeholders):** + START HERE + ``` + Build a structured workflow using the `workflow_schema` tool as a reference. + + I have {num_agents} agents in agents.yaml: + {agent_list} + + Requirements: + + Ensure the workflow follows the `workflow.schema.json` format. + Each step must: + Reference a valid agent from agents.yaml. + Have a name that describes its function. + The final output should be a valid structured workflow in YAML format, please make it easily readable in a code block. + ``` + + **Example User Input:** + ``` + number of agents: 2 + agent1: weather_fetcher โ€“ Retrieves weather data for a given location using OpenMeteo. + agent2: temperature_comparator โ€“ Compares the retrieved temperature with historical averages using OpenMeteo. + ``` + + **Expected Output:** + ``` + Build a structured workflow using the `workflow_schema` tool as a reference. + + I have 2 agents in agents.yaml: + weather_fetcher โ€“ Retrieves weather data for a given location using OpenMeteo. + temperature_comparator โ€“ Compares the retrieved temperature with historical averages using OpenMeteo. + + Requirements: + + Ensure the workflow follows the `workflow.schema.json` format. + Each step must: + Reference a valid agent from agents.yaml. + Have a name that describes its function. + The final output should be a valid structured workflow in YAML format, please make it easily readable in a code block. + ``` + + **Rules:** + - Ensure **exact structure formatting**. + - Always replace `{num_agents}` and `{agent_list}` correctly. + - The output **must match the given structure exactly**." \ No newline at end of file diff --git a/maestro/src/agents/meta_agent/test.sh b/maestro/src/agents/meta_agent/test.sh index 326933f..93923b7 100755 --- a/maestro/src/agents/meta_agent/test.sh +++ b/maestro/src/agents/meta_agent/test.sh @@ -7,14 +7,23 @@ echo "๐Ÿ“‚ Running tests for: $META_AGENT_DIR" bash "$(dirname "$0")/doctor.sh" || { echo "โŒ Environment check failed"; exit 1; } +# Find `agents.yaml` (still required) AGENTS_YAML=$(find "$META_AGENT_DIR" -maxdepth 1 -type f -name "agents.yaml") -WORKFLOW_YAML=$(find "$META_AGENT_DIR" -maxdepth 1 -type f -name "workflow.yaml") -if [[ -z "$AGENTS_YAML" || -z "$WORKFLOW_YAML" ]]; then - echo "โŒ Error: Missing agents.yaml or workflow.yaml in $META_AGENT_DIR" +# Find all workflow YAML files dynamically +WORKFLOW_FILES=($(find "$META_AGENT_DIR" -maxdepth 1 -type f -name "workflow*.yaml")) + +if [[ -z "$AGENTS_YAML" ]]; then + echo "โŒ Error: Missing agents.yaml in $META_AGENT_DIR" + exit 1 +fi + +if [[ ${#WORKFLOW_FILES[@]} -eq 0 ]]; then + echo "โŒ Error: No workflow YAML files found in $META_AGENT_DIR" exit 1 fi +# Locate schemas directory SCHEMA_DIR=$(find "$(dirname "$0")/../../.." -type d -name "schemas" -print -quit) if [[ -z "$SCHEMA_DIR" ]]; then @@ -29,13 +38,17 @@ echo "๐Ÿ” Detected schema directory: $SCHEMA_DIR" echo "๐Ÿ” Using schema file: $AGENT_SCHEMA_PATH" echo "๐Ÿ” Using schema file: $WORKFLOW_SCHEMA_PATH" +# Validate agents.yaml echo "๐Ÿ“ Validating $AGENTS_YAML..." poetry run maestro validate "$AGENT_SCHEMA_PATH" "$AGENTS_YAML" || { echo "โŒ Failed to validate agents.yaml!"; exit 1; } -echo "๐Ÿ“ Validating $WORKFLOW_YAML..." -poetry run maestro validate "$WORKFLOW_SCHEMA_PATH" "$WORKFLOW_YAML" || { echo "โŒ Failed to validate workflow.yaml!"; exit 1; } +# Loop through each workflow file and validate/run tests +for WORKFLOW_YAML in "${WORKFLOW_FILES[@]}"; do + echo "๐Ÿ“ Validating $WORKFLOW_YAML..." + poetry run maestro validate "$WORKFLOW_SCHEMA_PATH" "$WORKFLOW_YAML" || { echo "โŒ Failed to validate $WORKFLOW_YAML!"; exit 1; } -echo "๐Ÿงช Running workflow in dry-run mode..." -echo "" | poetry run maestro run --dry-run "$AGENTS_YAML" "$WORKFLOW_YAML" || { echo "โŒ Workflow test failed!"; exit 1; } + echo "๐Ÿงช Running workflow in dry-run mode for $WORKFLOW_YAML..." + echo "" | poetry run maestro run --dry-run "$AGENTS_YAML" "$WORKFLOW_YAML" || { echo "โŒ Workflow test failed for $WORKFLOW_YAML!"; exit 1; } +done -echo "โœ… Workflow tests passed for $META_AGENT_DIR!" +echo "โœ… All workflow tests passed for $META_AGENT_DIR!" diff --git a/maestro/src/agents/meta_agent/workflow.yaml b/maestro/src/agents/meta_agent/workflow.yaml deleted file mode 100644 index ce15528..0000000 --- a/maestro/src/agents/meta_agent/workflow.yaml +++ /dev/null @@ -1,44 +0,0 @@ -apiVersion: maestro/v1alpha1 -kind: Workflow -metadata: - name: meta_agent_workflow - labels: - project: maestro-demo -spec: - template: - metadata: - name: meta_agent_workflow - labels: - project: maestro-demo - agents: - - Format Input Agent - - Create Agent YAML - - Create Workflow YAML - prompt: | - number of agents: 2 - agent1: weather_fetcher โ€“ Retrieves weather data for a given location using OpenMeteo. - agent2: temperature_comparator โ€“ Compares the retrieved temperature with historical averages using OpenMeteo. - steps: - - name: Format Input - agent: Format Input Agent - - name: Create Agent YAML - agent: Create Agent YAML - - name: input - input: - prompt: | - Build a structured workflow using the workflow_schema tool as a reference. - - I have two agents in agents.yaml: - weather_fetcher โ€“ Retrieves weather data for a given location using the OpenMeteo tool. - temperature_comparator โ€“ Compares the retrieved temperature with historical averages using OpenMeteo. - - Requirements: - - Ensure the workflow follows the workflow.schema.json format. - Each step must: - Reference a valid agent from agents.yaml. - Have a name that describes its function. - The final output should be a valid structured workflow in YAML format, please make it easily readble in a code block - template: "{CONNECTOR}" - - name: Create Workflow YAML - agent: Create Workflow YAML \ No newline at end of file diff --git a/maestro/src/agents/meta_agent/workflow_agent.yaml b/maestro/src/agents/meta_agent/workflow_agent.yaml new file mode 100644 index 0000000..9000617 --- /dev/null +++ b/maestro/src/agents/meta_agent/workflow_agent.yaml @@ -0,0 +1,24 @@ +apiVersion: maestro/v1alpha1 +kind: Workflow +metadata: + name: meta_agent_workflow + labels: + project: maestro-demo +spec: + template: + metadata: + name: meta_agent_workflow + labels: + project: maestro-demo + agents: + - Format Input Agent + - Create Agent YAML + prompt: | + number of agents: 2 + agent1: weather_fetcher โ€“ Retrieves weather data for a given location using OpenMeteo tool. + agent2: temperature_comparator โ€“ Compares the retrieved temperature with historical averages using OpenMeteo tool. + steps: + - name: Format Input + agent: Format Input Agent + - name: Create Agent YAML + agent: Create Agent YAML \ No newline at end of file diff --git a/maestro/src/agents/meta_agent/workflow_workflow.yaml b/maestro/src/agents/meta_agent/workflow_workflow.yaml new file mode 100644 index 0000000..8c925ec --- /dev/null +++ b/maestro/src/agents/meta_agent/workflow_workflow.yaml @@ -0,0 +1,24 @@ +apiVersion: maestro/v1alpha1 +kind: Workflow +metadata: + name: meta_agent_workflow + labels: + project: maestro-demo +spec: + template: + metadata: + name: meta_agent_workflow + labels: + project: maestro-demo + agents: + - Format Workflow Agent + - Create Workflow YAML + prompt: | + number of agents: 2 + agent1: weather_fetcher โ€“ Retrieves weather data for a given location using OpenMeteo tool. + agent2: temperature_comparator โ€“ Compares the retrieved temperature with historical averages using OpenMeteo tool. + steps: + - name: Format Workflow Agent + agent: Format Workflow Agent + - name: Create Workflow YAML + agent: Create Workflow YAML \ No newline at end of file diff --git a/maestro/tools/run-meta-agent.sh b/maestro/tools/run-meta-agent.sh index a78938b..a47300d 100755 --- a/maestro/tools/run-meta-agent.sh +++ b/maestro/tools/run-meta-agent.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "๐Ÿš€ Running all meta-agent tests in CI..." +echo "๐Ÿš€ Running all meta-agent workflow tests in CI..." REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" echo "๐Ÿ“‚ Running from: $REPO_ROOT" @@ -35,14 +35,14 @@ echo "๐Ÿฉบ Running doctor.sh for meta_agent..." cd "$META_AGENT_DIR" bash doctor.sh || { echo "โŒ doctor.sh failed"; exit 1; } -# Run test.sh for the meta_agent directory -echo "๐Ÿงช Running test.sh for meta_agent..." +# Run test.sh only once with the directory, instead of looping over workflow files +echo "๐Ÿงช Running test.sh for meta_agent directory..." bash "$META_AGENT_DIR/test.sh" "$META_AGENT_DIR" || { echo "โŒ test.sh failed"; exit 1; } ((TEST_COUNT++)) if [[ "$TEST_COUNT" -gt 0 ]]; then - echo "โœ… All meta-agent tests completed successfully!" + echo "โœ… All meta-agent workflow tests completed successfully!" else - echo "โŒ Error: No tests were executed!" + echo "โŒ Error: No workflow tests were executed!" exit 1 fi