forked from molecule-ai/molecule-core
fix(a2a): document the metadata-attach except-pass in a2a_executor (closes #1787)
GitHub Code Quality bot flagged the empty `except (AttributeError,
TypeError): pass` at workspace/a2a_executor.py:424 as a nit on PR #1783.
The suppression IS intentional — `new_agent_text_message()` returns
a plain string in MagicMock paths in tests where assignment to
`.metadata` raises despite hasattr being true.
This:
- Adds a why-comment citing the test-mock motivation, commit
dcbcf19 (the original guard), and issue #1787 so the next
code-quality pass doesn't re-flag it.
- Adds `logger.debug("metadata attach skipped (non-Message ...")`
for observability — debug-level so production logs stay quiet
but ops can flip the level if metadata loss is ever suspected.
Behavior unchanged. 43 existing a2a_executor tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
889cc2f9fe
commit
76d0f8d004
@ -422,7 +422,14 @@ class LangGraphA2AExecutor(AgentExecutor):
|
||||
try:
|
||||
msg.metadata = {"tool_trace": tool_trace}
|
||||
except (AttributeError, TypeError):
|
||||
pass
|
||||
# `new_agent_text_message()` returns a plain string in
|
||||
# MagicMock paths in tests, where assignment to
|
||||
# .metadata raises despite hasattr being true (the
|
||||
# mock has the attribute as a property). Suppression
|
||||
# is intentional — production Message objects always
|
||||
# accept the assignment. See #1787 + commit dcbcf19
|
||||
# for the original test-mock motivation.
|
||||
logger.debug("metadata attach skipped (non-Message return from new_agent_text_message)")
|
||||
await event_queue.enqueue_event(msg)
|
||||
_result = final_text
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user