Skip to content
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: update tool parameters propagation #167

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

olbychos
Copy link
Contributor

@olbychos olbychos commented Feb 26, 2025

Important

Add tool_params to AgentInputSchema for flexible tool parameter application, with priority handling and a new example script.

  • Behavior:
    • Add tool_params field to AgentInputSchema in base.py for passing parameters to tools without LLM exposure.
    • Implement _apply_parameters() in Agent to apply parameters from tool_params with priority: global, tool name, tool ID.
    • Update _run_tool() in Agent to use merged input with applied parameters.
  • Utilities:
    • Add deep_merge() function to Node in node.py for merging dictionaries.
  • Examples:
    • New example use_agents_hidden_params.py demonstrates setting up a ReActAgent with API tools and using tool_params for authorization headers.

This description was created by Ellipsis for e4f1200. It will automatically update as commits are pushed.

@olbychos olbychos self-assigned this Feb 26, 2025
Copy link

github-actions bot commented Feb 26, 2025

Coverage

Coverage Report •
FileStmtsMissCoverMissing
dynamiq/nodes
   node.py4269777%257, 268, 283, 288–289, 293–294, 317–318, 320, 335, 358, 389, 391, 398–399, 491, 498, 500, 502, 506, 517–518, 536–539, 542–545, 547, 552, 554–556, 560, 563–564, 569, 591–593, 598, 727–729, 801–807, 809–814, 818, 820, 822, 842–843, 862–863, 882–883, 904–905, 927–928, 947–948, 967–968, 985–986, 1005–1006, 1020, 1038, 1046, 1049, 1067–1069, 1141–1144, 1146, 1148, 1167, 1191, 1197
dynamiq/nodes/agents
   base.py36511369%139, 205, 218, 221–223, 227–229, 251, 255, 259, 281, 283, 316–317, 320, 344, 346, 363–364, 370–371, 374–375, 395–396, 400–401, 427–429, 433–438, 443, 448, 453, 457, 462, 480, 489–490, 494–495, 499–501, 507, 511–516, 518–520, 524–526, 528–529, 531–535, 538–540, 543–546, 549–551, 553–554, 556, 562–566, 568–569, 589–594, 600, 605, 637, 642, 672, 706, 708–710, 714, 718–721, 724, 733
   react.py27021620%245, 262, 272–275, 277–280, 282, 286–287, 291–294, 296–300, 317, 319, 323–325, 329, 335–336, 338, 342–343, 348–352, 354–355, 357–360, 371, 374, 398–400, 407, 409, 411–415, 417, 419–420, 428–429, 431–433, 435, 439, 441–446, 454, 456–457, 459–460, 469–471, 473–475, 479–480, 484, 486, 488–493, 500, 502–503, 505, 507–508, 517–519, 521–523, 525–527, 529–533, 540, 542–543, 545–546, 555–557, 559–560, 562–567, 574, 576–577, 579–580, 589, 591–592, 594–596, 598–599, 601–603, 612, 620, 622–624, 626–627, 632, 634–636, 643, 649–652, 654, 658–659, 663–669, 671, 673–674, 676–677, 680, 682, 709, 715–716, 718, 721–723, 725–726, 728–729, 732, 738–739, 743–747, 749, 773, 777, 779, 785–789, 791–799, 801
dynamiq/nodes/tools
   http_api_call.py761382%36–42, 44, 103, 117, 124, 133–134
TOTAL11981366569% 

Tests Skipped Failures Errors Time
416 0 💤 0 ❌ 0 🔥 46.748s ⏱️

@olbychos olbychos changed the title feat: add tool params passing feat: update tool parameters propagation Feb 28, 2025
@olbychos olbychos marked this pull request as ready for review February 28, 2025 08:57
@olbychos olbychos requested a review from a team as a code owner February 28, 2025 08:57
Copy link

@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.

❌ Changes requested. Reviewed everything up to 64a61a3 in 2 minutes and 45 seconds

More details
  • Looked at 254 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 drafted comments based on config settings.
