-
Notifications
You must be signed in to change notification settings - Fork 186
Fix agent type update #4341
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
Fix agent type update #4341
Conversation
rithin-pullela-aws
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Can you rebase your main with current main? Looks like around 27 commits are pushed
7101c48 to
f208b34
Compare
pyek-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM, thanks for this!
common/src/main/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInput.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
5764e12 to
cfc354a
Compare
|
Thanks for fixing this! |
WalkthroughAdds a new VERSION_3_4_0 constant to support version-aware serialization. Introduces a type field to MLAgentUpdateInput with version-conditional serialization and validation to prevent agent type modifications during updates. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
common/src/test/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInputTest.java (1)
999-1034: Consider adding type field to stream serialization tests.The
testStreamInputOutputWithVersiontest doesn't include thetypefield in the builder, so the version-conditional serialization of the type field (usingVERSION_3_4_0) isn't being explicitly tested. Consider adding.type("flow")to verify round-trip serialization works correctly.@Test public void testStreamInputOutputWithVersion() throws IOException { MLAgentUpdateInput input = MLAgentUpdateInput .builder() .agentId("test-agent-id") .name("test-agent") + .type("flow") .description("test description") .llmModelId("test-model-id") .llmParameters(Map.of("temperature", "0.7")) .memoryType("conversation_index") .memorySessionId("test-session") .memoryWindowSize(10) .appType("rag") .lastUpdateTime(Instant.ofEpochMilli(1234567890)) .tenantId("test-tenant") .build(); // Test with different versions BytesStreamOutput output = new BytesStreamOutput(); input.writeTo(output); StreamInput streamInput = output.bytes().streamInput(); MLAgentUpdateInput parsedInput = new MLAgentUpdateInput(streamInput); assertEquals(input.getAgentId(), parsedInput.getAgentId()); assertEquals(input.getName(), parsedInput.getName()); + assertEquals(input.getType(), parsedInput.getType()); assertEquals(input.getDescription(), parsedInput.getDescription());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
common/src/main/java/org/opensearch/ml/common/CommonValue.java(1 hunks)common/src/main/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInput.java(11 hunks)common/src/test/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInputTest.java(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
common/src/main/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInput.java (1)
common/src/main/java/org/opensearch/ml/common/CommonValue.java (1)
CommonValue(14-150)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: spotless
- GitHub Check: spotless
🔇 Additional comments (10)
common/src/main/java/org/opensearch/ml/common/CommonValue.java (1)
100-100: LGTM!The new version constant follows the established pattern and is correctly placed in sequence after VERSION_3_3_0.
common/src/test/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInputTest.java (2)
390-440: LGTM!Good addition of type field testing in the parsing test. The test properly validates that the type is correctly parsed from JSON input.
964-997: Good test coverage for type validation.The test comprehensively covers all three scenarios:
- Same type update is allowed
- Different type throws
IllegalArgumentExceptionwith correct message- Omitting type preserves the original
common/src/main/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInput.java (7)
11-11: LGTM!Correct import of VERSION_3_4_0 for version-conditional serialization.
55-107: LGTM!The type field is properly declared and integrated into the constructor following the existing patterns in this class.
109-135: LGTM!The version-conditional deserialization is correctly implemented. The type field is only read when the stream version is 3.4.0 or later, maintaining backward compatibility with older nodes.
144-146: LGTM!The type field is correctly serialized to XContent when present.
197-199: LGTM!The version-conditional serialization correctly matches the deserialization logic, ensuring proper backward compatibility during rolling upgrades.
233-346: LGTM!The parsing logic correctly handles the type field following the established pattern for other fields in this method.
348-351: Core fix for the bug - looks correct.This validation properly addresses the issue where agent type updates were silently ignored. The check:
- Allows updates when no type is provided (
type == null)- Allows updates when the same type is provided
- Throws
IllegalArgumentExceptionwhen attempting to change the typeThis provides clear feedback to API callers instead of the previous silent failure behavior.
* Fix agent type update Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Added bwc checks Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Updated version Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> --------- Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> (cherry picked from commit 79cbcfb)
* Fix agent type update Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Added bwc checks Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Updated version Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> --------- Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> (cherry picked from commit 79cbcfb)
* Fix agent type update (#4341) * Fix agent type update Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Added bwc checks Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Updated version Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> --------- Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> (cherry picked from commit 79cbcfb) * Update common/src/main/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInput.java Co-authored-by: Owais Kazi <owaiskazi19@gmail.com> Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Update common/src/main/java/org/opensearch/ml/common/transport/agent/MLAgentUpdateInput.java Co-authored-by: Owais Kazi <owaiskazi19@gmail.com> Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Apply suggestions from code review Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Add version import in MLAgentUpdateInput Signed-off-by: Sicheng Song <sicheng.song@outlook.com> --------- Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> Signed-off-by: Sicheng Song <sicheng.song@outlook.com> Co-authored-by: Owais Kazi <owaiskazi19@gmail.com> Co-authored-by: Sicheng Song <sicheng.song@outlook.com>
Description
Fix agent update
{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "Agent type cannot be updated" } ], "type": "illegal_argument_exception", "reason": "Agent type cannot be updated" }, "status": 400 }Related Issues
Resolves #4340
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.