feat(workflows): preserve agent metadata in workflow step
Which issue(s) does this pull-request address?
When jsonpickling a workflow, all of the information that describes the agents is lost, due to it being hidden behind a closure. This preserves this information in a pickle-able form. I had to extend the existing AgentMeta because it does not capture the ChatModel or instructions information. I did this in AgentMetaDetail, a subclass of AgentMeta.
Closes: #
Description
Checklist
General
- [x] I have read the appropriate contributor guide: Python / TypeScript
- [x] I have signed off on my commit: Python instructions / TypeScript instructions
- [x] Commit messages and PR title follow conventional commits
- [x] Appropriate label(s) added to PR:
Pythonfor Python changes,TypeScriptfor TypeScript changes
Code quality checks
- [x] Linting passes: Python
poe lintorpoe lint --fix/ TypeScriptyarn lintoryarn lint:fix - [x] Formatting is applied: Python
poe formatorpoe format --fix/ TypeScript:yarn formatoryarn format:fix - [ ] Static type checks pass: Python
poe type-check
Testing
- [x] Unit tests pass: Python
poe test --type unit/ TypeScriptyarn test:unit - [ ] E2E tests pass: Python
poe test --type e2e/ TypeScript:yarn test:e2e - [ ] Integration tests pass: Python
poe test --type integration - [ ] Tests are included (for bug fixes or new features)
Documentation
- [ ] Documentation is updated
- [ ] Embedme embeds code examples in docs. To update after edits, run: Python
poe docs --type build
Hello @starpit. If I look at https://github.com/i-am-bee/beeai-framework/pull/641 is this PR still needed?
Hello @starpit. If I look at #641 is this PR still needed?
Thanks for the review.
- If the plan is not to deprecate the other form, I think the answer is yes, this PR is still needed.
- I tried the example from #641 which passes in an agent instance, and then jsonpickled the workflow, and it was missing even more information. So... if anything, I would say that #641 mandates that this PR do more not less. For example, none of the template
defaultsshow up in the pickle. Not sure how the agentnameproperty would be specified, either. In addition, ChatModel is not serializable in its current form, so without this PR, that information is also lost.
the over-arching goal here is to allow pickling of a workflow. i have consolidated the work necessary on this branch: https://github.com/i-am-bee/beeai-framework/compare/main...starpit:nick-meta-combo?expand=1
We recently added GlobalTrajectoryMiddleware(), which logs intermediate steps, and therefore, this should not be needed anymore. If you don't like the way a certain tool gets printed, you can add to_json_safe() -> Any method to override the behaviour.