This repository was archived by the owner on Jan 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
fix issue with session_id #91
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -88,11 +88,21 @@ async def test_handle_agent_request_success(self, mock_request): | |||||||||||||||||||||||||||||||||||
| mock_response.status = 200 | ||||||||||||||||||||||||||||||||||||
| mock_response.content_type = "application/json" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Create a mock span with proper trace_id formatting | ||||||||||||||||||||||||||||||||||||
| mock_span_context = MagicMock() | ||||||||||||||||||||||||||||||||||||
| mock_span_context.trace_id = 12345678901234567890123456789012345678 | ||||||||||||||||||||||||||||||||||||
| mock_span = MagicMock() | ||||||||||||||||||||||||||||||||||||
| mock_span.get_span_context.return_value = mock_span_context | ||||||||||||||||||||||||||||||||||||
| mock_span.is_recording.return_value = True | ||||||||||||||||||||||||||||||||||||
| mock_tracer = MagicMock() | ||||||||||||||||||||||||||||||||||||
| mock_tracer.start_span.return_value.__enter__.return_value = mock_span | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
Comment on lines
+91
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mock the API you actually use: start_as_current_span, not start_span. handle_agent_request uses tracer.start_as_current_span(...). Your mock wires start_span, so the configured span (is_recording, get_span_context) isn’t the one used. Apply this diff: - mock_tracer = MagicMock()
- mock_tracer.start_span.return_value.__enter__.return_value = mock_span
+ mock_tracer = MagicMock(spec=trace.Tracer)
+ mock_tracer.start_as_current_span.return_value.__enter__.return_value = mock_span📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| with ( | ||||||||||||||||||||||||||||||||||||
| patch( | ||||||||||||||||||||||||||||||||||||
| "agentuity.server.trace.get_tracer", return_value=MagicMock() | ||||||||||||||||||||||||||||||||||||
| "agentuity.server.trace.get_tracer", return_value=mock_tracer | ||||||||||||||||||||||||||||||||||||
| ) as mock_get_tracer, | ||||||||||||||||||||||||||||||||||||
| patch("agentuity.server.extract", return_value={}), | ||||||||||||||||||||||||||||||||||||
| patch("agentuity.server.format_trace_id", return_value="test-trace-id"), | ||||||||||||||||||||||||||||||||||||
| patch( | ||||||||||||||||||||||||||||||||||||
| "agentuity.server.run_agent", new_callable=AsyncMock | ||||||||||||||||||||||||||||||||||||
| ) as mock_run_agent, | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
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.
Bug: session_id becomes the literal string "None" when tracing isn’t recording.
str(run_id) coerces None → "None". Downstream code will see a non-empty session_id, which is misleading.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents