-
Notifications
You must be signed in to change notification settings - Fork 109
fix: preserve multi-turn history in Strands ConversationTurn #454
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
tests/bedrock_agentcore/evaluation/span_to_adot_serializer/conftest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| """Shared fixtures for span_to_adot_serializer tests.""" | ||
|
|
||
| from unittest.mock import Mock | ||
|
|
||
| import pytest | ||
|
|
||
| from bedrock_agentcore.evaluation.span_to_adot_serializer.adot_models import ( | ||
| ResourceInfo, | ||
| SpanMetadata, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_span_context(): | ||
| """Create a mock span context.""" | ||
| context = Mock() | ||
| context.trace_id = 0x1234567890ABCDEF1234567890ABCDEF | ||
| context.span_id = 0x1234567890ABCDEF | ||
| context.trace_flags = 1 | ||
| return context | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_resource(): | ||
| """Create a mock resource.""" | ||
| resource = Mock() | ||
| resource.attributes = {"service.name": "test-service"} | ||
| return resource | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_instrumentation_scope(): | ||
| """Create a mock instrumentation scope.""" | ||
| scope = Mock() | ||
| scope.name = "strands.agent" | ||
| scope.version = "1.0.0" | ||
| return scope | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_status(): | ||
| """Create a mock status.""" | ||
| status = Mock() | ||
| status.status_code = Mock() | ||
| status.status_code.__str__ = Mock(return_value="StatusCode.OK") | ||
| return status | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_span(mock_span_context, mock_resource, mock_instrumentation_scope, mock_status): | ||
| """Create a mock OTel span.""" | ||
| span = Mock() | ||
| span.context = mock_span_context | ||
| span.resource = mock_resource | ||
| span.instrumentation_scope = mock_instrumentation_scope | ||
| span.status = mock_status | ||
| span.parent = None | ||
| span.name = "test-span" | ||
| span.start_time = 1000000000 | ||
| span.end_time = 2000000000 | ||
| span.kind = Mock() | ||
| span.kind.__str__ = Mock(return_value="SpanKind.INTERNAL") | ||
| span.attributes = {"gen_ai.operation.name": "chat"} | ||
| span.events = [] | ||
| return span | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_event(): | ||
| """Create a mock span event factory.""" | ||
|
|
||
| def _create_event(name, attributes): | ||
| event = Mock() | ||
| event.name = name | ||
| event.attributes = attributes | ||
| return event | ||
|
|
||
| return _create_event | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def span_metadata(): | ||
| """Create test SpanMetadata.""" | ||
| return SpanMetadata( | ||
| trace_id="1234567890abcdef1234567890abcdef", | ||
| span_id="1234567890abcdef", | ||
| parent_span_id=None, | ||
| name="test-span", | ||
| start_time=1000000000, | ||
| end_time=2000000000, | ||
| duration=1000000000, | ||
| kind="INTERNAL", | ||
| flags=1, | ||
| status_code="OK", | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def resource_info(): | ||
| """Create test ResourceInfo.""" | ||
| return ResourceInfo( | ||
| resource_attributes={"service.name": "test-service"}, | ||
| scope_name="strands.agent", | ||
| scope_version="1.0.0", | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
if content:silently drops empty events. The old scalar path had different behavior —user_message = ""would fail the outerif user_messagegate and reject the whole turn. Now empty events are skipped individually. If the intent is to drop empty content, add a log line so it's visible.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.
Added
logger.debug(...)on all three empty-content skip paths (user, assistant, tool). The outer-gate semantics are also restored — a parse that yields only an empty user event now fails the gate (has_user_inputrequires a non-emptyinput_messagesentry with role=user), matching the oldif user_messagebehavior.