1. dynamiq/nodes/agents/base.py:510
  • Draft comment:
    Consider clarifying the merging logic in _apply_parameters: when both merged_input[key] and the incoming value are dicts, the call to deep_merge may not override primitive values. Ensure that higher‐priority parameters truly override lower ones if needed.
  • 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%
    The comment raises a valid technical concern about the deep merging behavior, but several issues make me lean towards removing it: 1) The deep_merge method isn't shown in the diff or context, so we can't verify if there's actually an issue 2) The comment is speculative ("may not override") rather than pointing to a definite problem 3) The priority order is clearly documented in the code comments (global -> name -> id) 4) The code has debug logging to help trace any merge issues.
    I could be wrong about the severity of the potential deep merge issue - if deep_merge has bugs, it could cause subtle parameter override problems that would be hard to debug.
    While deep merge bugs could be serious, without seeing the deep_merge implementation we can't verify if there's a real issue. The comment is too speculative and would require more context to be actionable.
    Delete the comment because it's speculative and requires more context about deep_merge to be actionable. The code already has clear documentation about parameter priority and debug logging.
2. dynamiq/nodes/agents/base.py:537
  • Draft comment:
    The merging order (global, then tool name, then tool id) is subtle. Add a comment clarifying these priority rules.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. dynamiq/nodes/node.py:1129
  • Draft comment:
    deep_merge overwrites non-dict values. Consider if a more robust merge strategy is needed for complex nested structures.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
4. dynamiq/nodes/tools/http_api_call.py:123
  • Draft comment:
    The check using 'self.model_fields_set' for response_type fallback depends on pydantic internals. Verify compatibility with your pydantic version.
  • 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.
5. dynamiq/nodes/agents/base.py:617
  • Draft comment:
    Typo: The variable name 'formated_prompt_blocks' appears to be misspelled. Consider renaming it to 'formatted_prompt_blocks' for clarity.
  • 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.
6. dynamiq/nodes/agents/react.py:84
  • Draft comment:
    Typographical error: In the REACT_BLOCK_INSTRUCTIONS block, 'strickly adhere to it' should be corrected to 'strictly adhere to it'.
  • 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.
7. dynamiq/nodes/agents/react.py:120
  • Draft comment:
    Typographical error: In the REACT_BLOCK_INSTRUCTIONS_STRUCTURED_OUTPUT block, 'Structure you responses in JSON format.' should be corrected to 'Structure your responses in JSON format.'
  • 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.
8. dynamiq/nodes/node.py:341
  • Draft comment:
    Typo in the docstring: 'if it is is provided' should be corrected to 'if it is provided'.
  • 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.
9. dynamiq/nodes/node.py:313
  • Draft comment:
    Typo in the comment: 'if the function accepts the at least "inputs" and "outputs"' should be changed to 'if the function accepts at least "inputs" and "outputs" parameters' (remove the extra 'the').
  • 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.
10. dynamiq/nodes/tools/http_api_call.py:53
  • Draft comment:
    Typographical error: In the description of the 'connection' attribute, there is a missing space after the period. It currently reads '...http requests.A new connection...' and should be corrected to '...http requests. A new connection...'
  • 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_rugefUrJN2Pxpjsk


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@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.

👍 Looks good to me! Incremental review on e4f1200 in 1 minute and 25 seconds

More details
  • Looked at 1679 lines of code in 14 files
  • Skipped 0 files when reviewing.
  • Skipped posting 16 drafted comments based on config settings.
1. tests/integration/evaluations/metrics/test_answer_correctness.py:33
  • Draft comment:
    The use of multiple side_effect lists for extraction and classification is clear. Consider adding inline comments or helper functions to document the order of calls to improve maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50%
    None
2. tests/integration/flows/test_flow.py:60
  • Draft comment:
    Good use of fixtures and tracing validations. Ensure that file encoding (BytesIO) and bytes decoding are robust—especially when handling non-UTF-8 content.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50%
    None
3. tests/integration/flows/test_flow.py:252
  • Draft comment:
    Test assertions regarding tracing and dependency mapping are comprehensive. Verify that expected metadata keys (e.g., 'host', 'workflow id') always exist; if possible, add defensive checks or more informative error messages.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50%
    None
4. pyproject.toml:6
  • Draft comment:
    Versioning and dependency information look consistent. Consider adding a changelog entry referencing the tool parameter propagation update for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 50%
    None
