Skip to content

Conversation

@maksymbuleshnyi
Copy link
Contributor

@maksymbuleshnyi maksymbuleshnyi commented Oct 22, 2025

Important

Adds ContextManagerTool for automatic context management in agents, enabling summarization and context compression.

  • Behavior:
    • Adds ContextManagerTool to agent.py for automatic context management when summarization is enabled.
    • Removes update_system_message() from agent.py.
    • Modifies summarize_history() in agent.py to remove history_offset parameter.
  • Tools:
    • Introduces ContextManagerTool in context_manager.py for compressing message history into a summary.
    • Implements _apply_context_manager_tool_effect() in context_manager.py to apply context changes.
  • Configuration:
    • Updates agent_file_storage.yaml to enable summarization and increase max_loops to 15.
    • Updates agent_deep_scraping.py to use ScaleSerpTool and E2BInterpreterTool with summarization enabled.
  • Misc:
    • Adds ContextManagerTool import to __init__.py in tools package.

This description was created by Ellipsis for e5e5a19. You can customize this summary. It will automatically update as commits are pushed.

@maksymbuleshnyi maksymbuleshnyi requested a review from a team as a code owner October 22, 2025 09:00
@maksymbuleshnyi maksymbuleshnyi marked this pull request as draft October 22, 2025 09:00
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to c20256a in 2 minutes and 28 seconds. Click for details.
  • Reviewed 314 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. dynamiq/nodes/agents/agent.py:778
  • Draft comment:
    Consider re-raising the exception (or handling it more explicitly) in _ensure_context_manager_tool instead of only logging the error, to avoid silent failures.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This is a model validator that runs during initialization. The current code swallows all exceptions and only logs them, which could hide serious issues. However, this appears to be an optional feature (adding a context manager tool) that shouldn't prevent the entire object from being created. The code is defensive by catching exceptions and continuing. Re-raising could break object initialization unnecessarily. I may be underestimating the importance of the ContextManagerTool. If it's critical for summarization to work properly, then silently failing could lead to subtle bugs later. Looking at the code more carefully, this is a best-effort attempt to add a convenience tool. The summarization_config.enabled check suggests this is an optional feature. Failing silently is appropriate here since it's not critical functionality. The current error handling is appropriate for this optional initialization code. Re-raising would be too aggressive and could break initialization unnecessarily.
2. dynamiq/nodes/agents/agent.py:1099
  • Draft comment:
    The try and except blocks in _apply_context_manager_tool_effect contain duplicate code. Consider refactoring to avoid repetition.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. examples/use_cases/agents_use_cases/agent_deep_scraping.py:32
  • Draft comment:
    Ensure that the new tool configuration (ScaleSerpTool and E2BInterpreterTool) is fully compatible with the agent's XML inference mode and LLM setup.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_PBNiSPTN7o78ilSm

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@github-actions
Copy link

github-actions bot commented Oct 22, 2025

Coverage

Coverage Report •
FileStmtsMissCoverMissing
dynamiq/nodes/agents
   agent.py66621567%761, 766, 775–776, 778–780, 794, 836–837, 863, 919, 933, 939–941, 943–946, 948–949, 951–953, 955–956, 960–961, 963, 989, 991, 1015–1017, 1019–1023, 1027, 1029, 1031, 1035, 1041, 1043–1044, 1050–1053, 1058–1061, 1063–1064, 1068–1069, 1072, 1074, 1076–1077, 1172–1173, 1196, 1205, 1211, 1244, 1246–1250, 1254, 1265–1267, 1270, 1284–1285, 1296, 1306, 1317, 1354–1355, 1364, 1373, 1391–1393, 1398–1400, 1402–1404, 1410–1412, 1436, 1471–1474, 1482, 1494, 1496–1497, 1502, 1527, 1529–1530, 1533, 1540, 1584, 1597, 1603, 1617–1618, 1621, 1629, 1657–1659, 1705–1707, 1724, 1775–1776, 1778, 1781–1782, 1784–1785, 1787–1788, 1790–1792, 1794–1795, 1797–1798, 1801–1802, 1804–1806, 1808–1809, 1811–1814, 1816, 1822–1826, 1828, 1855, 1858, 1882, 1896–1897, 1910, 1925–1931, 1937, 1939–1948, 1950–1951, 1956–1964, 1977, 2003–2006, 2030–2031, 2050, 2058–2060, 2071, 2108–2111, 2143
   base.py61219168%211, 217, 319–321, 336, 344, 347, 456–457, 459–460, 501, 503, 519, 523, 551, 568, 570, 572, 600, 628, 631, 648–653, 672–673, 704, 715–716, 796, 807, 831–834, 836, 838–840, 842–843, 850, 852–853, 857–859, 865, 869–875, 877–878, 896, 898, 906–908, 915–917, 920, 937, 945–948, 952–954, 965, 972–974, 977–978, 983–985, 988–989, 1004–1007, 1009–1011, 1029–1031, 1033, 1054–1059, 1061–1063, 1070–1071, 1073–1078, 1080–1083, 1085, 1092–1093, 1095, 1097–1098, 1111–1119, 1121–1122, 1124, 1131–1136, 1143, 1145, 1147, 1222–1224, 1229–1230, 1246–1247, 1251, 1264, 1268, 1274, 1276–1277, 1279–1280, 1282–1285, 1287, 1289, 1291–1294, 1296, 1299, 1301, 1305–1306, 1308, 1312–1313, 1315, 1319–1322, 1329, 1336–1338
