-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat: add a way to create/store/restore agents in the filesystem #2389
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @maxcoto! Welcome to the elizaOS community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now an elizaOS contributor!
d4c3800
to
42c61a8
Compare
@coderabbitai review |
📝 WalkthroughWalkthroughThe pull request introduces a new configuration option for character storage in a TypeScript application. By adding a Changes
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
agent/src/index.ts (1)
252-264
: Enhance character loading reliability.The
readCharactersFromStorage
function needs improvements:
- Validate JSON files before adding to paths
- Use consistent path handling
- Add logging for better debugging
async function readCharactersFromStorage(characterPaths: string[]): Promise<string[]> { try { const uploadDir = path.join(process.cwd(), "data", "characters"); const fileNames = await fs.promises.readdir(uploadDir); - fileNames.forEach(fileName => { - characterPaths.push(uploadDir + '/' + fileName); + for (const fileName of fileNames) { + if (!fileName.endsWith('.json')) continue; + try { + const filePath = path.join(uploadDir, fileName); + const content = await fs.promises.readFile(filePath, 'utf8'); + JSON.parse(content); // Validate JSON + characterPaths.push(filePath); + elizaLogger.debug(`Added character file: ${fileName}`); + } catch (err) { + elizaLogger.warn(`Skipping invalid character file ${fileName}: ${err.message}`); + } }); } catch (err) { - console.error('Error reading directory:', err); + elizaLogger.error('Error reading characters directory:', err); } return characterPaths; };.env.example (1)
619-621
: Improve configuration documentation placement.Move the
USE_CHARACTER_STORAGE
configuration to the "Server & DB Configurations" section at the top of the file for better visibility, as it's related to core storage functionality.#################################### #### Server & DB Configurations #### #################################### + +# Character Storage Configuration +USE_CHARACTER_STORAGE=false # Enable to store characters set via API in data/characters folder
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.env.example
(1 hunks)agent/src/index.ts
(1 hunks)packages/client-direct/src/api.ts
(6 hunks)
🔇 Additional comments (1)
.env.example (1)
Line range hint
271-273
: Verify character storage integration.Let's verify the character storage feature's integration:
Hi @wtfsayo one of the commits eliminates the feature of loading the stored characters all at once, is that intentional or a side effect of the merge of 'develop' into pr/2389? |
yeah can you push a fix |
I do not know how is your preferred approach to do that. I also see changes that I did not introduce in this PR. Should I rebase and force-push my branch? What do you prefer? |
@wtfsayo |
@coderabbitai final review |
Tip For best results, initiate chat on the files or code changes. @wtfsayo The review reveals that the functionality to load stored characters all at once is indeed missing from the current implementation. The code needs to be fixed to:
Since the author asked about the process, they should:
Would you like me to open a GitHub issue to track this requirement? ╭──────────────────╮ 🔗 Analysis chain🏁 Scripts executedThe following scripts were executed for the analysis: Script:
Length of output: 13728 Script:
Length of output: 47724 |
yeah try that otherwise open new PR, kinda weird why that would happen |
Head branch was pushed to by a user without write access
@wtfsayo after I rebased everything looks correct. Let's keep this PR. |
* upstream/develop: test configuration and tests for client-lens (elizaOS#2534) chore(attempt): optimize pnpm cache configuration (elizaOS#2556) feat: add a way to create/store/restore agents in the filesystem (elizaOS#2389) chore: optimize pnpm cache configuration (elizaOS#2555) chore: remove cleanup step from integration tests workflow (elizaOS#2553) feat: Add more actions to Abstract Plugin (elizaOS#2531) feat: add anthropic image provider for vision (elizaOS#2524) feat: improve integrationtests workflow caching (elizaOS#2551) feat: Updated READ.me file with pre-requisites to enable telegram bot (elizaOS#2547) feat(plugin-devin): implement client-agnostic Devin plugin (elizaOS#2549) use generateObject handle undefined env variable feat:add plugin-lightning (elizaOS#2429)
Relates to
No Issue.
Risks
As it is using a env variable to enable/disable the feature, there are no risks involved.
Background
What does this PR do?
If USE_CHARACTER_STORAGE is enabled in the .env:
It stores a json file at agents/data/characters when calling /agents/00000000-0000-0000-0000-000000000000/set (or any non-existing UUID) in the client-direct.
Later on when the server restarts it will be loaded back again by the loadCharacters function.
What kind of change is this?
Features (non-breaking change which adds functionality)
Why are we doing this? Any context or related work?
This allows to have a server running accepting new characters that are stored and not lost if the server restarts for a reason.
Documentation changes needed?
My changes do not require a change to the project documentation.
Testing
Where should a reviewer start?
Start Eliza as usual.
Detailed testing steps
As anon/admin
Discord username
max0x90