Commit b3e88ff
Code review fixes/pr 105 v3 (#115)
* fix(runtime): implement thread-safe singleton with eager initialization
Convert OperationResult.success() singleton from lazy to eager initialization
at module level. Python's import lock ensures thread-safe initialization,
eliminating the race condition in the previous check-and-create pattern.
Addresses CRM-001 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(tooling): include error response body in HTTP error log message
Add truncated error_text (max 500 chars) to the log message when HTTP
errors occur in send_chat_history. This improves debugging by showing
the actual error response from the MCP platform.
Addresses CRM-002 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(tooling): reorder exception handlers for proper timeout handling
Move asyncio.TimeoutError handler before aiohttp.ClientError to ensure
timeouts are caught correctly. Since aiohttp.ServerTimeoutError inherits
from both exceptions, the previous order could misclassify timeouts.
Addresses CRM-003 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(tooling): add type hints for local variables in send_chat_history
Add Optional[str] type annotations for conversation_id, message_id, and
user_message variables to improve code clarity and IDE support.
Addresses CRM-004 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs(tooling): improve validation error messages in ChatHistoryMessage
Update error messages to say "cannot be empty or whitespace-only" instead
of just "cannot be empty" for clearer feedback when whitespace validation
fails.
Addresses CRM-005 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(tooling): extract timeout and HTTP status code to constants
Add DEFAULT_REQUEST_TIMEOUT_SECONDS and HTTP_STATUS_OK module-level
constants to replace magic values. Improves maintainability and makes
configuration easier to modify.
Addresses CRM-006 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs(runtime): enhance defensive copy docstring in OperationResult.errors
Move the defensive copy rationale into a prominent Note section in the
docstring to make it more visible to developers. This clarifies why the
property returns a copy rather than the internal list.
Addresses CRM-007 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test(tooling): use Mock(spec=TurnContext) for stricter interface validation
Import TurnContext and use it as a spec for the mock fixture. This ensures
the mock matches the actual TurnContext interface, catching potential
issues if the API changes.
Addresses CRM-008 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs(tooling): add usage example to send_chat_history docstring
Add an Example section showing how to create ChatHistoryMessage objects
and call send_chat_history with proper error handling. This helps
developers understand the intended usage pattern.
Addresses CRM-009 from code review.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Johan Broberg <johanb@microsoft.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 8f9b0d4 commit b3e88ff
4 files changed
Lines changed: 55 additions & 19 deletions
File tree
- libraries
- microsoft-agents-a365-runtime/microsoft_agents_a365/runtime
- microsoft-agents-a365-tooling/microsoft_agents_a365/tooling
- models
- services
- tests/tooling/services
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | | - | |
52 | | - | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
64 | | - | |
65 | | - | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
Lines changed: 40 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
48 | 59 | | |
49 | 60 | | |
50 | 61 | | |
| |||
532 | 543 | | |
533 | 544 | | |
534 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
535 | 560 | | |
536 | 561 | | |
537 | 562 | | |
| |||
543 | 568 | | |
544 | 569 | | |
545 | 570 | | |
546 | | - | |
| 571 | + | |
547 | 572 | | |
548 | 573 | | |
549 | | - | |
550 | | - | |
| 574 | + | |
| 575 | + | |
551 | 576 | | |
552 | | - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
553 | 580 | | |
554 | 581 | | |
555 | 582 | | |
| |||
592 | 619 | | |
593 | 620 | | |
594 | 621 | | |
595 | | - | |
| 622 | + | |
596 | 623 | | |
597 | 624 | | |
598 | | - | |
| 625 | + | |
599 | 626 | | |
600 | 627 | | |
601 | 628 | | |
602 | 629 | | |
603 | 630 | | |
604 | | - | |
| 631 | + | |
| 632 | + | |
605 | 633 | | |
606 | 634 | | |
607 | 635 | | |
| |||
613 | 641 | | |
614 | 642 | | |
615 | 643 | | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | 644 | | |
| 645 | + | |
| 646 | + | |
620 | 647 | | |
621 | 648 | | |
622 | 649 | | |
623 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
624 | 654 | | |
625 | 655 | | |
626 | 656 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
0 commit comments