5. dynamiq/nodes/agents/base.py:119
  • Draft comment:
    Nice addition of the 'tool_params' field with proper agent exposure control. Consider adding inline comments to explain the merging priority (global < tool name < tool ID).
  • 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.
6. dynamiq/nodes/agents/base.py:305
  • Draft comment:
    Switching assignment from _prompt_variables['context'] to _prompt_blocks['context'] is a notable change. Ensure this is intended as it affects prompt formatting.
  • 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.
7. dynamiq/nodes/tools/exa_search.py:25
  • Draft comment:
    Input schema parameters now include an 'is_accessible_to_agent' flag, which is good for tool parameter control. Verify that the new parameters align with tool usage in agents.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is asking the PR author to verify alignment, which is against the rules. It doesn't provide a specific suggestion or point out a clear issue.
8. pyproject.toml:7
  • Draft comment:
    Version bumped to 0.11.1; ensure all dependency updates have been properly tested.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is related to dependency changes and asks the author to ensure that all dependency updates have been properly tested. This violates the rule against asking the author to ensure testing and commenting on dependency changes.
9. tests/integration/evaluations/metrics/test_answer_correctness.py:140
  • Draft comment:
    The test expectations for F1 scores seem correctly computed. Ensure the mocked responses align with actual LLM behavior for future robustness.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is asking the PR author to ensure that the mocked responses align with actual LLM behavior, which is a form of asking them to double-check or verify something. This violates the rule against asking the author to ensure or verify things.
10. tests/integration/flows/test_flow.py:124
  • Draft comment:
    Workflow tests now include checks for tracing and input mappings. Review if all expected metadata fields are consistently propagated.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is asking the PR author to review and ensure that all expected metadata fields are consistently propagated. This falls under the category of asking the author to double-check things, which is against the rules.
11. dynamiq/nodes/agents/base.py:55
  • Draft comment:
    Typo in the prompt template: Consider removing the extra 'to' in the phrase "Refer to this as to additional information, not as direct instructions." It should read "Refer to this as additional information, not as direct instructions."
  • Reason this comment was not posted:
    Comment was on unchanged code.
12. dynamiq/nodes/agents/base.py:617
  • Draft comment:
    Typographical error: The variable 'formated_prompt_blocks' is misspelled. It should be 'formatted_prompt_blocks' to maintain correct spelling.
  • 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.
13. dynamiq/nodes/agents/react.py:84
  • Draft comment:
    Typographical error: In the REACT_BLOCK_INSTRUCTIONS string (around line 84), 'strickly adhere to it' should be corrected to 'strictly adhere to it'.
  • 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.
14. dynamiq/nodes/agents/react.py:198
  • Draft comment:
    Typographical error in the description of final_answer_function_schema: The phrase "when if you can answer the initial request or if there is not request at all" is awkward. Consider revising it to 'Function should be called when you can answer the initial request or when there is no request at all.'
  • 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.
15. dynamiq/nodes/tools/exa_search.py:31
  • Draft comment:
    Typographical error: please change 'converted to a Exa query' to 'converted to an Exa query'. This issue can be found in the description for 'use_autoprompt' (line 31) and is repeated in the tool's field description (line 94).
  • Reason this comment was not posted:
    Comment was on unchanged code.
16. dynamiq/prompts/prompts.py:73
  • Draft comment:
    Typo: In the docstring for the format_message method, 'formated copy of message' should be corrected to 'formatted copy of message'.
  • 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_cfj7Ww9fn5iQO4Ky


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -157,6 +166,7 @@ class Agent(Node):

model_config = ConfigDict(arbitrary_types_allowed=True)
input_schema: ClassVar[type[AgentInputSchema]] = AgentInputSchema
_tool_params: dict[str, Any] | None = None
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this parameter has not beed used. Is it needed somewhere?

@@ -1127,6 +1127,26 @@ def merge_and_short_content(inputs: dict, outputs: dict[str, dict]):
self.input_mapping[key] = value
return self

def deep_merge(self, source: dict, destination: dict) -> dict:
Copy link
Contributor

Choose a reason for hiding this comment

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

We could consider adding list concatenation in the deep_merge function. For example, in TavilyInputSchema, several parameters have the list[str] type.

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.

2 participants