Skip to content

Fix: deserialize model_context in AssistantAgent and SocietyOfMindAgent and CodeExecutorAgent #6337

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

Merged
merged 4 commits into from
Apr 22, 2025

Conversation

SongChiYoung
Copy link
Contributor

Why are these changes needed?

This PR fixes a bug where model_context was either ignored or explicitly set to None during agent deserialization (_from_config) in:

  • AssistantAgent: model_context was serialized but not restored.
  • SocietyOfMindAgent: model_context was neither serialized nor restored.
  • CodeExecutorAgent: model_context was serialized but not restored.

As a result, restoring an agent from its config silently dropped runtime context settings, potentially affecting agent behavior.

This patch:

  • Adds proper serialization/deserialization of model_context using .dump_component() and load_component(...).
  • Ensures round-trip consistency when using declarative agent configs.

Related issue number

Closes #6336

Checks

@ekzhu
Copy link
Collaborator

ekzhu commented Apr 22, 2025

Good catch!

@ekzhu ekzhu enabled auto-merge (squash) April 22, 2025 04:56
@ekzhu ekzhu merged commit b3f3731 into microsoft:main Apr 22, 2025
57 checks passed
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.26%. Comparing base (8a97292) to head (5283a77).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6337      +/-   ##
==========================================
+ Coverage   78.23%   78.26%   +0.02%     
==========================================
  Files         217      217              
  Lines       15666    15669       +3     
==========================================
+ Hits        12257    12263       +6     
+ Misses       3409     3406       -3     
Flag Coverage Δ
unittests 78.26% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

peterj added a commit to kagent-dev/autogen that referenced this pull request Apr 24, 2025
…e0424

* upstream/main:
  Remove `name` field from OpenAI Assistant Message (microsoft#6388)
  Introduce workbench (microsoft#6340)
  TEST/change gpt4, gpt4o serise to gpt4.1nano (microsoft#6375)
  update website version (microsoft#6364)
  Add self-debugging loop to `CodeExecutionAgent` (microsoft#6306)
  Fix: deserialize model_context in AssistantAgent and SocietyOfMindAgent and CodeExecutorAgent (microsoft#6337)
  Add azure ai agent (microsoft#6191)
  Avoid re-registering a message type already registered (microsoft#6354)
  Added support for exposing GPUs to docker code executor (microsoft#6339)
  fix: ollama fails when tools use optional args (microsoft#6343)
  Add an example using autogen-core and FastAPI to create streaming responses (microsoft#6335)
  FEAT: SelectorGroupChat could using stream inner select_prompt (microsoft#6286)
  Add experimental notice to canvas (microsoft#6349)
  DOC: add extentions - autogen-oaiapi and autogen-contextplus (microsoft#6338)
  fix: ensure serialized messages are passed to LLMStreamStartEvent (microsoft#6344)
  Generalize Continuous SystemMessage merging via model_info[“multiple_system_messages”] instead of `startswith("gemini-")` (microsoft#6345)
  Agentchat canvas (microsoft#6215)

Signed-off-by: Peter Jausovec <[email protected]>
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.

Some agents do not deserialize model_context (set to None or Do not serialize too)
2 participants