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: cleanup failed agent creation #726

Merged
merged 1 commit into from
Dec 29, 2023
Merged

Conversation

cpacker
Copy link
Collaborator

@cpacker cpacker commented Dec 28, 2023

Close #709

Please describe the purpose of this pull request.

From Discord:

When running memgpt run --preset foo-system --persona foo --agent foo --human bar for the first time, if the setup fails (in my case because i hadn't deployed the preset files yet), the new agent dir and config is created, but not the state file.
When I run it again, startup fails due to a missing agent state file.
Deleting the agent dir allows the agent to be created successfully

Reproducing the error:

memgpt run --preset banana
? Would you like to select an existing agent? No

🧬 Creating new agent...
->  🤖 Using persona profile 'sam_pov'
->  🧑 Using human profile 'basic'
Failed to create agent from provided information:
Preset 'banana.yaml' not found
$ ls -lrt ~/.memgpt/agents
agent_1
agent_2
$ ls -lrt ~/.memgpt/agents/agent_2
config.json

How to test

Run memgpt run --preset banana and make sure no new directory is created (ie it's created, then deleted).

Have you tested this PR?

Yes:

% ls -rt ~/.memgpt/agents
agent_1
% memgpt run --preset banana

? Would you like to select an existing agent? No

🧬 Creating new agent...
->  🤖 Using persona profile 'sam_pov'
->  🧑 Using human profile 'basic'
Failed to create agent from provided information:
Preset 'banana.yaml' not found
% ls -rt ~/.memgpt/agents   
agent_1

@cpacker cpacker requested a review from sarahwooders December 28, 2023 06:49
@@ -466,6 +467,21 @@ def run(
)
except ValueError as e:
typer.secho(f"Failed to create agent from provided information:\n{e}", fg=typer.colors.RED)
# Delete the directory of the failed agent
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarahwooders not sure if this is too dangerous (rm -r) - alternatively we could move to /tmp instead of deleting?

@cpacker cpacker merged commit 4de0e8b into main Dec 29, 2023
4 checks passed
@cpacker cpacker deleted the clean-up-failed-agent-create branch December 30, 2023 07:50
norton120 pushed a commit to norton120/MemGPT that referenced this pull request Feb 15, 2024
mattzh72 pushed a commit that referenced this pull request Oct 9, 2024
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.

control-C instead of exiting a chat session with /exit it corrupts the agent
1 participant