dynamiq/nodes/tools
   __init__.py160100% 
   context_manager.py673547%116–119, 123, 128, 131–133, 136–137, 140, 142, 149, 151–152, 154, 170–172, 174, 176–178, 180–181, 183, 185, 195–199, 201–202
TOTAL18220585667% 

Tests Skipped Failures Errors Time
956 35 💤 0 ❌ 0 🔥 3m 33s ⏱️

@maksymbuleshnyi
Copy link
Contributor Author

Screenshot 2025-10-27 at 16 26 33

Example of trace

@maksymbuleshnyi maksymbuleshnyi marked this pull request as ready for review October 27, 2025 14:30
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to 491fe6c in 3 minutes and 1 seconds. Click for details.
  • Reviewed 314 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. dynamiq/nodes/agents/agent.py:770
  • Draft comment:
    Consider verifying that the automatic addition of ContextManagerTool in _ensure_context_manager_tool uses a robust check (e.g., by tool name or unique identifier) to avoid duplicates if the tool already exists.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50% None
2. examples/use_cases/agents_use_cases/agent_deep_scraping.py:32
  • Draft comment:
    Ensure that the new automatic context management workflow integrates well with the agent’s configuration, especially with summarization_config and file_store settings.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50% None
3. examples/use_cases/agents_use_cases/agent_deep_scraping.py:12
  • Draft comment:
    Typo: The multi-line string for AGENT_ROLE appears to be missing its closing triple quotes. Please add the closing triple quotes to complete the string.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_STTJLmG8A9HCeDqi

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed 33504dc in 58 seconds. Click for details.
  • Reviewed 30 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. dynamiq/nodes/tools/context_manager.py:22
  • Draft comment:
    Added 'History to compress:' and '{history}' in prompt template. Ensure downstream formatting and LLM output integration uses the new placeholder.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. dynamiq/nodes/tools/context_manager.py:94
  • Draft comment:
    Improved string concatenation with added spaces in tool description. Verify the formatting meets design expectations.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_5xFqlG7BGVnkADVW

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

olbychos

This comment was marked as resolved.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed a5ea310 in 1 minute and 19 seconds. Click for details.
  • Reviewed 103 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. dynamiq/nodes/agents/agent.py:1018
  • Draft comment:
    The 'history_offset' parameter has been removed from summarize_history in favor of using the internal _history_offset attribute. Please update the docstring and any API docs accordingly to reflect this change.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to update documentation, which is not allowed according to the rules. The comment is not making a specific code suggestion or pointing out a potential issue with the code itself.
2. dynamiq/nodes/agents/agent.py:1122
  • Draft comment:
    Assigning '_history_offset' alongside summary_offset (i.e. 'summary_offset = self._history_offset = len(self._prompt.messages)') nicely encapsulates context management. Consider verifying that this state resets appropriately between separate runs.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the author to verify the behavior of the code, which violates the rule against asking the author to confirm or ensure behavior. It does not provide a specific suggestion or point out a clear issue.
3. dynamiq/nodes/agents/base.py:389
  • Draft comment:
    The addition of the PrivateAttr _history_offset with a default of 2 to represent the offset for conversation history is a clear improvement. Ensure that its description and default value meet all use case needs, and consider whether this offset should be configurable from outside as needed.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 20% <= threshold 50% The comment is asking the PR author to ensure that the description and default value meet all use case needs, which is against the rules. It also suggests considering configurability, which is a valid suggestion. However, the primary focus of the comment is on ensuring and considering, which violates the rules.

Workflow ID: wflow_QcFPctio7yTDH57U

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed e5e5a19 in 1 minute and 12 seconds. Click for details.
  • Reviewed 15 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. dynamiq/nodes/agents/base.py:390
  • Draft comment:
    Changing the verbose description to an inline comment is fine if the description metadata isn’t used by PrivateAttr. If documentation for introspection is needed, consider a short docstring instead.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_gmkKZJ8oyUUN1ZvS

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@maksymbuleshnyi maksymbuleshnyi merged commit ba9333c into main Oct 28, 2025
8 checks passed
@maksymbuleshnyi maksymbuleshnyi deleted the feat/agent-context-manager branch October 28, 2025 16:34
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.

4 participants