bee-agent-framework icon indicating copy to clipboard operation
bee-agent-framework copied to clipboard

feat(workflows): preserve agent metadata in workflow step

Open starpit opened this issue 9 months ago • 3 comments

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

Code quality checks

  • [x] Linting passes: Python poe lint or poe lint --fix / TypeScript yarn lint or yarn lint:fix
  • [x] Formatting is applied: Python poe format or poe format --fix / TypeScript: yarn format or yarn format:fix
  • [ ] Static type checks pass: Python poe type-check

Testing

  • [x] Unit tests pass: Python poe test --type unit / TypeScript yarn 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

starpit avatar Mar 22 '25 22:03 starpit

Hello @starpit. If I look at https://github.com/i-am-bee/beeai-framework/pull/641 is this PR still needed?

Tomas2D avatar Mar 24 '25 08:03 Tomas2D

Hello @starpit. If I look at #641 is this PR still needed?

Thanks for the review.

  1. If the plan is not to deprecate the other form, I think the answer is yes, this PR is still needed.
  2. 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 defaults show up in the pickle. Not sure how the agent name property would be specified, either. In addition, ChatModel is not serializable in its current form, so without this PR, that information is also lost.

starpit avatar Mar 24 '25 10:03 starpit

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

starpit avatar Mar 26 '25 14:03 starpit

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.

Tomas2D avatar Jun 12 '25 12:06 Tomas2D