Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix plan argument for goose session start #424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ThinTim
Copy link

@ThinTim ThinTim commented Dec 5, 2024

Updates arguments for goose session start to match the behavior of goose session planned, to fix issue where goose session start could only accept YAML-formatted plans without jinja templating, breaking the example commands in the docs.

Updates arguments for `goose session start` to match the behavior of
`goose session planned`, to fix issue where `goose session start` could
only accept YAML-formatted plans without jinja templating, breaking the
example commands in the docs.
@ThinTim ThinTim changed the title Fix plan argument for goose session start fix: Fix plan argument for goose session start Dec 5, 2024
@reproduce-bot
Copy link

The following script was generated by AI Agent to reproduce the bug in this issue:

# goose/reproduce.py
import click
from click.testing import CliRunner
from goose.cli.main import session_start
from ruamel.yaml import YAML
import jinja2

def test_session_start_with_jinja_template():
    runner = CliRunner()
    
    # Create a sample plan with jinja templating
    plan_content = """
    tasks:
      - Task 1: "{{ variable1 }}"
      - Task 2: "{{ variable2 }}"
    kickoff_message: "Starting plan with jinja templating"
    """
    
    # Render the plan with jinja2
    template = jinja2.Template(plan_content)
    rendered_plan = template.render(variable1="Test Variable 1", variable2="Test Variable 2")
    
    # Write the rendered plan to a temporary file
    plan_path = "temp_plan.yml"
    with open(plan_path, "w") as f:
        f.write(rendered_plan)
    
    # Invoke the CLI command `goose session start` with the rendered plan
    result = runner.invoke(session_start, ["--profile", "default", "--plan", plan_path])
    
    # Check if the session started successfully
    try:
        assert result.exit_code == 0, f"Expected exit code 0 but got {result.exit_code}"
        assert "Starting plan with jinja templating" in result.output, "Kickoff message not found in output"
        assert "Task 1: Test Variable 1" in result.output, "First task not found in output"
        assert "Task 2: Test Variable 2" in result.output, "Second task not found in output"
        print("Test passed successfully with no errors!")
    except AssertionError as e:
        raise AssertionError(f"Test failed as expected with error: {e}")

if __name__ == "__main__":
    test_session_start_with_jinja_template()

How to run:

python3 goose/reproduce.py

Expected Result:

Traceback (most recent call last):
  File "goose/reproduce.py", line 32, in test_session_start_with_jinja_template
    assert result.exit_code == 0, f"Expected exit code 0 but got {result.exit_code}"
AssertionError: Expected exit code 0 but got 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "goose/reproduce.py", line 41, in <module>
    test_session_start_with_jinja_template()
  File "goose/reproduce.py", line 38, in test_session_start_with_jinja_template
    raise AssertionError(f"Test failed as expected with error: {e}")
AssertionError: Test failed as expected with error: Expected exit code 0 but got 1

Please review the usefulness of this reproduction script. We hope this script is helpful for maintainers to reproduce, localize and fix the issue, and has the potential to enhance the test suite.

Note that the script is generated by large language models. Use the generated code with cautions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants