Skip to content

Commit 4a8ee72

Browse files
fix: address Copilot review - empty name handling and type annotation
- _sanitize_author_name returns None for empty string (avoids invalid OpenAI name field that doesn't match ^[^\s<|\\/>]+$ regex) - Fix create_agents return type: dict[str, Agent] not list[Agent] - Update test assertion to match new empty-string behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b9979a7 commit 4a8ee72

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/processor/src/libs/agent_framework/azure_openai_response_retry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,10 @@ def _sanitize_author_name(name: Any) -> Any:
284284
empty (e.g. name was all whitespace), returns ``None`` so the field can be
285285
dropped entirely.
286286
"""
287-
if not isinstance(name, str) or not name:
287+
if not isinstance(name, str):
288288
return name
289+
if not name:
290+
return None
289291
if not _OPENAI_NAME_INVALID_CHARS.search(name):
290292
return name
291293
sanitized = _OPENAI_NAME_INVALID_CHARS.sub("_", name).strip("_")

src/processor/src/libs/base/orchestrator_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async def prepare_agent_infos(self) -> list[AgentInfo]:
145145

146146
async def create_agents(
147147
self, agent_infos: list[AgentInfo], process_id: str
148-
) -> list[Agent]:
148+
) -> dict[str, Agent]:
149149
agents = dict[str, Agent]()
150150
agent_client = await self.get_client(thread_id=process_id)
151151

src/processor/src/tests/unit/libs/agent_framework/test_azure_openai_response_retry_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_sanitize_author_name_replaces_whitespace_and_specials() -> None:
111111

112112
def test_sanitize_author_name_handles_edge_cases() -> None:
113113
assert _sanitize_author_name(None) is None
114-
assert _sanitize_author_name("") == ""
114+
assert _sanitize_author_name("") is None
115115
assert _sanitize_author_name(123) == 123
116116
# All-invalid input collapses to empty -> None (so callers drop the field).
117117
assert _sanitize_author_name(" ") is None

0 commit comments

Comments
 (0)